Part 1: Your First Project
Build a full-stack application on Prisma in four parts: a Project, an Effect-native Compute API, a Postgres database, and a Vite frontend. The complete example contains the final application and its deployment test.
Prerequisites
Section titled “Prerequisites”- Bun or Node.js 22+ installed locally.
- A Prisma workspace with access to Compute and Postgres.
- A workspace service token from the Prisma Console.
Create a directory
Section titled “Create a directory”mkdir prisma-tutorialcd prisma-tutorialKeep all of the following files in this directory.
Initialize the package
Section titled “Initialize the package”bun init -ynpm init -ypnpm inityarn init -yThis creates the package.json that records your dependencies.
Install Alchemy
Section titled “Install Alchemy”bun add "alchemy@next" "effect@rc" "@effect/platform-node@rc"npm install "alchemy@next" "effect@rc" "@effect/platform-node@rc"pnpm add "alchemy@next" "effect@rc" "@effect/platform-node@rc"yarn add "alchemy@next" "effect@rc" "@effect/platform-node@rc"Use matching Effect versions for Alchemy and the platform packages.
Configure credentials
Section titled “Configure credentials”bun alchemy profile edit --add Prismanpx alchemy profile edit --add Prismapnpm exec alchemy profile edit --add Prismayarn alchemy profile edit --add PrismaEnter your service token when prompted. Setup explains
profiles and the PRISMA_SERVICE_TOKEN environment variable used in CI.
Ignore local state
Section titled “Ignore local state”Create .gitignore:
node_modules/.alchemy/dist/.envAlchemy’s local state contains resource identifiers and potentially sensitive outputs. Keep it out of source control, but retain it between deployments.
Create the Stack
Section titled “Create the Stack”Create alchemy.run.ts:
import * as Alchemy from "alchemy";import * as Prisma from "alchemy/Prisma";import * as Effect from "effect/Effect";
export default Alchemy.Stack( "PrismaTutorial", { providers: Prisma.providers(), state: Alchemy.localState() }, Effect.gen(function* () {}),);A Stack groups resources. The Prisma providers manage them, and local state records what this Stack owns. For shared deployments, use a shared state store instead.
Define a Project
Section titled “Define a Project”Create src/Database.ts:
import * as Prisma from "alchemy/Prisma";
export const Project = Prisma.Project("Project", { createDatabase: false, region: "eu-west-3",});The Project will contain both Compute services and Postgres. Disable the implicit default database because Part 3 creates an explicit database resource. Alchemy generates a physical name from the Stack, stage, and logical ID.
Add the Project to the Stack
Section titled “Add the Project to the Stack”import { Project } from "./src/Database.ts";
Effect.gen(function* () {}), Effect.gen(function* () { const project = yield* Project; return { projectId: project.projectId }; }),Yielding the resource registers it in the Stack. Returning its ID makes that value visible in the deployment output.
Deploy
Section titled “Deploy”bun alchemy deploynpx alchemy deploypnpm exec alchemy deployyarn alchemy deployAlchemy creates the Project and prints projectId. Use the same profile and
stage throughout the tutorial so each deployment updates this Stack.
Part 2: An HTTP API adds an Effect-native Compute service to the Project.