This monorepo is a full-stack application setup using Bun workspaces.
packages/db: Contains the Drizzle ORM schema, client, and migration scripts.packages/shared: Contains shared code, primarily Zod schemas generated from the Drizzle schema viadrizzle-zod.packages/backend: A Hono API server running on Bun. It handles auth via Supabase and serves a protected API.packages/frontend: A Vue 3 + Pinia + Vite frontend that consumes the Hono API usinghono/client.
To avoid circular dependencies, the frontend imports the Hono AppType directly from the backend package.
The shared package is reserved for code that is truly platform-agnostic and can be shared by both frontend and backend without creating import loops (e.g., Zod validation schemas).
Dependency Graph:
frontend->backend(forAppType)frontend->shared(for Zod schemas)backend->shared(for Zod schemas)backend->db(for Drizzle client)shared->db(for Drizzle schema types)
-
Install Dependencies:
bun install
-
Setup Supabase:
- Create a new Supabase project.
- Enable Email/Password authentication.
- Go to Project Settings > Database and get your Connection string (URI).
-
Environment Variables:
- Copy
packages/backend/.env.exampletopackages/backend/.env. - Fill in
DATABASE_URLwith your Supabase connection string. - Fill in
SUPABASE_URLandSUPABASE_SERVICE_KEYfrom your Supabase Project Settings > API. - Copy
packages/frontend/.env.exampletopackages/frontend/.env. - Fill in
VITE_SUPABASE_URLandVITE_SUPABASE_ANON_KEY(the public anon key). - Set
VITE_API_URL(default ishttp://localhost:3000).
- Copy
-
Run Database Migrations:
cd packages/dbbun db:generate(This generates the SQL for your schema)bun db:migrate(This applies the migrations to your Supabase DB)cd ../..(Return to root)
-
Run the Application:
- In one terminal, run the backend:
bun --cwd packages/backend dev
- In another terminal, run the frontend:
bun --cwd packages/frontend dev
- In one terminal, run the backend:
-
Open the App:
- Open your browser to the URL provided by the Vite dev server (usually
http://localhost:5173). - Sign up for a new account (using your Supabase auth).
- Log in.
- Click "Fetch My API Profile" to test the authenticated call to your Hono backend.
- Open your browser to the URL provided by the Vite dev server (usually