1# Prisma tutorial
2
3The complete application from the [four-part Prisma tutorial](https://alchemy.run/prisma/tutorial/part-1): a shared Project, Effect-native Compute API, Postgres connection, and Vite frontend.
4
5## Run
6
7From the repository root, install dependencies with `pnpm install`. Then:
8
9```sh
10cd examples/prisma-tutorial
11bun alchemy profile edit --add Prisma
12bun run deploy
13```
14
15Open the returned website URL and click **Read database time**. The API executes `SELECT current_timestamp::text AS time` against Prisma Postgres; no schema setup is needed.
16
17```sh
18bun run dev
19```
20
21The frontend runs locally in Vite. The API, its database, and the shared Project remain remote because the Stack explicitly uses `Alchemy.remote()`. Credentials and cloud charges still apply. A separate `--stage dev` creates a separate remote backend rather than using another stage's database.
22
23## Test
24
25```sh
26ALCHEMY_PROFILE=testing timeout 240 bun test
27```
28
29The test deploys the real application, queries Postgres over HTTP, checks CORS and error routes, and destroys the Stack afterward. Set `NO_DESTROY=1` only when retaining the deployment for manual browser verification.
30
31## Cleanup
32
33```sh
34bun run destroy
35```
36
37Use the profile and stage used for deployment. For retained test deployments, pass the test harness's stage with `--stage`; this is separate from the normal deploy stage. Retain `.alchemy/` until cleanup finishes.
38
39The API deliberately exposes only a read-only database timestamp and allows all origins. Restrict origins and add authentication before exposing private data. Only the public API URL goes into `VITE_API_URL`; database credentials stay in the Compute binding.