Ai Referrer is a separated frontend/backend project organized into api (server) and web (frontend).
api/: Backend service code (Bun + TypeScript), providing APIs and business logic.web/: Frontend app code (Vite + TypeScript), providing the user interface.packages/: Reserved shared package directory (for common types, utilities, SDKs, etc.).CLAUDE.md: Project collaboration and development conventions.
The API depends on PostgreSQL and Prisma migrations in packages/db.
Start the local database:
docker compose up -d postgresThe default local connection is already configured in packages/db/.env:
DATABASE_URL="postgresql://postgres:postgres@localhost:5434/ai_referrer?schema=public"Apply existing migrations to your local development database:
cd packages/db
bun install
bun prisma migrate deploy --schema prisma/schema.prisma
bun prisma generate --schema prisma/schema.prismaIf you want Prisma to create a new migration while developing schema changes, use:
cd packages/db
bun prisma migrate dev --schema prisma/schema.prisma --name your_migration_namecd api
bun install
bun run devDefault URL: http://localhost:3000
cd web
bun install
bun run devDefault URL (Vite): usually http://localhost:5173
- See
api/README.mdfor API details. - See
web/README.mdfor Web details.
Create two services in Coolify from the same repository:
- API Service
- Build Pack:
Nixpacks - Base Directory: repository root (
.) - Port:
3000
- Build Pack:
- Web Service
- Build Pack:
Nixpacks - Base Directory:
web - Port:
3000(the port used byvite previewinside the container)
- Build Pack:
This repository includes build/start settings in:
- API at repository root:
nixpacks.toml - Web in subdirectory:
web/nixpacks.toml
Use the root service for API so api can access packages/db during install and runtime.
Create OAuth 2.0 Web Client credentials in Google Cloud Console, then set:
web/.env.localVITE_GOOGLE_CLIENT_ID=your_google_web_client_id
api/.envGOOGLE_CLIENT_ID=your_google_web_client_idLOGIN_ALLOWED_EMAIL_SUFFIX=@yourcompany.com(optional, restrict login domain)