1# Prisma Compute Effect
2
3Minimal Effect-native Prisma Compute app managed by Alchemy.
4
5This example is intentionally not a framework app. It shows the provider-native
6runtime path:
7
8- `Prisma.Project`
9- `Prisma.Postgres`
10- `Prisma.Connection`
11- `Prisma.Compute(..., Effect.gen(...))`
12- `Prisma.Connect(Connection)` inside the deployed runtime
13
14`alchemy.run.ts` only wires the stack together. The Prisma data resources live
15in `src/Database.ts`, and the Effect-native Compute app lives in
16`src/Api.ts`.
17
18Prisma creates the project-owned default `main` branch as part of project
19creation. The database and app select that branch by `branchGitName` instead of
20trying to manage the default branch as a standalone resource.
21
22The deployed app responds on `/` and `/api/health`. The health route reports
23whether the runtime database binding is available without exposing connection
24strings or infrastructure IDs. It verifies binding delivery, not a database
25query.
26
27## Durable State Prerequisite
28
29This stack always uses `Cloudflare.state()`. Alchemy state is stored in a
30Cloudflare Worker backed by a Durable Object with embedded SQLite; its bearer
31token and encryption key live in Cloudflare Secrets Store. There is
32intentionally no local-state fallback. Alchemy does not currently ship a
33Prisma-hosted remote state store, so this example selects the built-in durable
34backend explicitly.
35
36Before the first deploy, make one Cloudflare account available to every trusted
37operator and CI runner that will deploy or destroy this stack, then bootstrap
38the state store once:
39
40```sh
41export CLOUDFLARE_ACCOUNT_ID="..."
42export CLOUDFLARE_API_TOKEN="..."
43bunx alchemy provider cloudflare bootstrap
44```
45
46Keep those Cloudflare credentials configured for every later deploy and
47destroy. The default state-store Worker is shared across stacks and stages;
48Alchemy scopes this stack's records by stack name and stage.
49
50## Deploy
51
52```sh
53export CLOUDFLARE_ACCOUNT_ID="..."
54export CLOUDFLARE_API_TOKEN="..."
55export PRISMA_SERVICE_TOKEN="..."
56export PRISMA_EFFECT_APP="my-team-effect-api-production"
57bun run deploy --stage production
58```
59
60The App name must be stable and unique within the Prisma workspace. The example
61defaults it from the Alchemy stage for local use; production and CI should set
62`PRISMA_EFFECT_APP` to a deterministic environment-specific value. The Project
63name is provider-generated by default so interrupted creates can be recovered
64safely; set `PRISMA_PROJECT` only when an externally fixed Console name is
65required.
66
67Copy the `url` value from the deploy output before checking the app:
68
69```sh
70URL="https://your-app.prisma.build"
71```
72
73## Check It
74
75```sh
76curl --fail-with-body --show-error "$URL/"
77curl --fail-with-body --show-error "$URL/api/health"
78```
79
80The response should include:
81
82```json
83{
84 "ok": true,
85 "mode": "effect-native",
86 "databaseBinding": "ready"
87}
88```
89
90## Destroy
91
92```sh
93export CLOUDFLARE_ACCOUNT_ID="..."
94export CLOUDFLARE_API_TOKEN="..."
95export PRISMA_SERVICE_TOKEN="..."
96export PRISMA_EFFECT_APP="my-team-effect-api-production"
97bun run destroy --stage production
98```