1---
2title: "Part 1: Your First Project"
3description: Install Alchemy, configure Prisma credentials, and deploy your first Project.
4sidebar:
5 order: 1
6---
7
8import { Code, Tabs, TabItem } from "@astrojs/starlight/components";
9import { effectVersion } from "../../../../versions";
10
11export const pkgs = `"alchemy@next" "effect@${effectVersion}" "@effect/platform-node@${effectVersion}"`;
12
13Build a full-stack application on Prisma in four parts: a Project, an
14Effect-native Compute API, a Postgres database, and a Vite frontend.
15The [complete example](https://github.com/alchemy-run/alchemy/tree/main/examples/prisma-tutorial)
16contains the final application and its deployment test.
17
18## Prerequisites
19
20- [Bun](https://bun.sh) or Node.js 22+ installed locally.
21- A Prisma workspace with access to Compute and Postgres.
22- A workspace service token from the [Prisma Console](https://console.prisma.io).
23
24:::caution[Cloud costs]
25This tutorial deploys real infrastructure. Compute and Postgres may incur
26charges. Part 4 ends with `alchemy destroy`; you can also run it after any
27part to remove the resources created so far.
28:::
29
30## Create a directory
31
32```sh
33mkdir prisma-tutorial
34cd prisma-tutorial
35```
36
37Keep all of the following files in this directory.
38
39## Initialize the package
40
41<Tabs syncKey="pkgManager">
42 <TabItem label="bun" icon="bun"><Code code="bun init -y" lang="sh" /></TabItem>
43 <TabItem label="npm" icon="npm"><Code code="npm init -y" lang="sh" /></TabItem>
44 <TabItem label="pnpm" icon="pnpm"><Code code="pnpm init" lang="sh" /></TabItem>
45 <TabItem label="yarn" icon="seti:yarn"><Code code="yarn init -y" lang="sh" /></TabItem>
46</Tabs>
47
48This creates the `package.json` that records your dependencies.
49
50## Install Alchemy
51
52<Tabs syncKey="pkgManager">
53 <TabItem label="bun" icon="bun"><Code code={`bun add ${pkgs}`} lang="sh" /></TabItem>
54 <TabItem label="npm" icon="npm"><Code code={`npm install ${pkgs}`} lang="sh" /></TabItem>
55 <TabItem label="pnpm" icon="pnpm"><Code code={`pnpm add ${pkgs}`} lang="sh" /></TabItem>
56 <TabItem label="yarn" icon="seti:yarn"><Code code={`yarn add ${pkgs}`} lang="sh" /></TabItem>
57</Tabs>
58
59Use matching Effect versions for Alchemy and the platform packages.
60
61## Configure credentials
62
63<Tabs syncKey="pkgManager">
64 <TabItem label="bun" icon="bun"><Code code="bun alchemy profile edit --add Prisma" lang="sh" /></TabItem>
65 <TabItem label="npm" icon="npm"><Code code="npx alchemy profile edit --add Prisma" lang="sh" /></TabItem>
66 <TabItem label="pnpm" icon="pnpm"><Code code="pnpm exec alchemy profile edit --add Prisma" lang="sh" /></TabItem>
67 <TabItem label="yarn" icon="seti:yarn"><Code code="yarn alchemy profile edit --add Prisma" lang="sh" /></TabItem>
68</Tabs>
69
70Enter your service token when prompted. [Setup](/prisma/setup) explains
71profiles and the `PRISMA_SERVICE_TOKEN` environment variable used in CI.
72
73## Ignore local state
74
75Create `.gitignore`:
76
77```text
78node_modules/
79.alchemy/
80dist/
81.env
82```
83
84Alchemy's local state contains resource identifiers and potentially sensitive
85outputs. Keep it out of source control, but retain it between deployments.
86
87## Create the Stack
88
89Create `alchemy.run.ts`:
90
91```typescript
92import * as Alchemy from "alchemy";
93import * as Prisma from "alchemy/Prisma";
94import * as Effect from "effect/Effect";
95
96export default Alchemy.Stack(
97 "PrismaTutorial",
98 { providers: Prisma.providers(), state: Alchemy.localState() },
99 Effect.gen(function* () {}),
100);
101```
102
103A Stack groups resources. The Prisma providers manage them, and local state
104records what this Stack owns. For shared deployments, use a
105[shared state store](/state-store) instead.
106
107## Define a Project
108
109Create `src/Database.ts`:
110
111```typescript
112import * as Prisma from "alchemy/Prisma";
113
114export const Project = Prisma.Project("Project", {
115 createDatabase: false,
116 region: "eu-west-3",
117});
118```
119
120The Project will contain both Compute services and Postgres. Disable the
121implicit default database because Part 3 creates an explicit database resource.
122Alchemy generates a physical name from the Stack, stage, and logical ID.
123
124## Add the Project to the Stack
125
126```diff lang="typescript"
127// alchemy.run.ts
128+import { Project } from "./src/Database.ts";
129
130- Effect.gen(function* () {}),
131+ Effect.gen(function* () {
132+ const project = yield* Project;
133+ return { projectId: project.projectId };
134+ }),
135```
136
137Yielding the resource registers it in the Stack. Returning its ID makes that
138value visible in the deployment output.
139
140## Deploy
141
142<Tabs syncKey="pkgManager">
143 <TabItem label="bun" icon="bun"><Code code="bun alchemy deploy" lang="sh" /></TabItem>
144 <TabItem label="npm" icon="npm"><Code code="npx alchemy deploy" lang="sh" /></TabItem>
145 <TabItem label="pnpm" icon="pnpm"><Code code="pnpm exec alchemy deploy" lang="sh" /></TabItem>
146 <TabItem label="yarn" icon="seti:yarn"><Code code="yarn alchemy deploy" lang="sh" /></TabItem>
147</Tabs>
148
149Alchemy creates the Project and prints `projectId`. Use the same profile and
150stage throughout the tutorial so each deployment updates this Stack.
151
152## Next
153
154[Part 2: An HTTP API](/prisma/tutorial/part-2) adds an Effect-native Compute
155service to the Project.