For DevelopersServices
Server Service (apps/server)
Hono API running on Bun. Serves JSON APIs, OpenAPI JSON and interactive reference, and static DB schema assets.
Entrypoint (src/index.ts)
- Initializes Sentry, compression, CORS, logging
- Serves static assets:
/schema,/schema.dbml,/schema.svg - Exposes OpenAPI JSON at
/openapi/jsonand interactive reference at/openapi - Registers all routes from
src/routes/** - Starts Bun server on
ENV.SERVER_PORT(default parsed from string, default '8080') - Initializes an all-time impact cache cron on non-development environments
Routes
- Root and feature routes under
src/routes/**with clear segmentation: partners, locations, rescues, transfers, users, impact, ai - Each feature also has service-layer logic under
src/services/**
Environment (src/utils/env.ts)
- Validated by Zod. Required:
ENV_NAMEin ['development','staging','production']NODE_ENVin ['development','production','test']SERVER_PORT,SENTRY_DSN_API,DATABASE_URL,DATABASE_READ_REPLICA_URLCLERK_PUBLISHABLE_KEY,CLERK_SECRET_KEYS3_ACCESS_KEY_ID,S3_SECRET_ACCESS_KEY,S3_REGION,S3_BUCKET,S3_ENDPOINT,RESEND_API_KEY,ANTHROPIC_API_KEY
CORS (src/utils/cors.ts)
- Per-environment allowed origins; credentials enabled; standard methods/headers
OpenAPI helpers (src/utils/openapi.ts)
defaultErrorResponsesandmessageResponseSchemafor consistent route responses
Docker image (apps/server/Dockerfile)
- Multi-stage: builder compiles server for linting; production installs only prod deps filtered for server/types/db
- Generates DB schema assets by running
packages/dbgenerator - Runs as non-root, exposes 8080, starts with
bun start
Railway (apps/server/railway.json)
- Builder: DOCKERFILE (path
apps/server/Dockerfile) - Healthcheck:
/, timeout 180s - Production default: 3 replicas, generous CPU/memory, multi-region
- Staging sleeps
Local dev
bun devat root (Turbo starts server first)- Or
cd apps/server && bun run dev