Skip to content

Local development

The backend needs PostgreSQL 16, Redis 7, and (for OTP/email testing) MailHog. docker-compose provides them.

Terminal window
cd trile
./start.sh # .env → infra up → wait healthy → migrate → build → api+scheduler+worker

start.sh copies .env.example to .env if missing, brings up infra, runs migrations, and launches all three process roles with clean shutdown on Ctrl-C.

Terminal window
cd trile
docker compose up -d # infra only: postgres, redis, mailhog
pnpm install
pnpm migrate # apply Drizzle migrations
pnpm dev # api process with watch
# in separate shells, if you need them:
pnpm start:worker
pnpm start:scheduler
ServiceURL
APIhttp://localhost:3000
OpenAPI JSONhttp://localhost:3000/docs-json
Swagger UIhttp://localhost:3000/docs
MailHog (OTP/email inbox)http://localhost:8025
Health / readiness/healthz, /readyz

Useful scripts: pnpm typecheck, pnpm lint (Biome), pnpm test / pnpm test:e2e (Testcontainers spins real Postgres + Redis), pnpm migrate:generate, pnpm seed:demo.

Terminal window
cd docs
npm install
npm run dev # http://localhost:4321
npm run build # static output in dist/
npm run preview # serve the build

The API Reference is rendered from src/openapi/trile.json. Refresh it from a running backend:

Terminal window
cd trile && pnpm dev # backend on :3000 (in one shell)
cd docs
TRILE_API_URL=http://localhost:3000 npm run sync:openapi

The committed trile.json is a curated snapshot so the docs build without a live API; the sync script overwrites it with the full live spec. Re-run sync and commit the JSON whenever backend endpoints or DTOs change.