Deployment Guide
Relevant source files
The following files were used as context for generating this wiki page:
The Subito project is a monorepo managed by Turborepo, consisting of multiple applications and shared packages. This guide outlines the infrastructure requirements, configuration parameters, and build processes necessary to deploy the Subito ecosystem.
The system comprises a Hono-based API server, a Next.js dashboard, and a PostgreSQL database layer managed via Drizzle ORM. Deployment requires a Node.js environment (version 20 or higher) and several external service integrations including Redis, Firebase, and Juspay.
Monorepo Architecture
The project utilizes a workspace-based architecture. Turborepo manages the task pipeline, ensuring that builds and migrations are executed in the correct dependency order.
The diagram above illustrates the internal dependency flow within the monorepo.
Sources: package.json:20-28, apps/api/package.json:28-30, apps/dashboard/package.json:16-17
Environment Configuration
A successful deployment requires the configuration of several environment variables across the API and Database layers. These variables control connectivity, security, and integration with third-party providers.
Core Infrastructure Variables
These variables are globally recognized by the build system and must be provided during the build and runtime phases.
| Variable | Description | Source |
|---|---|---|
DATABASE_URL | PostgreSQL connection string | turbo.json:5 |
REDIS_URL | Redis connection string for BullMQ | turbo.json:9 |
NODE_ENV | Environment mode (production/development) | turbo.json:10 |
PORT | Port number for the API server | turbo.json:21 |
Security & Authentication
The API utilizes JWT for session management. Secret keys must be at least 32 characters long.
| Variable | Description | Source |
|---|---|---|
JWT_SECRET | Secret key for signing HS256 tokens | apps/api/src/lib/jwt.ts:10-15 |
JWT_ISSUER | Identity of the token issuer (default: subito-api) | apps/api/src/lib/jwt.ts:20 |
ACCESS_TOKEN_EXPIRY | Duration for access tokens (default: 15m) | apps/api/src/lib/jwt.ts:23 |
FIREBASE_SERVICE_ACCOUNT | JSON credentials for Firebase Admin | turbo.json:19 |
Database Deployment
The database layer uses Drizzle ORM with a PostgreSQL backend. Deployment involves generating SQL migrations from the schema and applying them to the target database.
Migration Workflow
- Generate: Create migration files based on schema changes.
- Migrate: Apply the generated SQL files to the production database.
- Seed: Populate the database with initial configurations or required lookups.
Sequence for preparing and initializing the database layer.
Sources: packages/db/package.json:11-15, packages/db/src/seed.ts:1-10
Build and Execution
Deployment is handled through the Turborepo pipeline, which orchestrates builds for all workspace members.
Build Commands
The root package.json provides scripts to trigger the build across the entire monorepo.
| Command | Action |
|---|---|
pnpm build | Executes turbo build to compile API and Dashboard |
pnpm start (API) | Runs node dist/index.js in the API directory |
pnpm start (Dashboard) | Runs next start in the Dashboard directory |
Sources: package.json:6, apps/api/package.json:10, apps/dashboard/package.json:9
API Execution Details
The API is built using tsup into an ESM format and served via @hono/node-server.
# Within apps/api
pnpm run build # Compiles src/index.ts to dist/
pnpm run start # Starts the production server
Sources: apps/api/package.json:8-10
Service Dependencies
The Subito API relies on several external services that must be accessible at runtime:
- PostgreSQL: Primary data store for users, bookings, and payments.
- Redis: Used for BullMQ job processing and potentially caching.
- Firebase: Used for UID-based authentication and FCM notifications.
- Juspay: Payment gateway integration for order processing.
Sources: apps/api/package.json:31-36, turbo.json:19-20
Summary
Deploying Subito requires a coordinated build of its monorepo components. Key steps include setting up a Node.js 20+ environment, configuring mandatory environment variables for JWT and database access, executing Drizzle migrations, and building the API and Dashboard applications. The system architecture depends heavily on external service connectivity for authentication, payments, and background tasks.