Skip to content

API

The API is a Node.js service that runs inside Docker Compose as part of the backend profile. It provides the legacy v1 REST and GraphQL API.

Running

bash
pnpm dev:backend

The API is available at http://localhost:3001. Traffic routed through the API Gateway is available at http://localhost:8888/api.

Environment Variables

The API loads environment variables from two sources:

  • apps/api/.env -- mounted into the container via Docker Compose
  • Docker Compose environment block -- overrides for container networking (database host, Redis host, etc.)

Key overrides set by Docker Compose:

VariableValueDescription
MAIN_DB_CONNECTION_STRINGpostgresql://postgres:postgres@postgres:5432/mainPostgres via Docker network
REDIS_URLredis://redis:6379Redis via Docker network
GRAPHQL_SCHEMAhttp://localhost:3000/api/graphqlGraphQL introspection endpoint
OTEL_EXPORTER_OTLP_ENDPOINThttp://aspire-dashboard:18889OpenTelemetry — see Observability

Hot Reload

The API runs in dev mode using tsup --watch. Source code is mounted via ./:/workspace:delegated, so file changes trigger an automatic rebuild and restart inside the container.

Database

The API connects to the postgres service (main database). To reset the database:

bash
docker compose down -v
pnpm dev:backend

WARNING

-v removes all named volumes including pnpm store and node_modules caches.

Logs

bash
docker compose logs -f api

Output is piped through pino-pretty for readable structured logs.