Bakestack is currently a modular monolith built with NestJS, TypeScript, PostgreSQL, Redis, and TypeORM. Identity, sessions, verification, invites, and security audit concerns are delegated to the separate bakestake-identity service.
- Runtime: Node.js 20
- Package manager: npm
- Application shape: modular monolith
- Identity boundary: external
bakestake-identityservice - Data boundary in this repo: bakery operations, catalog, inventory, orders, customers, payments, analytics, outreach, media
- Environment validation with fail-fast startup
- Secure bootstrap with Helmet, compression, request size limits, and environment-driven CORS
- Request correlation ids and structured request logging
- Redis centralized as shared infrastructure instead of ad hoc client construction
- Public-auth rate limiting on sensitive entry points
- Liveness, readiness, and dependency health endpoints
- Explicit production migration runners
- Docker, PM2, Nginx, and deployment notes
- Future extraction scaffold in
microservices/
- docs/architecture.md
- docs/domain-boundaries.md
- docs/security.md
- docs/observability.md
- docs/idempotency.md
- docs/pos-sync.md
- docs/runbooks.md
- docs/incident-response.md
- docs/migrations.md
- docs/api-versioning.md
- docs/production-readiness-checklist.md
GET /api/health/liveGET /api/health/readyGET /api/healthGET /api/health/dependencies/identity
- Development template:
.env.example - Production template:
.env.production.example
Core variables:
APP_NAMEAPI_PREFIXHOSTPORTNODE_ENVPUBLIC_APP_URLENABLE_SWAGGERTRUST_PROXYREQUEST_BODY_LIMITHELMET_ENABLEDCOMPRESSION_ENABLEDENABLE_REQUEST_LOGGINGCORS_ALLOWED_ORIGINSCORS_ALLOW_CREDENTIALSCORS_ALLOW_ALLDATABASE_HOSTDATABASE_PORTDATABASE_USERNAMEDATABASE_PASSWORDDATABASE_NAMEDATABASE_SSLDATABASE_POOL_SIZEDATABASE_CONNECTION_TIMEOUT_MSDATABASE_RETRY_ATTEMPTSDATABASE_RETRY_DELAY_MSREDIS_HOSTREDIS_PORTREDIS_PASSWORDREDIS_DBREDIS_TLSIDENTITY_BASE_URLIDENTITY_INTERNAL_API_KEYIDENTITY_INTERNAL_SERVICE_NAMEIDENTITY_SESSION_COOKIE_NAMEIDENTITY_CSRF_COOKIE_NAMEIDENTITY_REQUEST_TIMEOUT_MSIDENTITY_CACHE_TTL_SECONDSIDENTITY_REQUIRE_STEP_UP_FOR_PUBLISHJWT_SECRETJWT_EXPIRES_INTHROTTLE_AUTH_TTL_SECONDSTHROTTLE_AUTH_LIMITIDEMPOTENCY_TTL_HOURSENABLE_QUEUE_WORKERSQUEUE_DEFAULT_ATTEMPTSQUEUE_DEFAULT_BACKOFF_MSMETRICS_ENABLEDOTEL_SERVICE_NAMESTRIPE_WEBHOOK_SECRET
Identity service first:
cd "/Users/surajmahapatra/Desktop/OUTREACH SECURITY "
npm install
cp .env.example .env
docker compose up -d postgres redis
npm run prisma:generate
npm run prisma:migrate:deploy
npm run prisma:seed
npm run devThen this backend:
cd "/Users/surajmahapatra/Desktop/OUTREACH BACKEND"
npm install
cp .env.example .env
npm run migration:run
npm run seed
npm run start:identity-localstart:identity-local runs the delegated backend on http://localhost:3002/api, enables local CORS for the UI, and applies pending migrations on boot.
nvm use 20
npm ci
npm run build
npm run migration:run:prod
PORT=3002 npm run start:prod
curl -fsS http://127.0.0.1:3002/api/health/readyTo run migrations on boot intentionally:
RUN_MIGRATIONS_ON_BOOT=true npm run start:prod:safeDevelopment:
docker compose -f docker-compose.dev.yml up --buildProduction-style compose:
docker compose up --buildThe Docker image exposes a healthcheck against /api/health/live.
PM2 config is provided in ecosystem.config.cjs.
pm2 start ecosystem.config.cjs --env production
pm2 logs bakestake-backendDevelopment TS runner:
npm run migration:run
npm run migration:revertCompiled production runner:
npm run build
npm run migration:run:prod
npm run migration:revert:prodThe current backend should remain a monolith for now. The extraction staging area is in microservices/.
Best early extraction candidates:
worker-serviceanalytics-service
Later extraction candidates:
notification-serviceemail-servicebilling-service
Do not extract yet:
- catalog and inventory writes
- order creation and cancellation
- bakery settings and storefront publish workflow
- payment orchestration tied directly to orders
Those domains still share transactional consistency requirements and would become more fragile if split now.
npm run test:smoke
SMOKE_BASE_URL=http://localhost:3002 npm run test:smokeThe backend seed creates the bakery, categories, and products. Authentication credentials come from the separate identity service seed.
K6_BASE_URL=http://localhost:3002 \
K6_BAKERY_SLUG=sweet-crumbs \
npm run loadtest:catalogue
K6_BASE_URL=http://localhost:3002 \
K6_BAKERY_SLUG=sweet-crumbs \
npm run loadtest:checkout
K6_BASE_URL=http://localhost:3002 \
K6_STRIPE_WEBHOOK_SECRET=whsec_local_development_secret \
npm run loadtest:webhooksDetailed rollout and rollback guidance lives in docs/production-deployment.md.