Skip to content
STACK IT FIRST
Install the skills
03 · Backend · Growth · Product API

NestJS + Postgres + Redis

One service with strong module conventions, a queue for side effects, and an OpenAPI document clients are generated from.
Agent fit5/5 Growth · Charge for it Reviewed

The stack

Framework
NestJS
Runtime
Node.js 24 LTS in a container
Data
Managed Postgres via Prisma or Drizzle, Redis for cache and queues
Auth
Passport with a hosted OIDC provider
Hosting
Fly, Railway, or ECS
Also
  • OpenAPI from decorators, clients generated for web and mobile
  • BullMQ for jobs
  • Jest with testcontainers for Postgres
AGENTS.md + real projects on STACK IT FAST (opens in a new tab)

Why agents do well here

5/5
  • NestJS's module, controller, service and DTO convention is rigid enough that the agent knows exactly where new code goes.
  • Generated OpenAPI plus generated clients turn a schema change into a compile error in every consumer, which is the feedback loop that keeps consumers safe.
  • Decorators make validation and documentation live next to the handler, so the agent reads one file to understand a route.

Avoid at this tier

  • Splitting into microservices; split into modules with clear imports.
  • Hand-written clients in the frontend; generate them.
  • Synchronous webhooks or emails; everything goes through BullMQ.

How it fits together

At growth the API has consumers it does not control. NestJS gives the structure, OpenAPI gives the contract, and BullMQ takes every side effect out of the request path.

Folder layout

src/
  modules/<domain>/   controller.ts, service.ts, dto/, entities/, *.spec.ts
  jobs/               processors for BullMQ queues
  common/             guards, interceptors, filters
prisma/ or drizzle/   schema + migrations
openapi.json          generated in CI, consumed by packages/api-client

First five decisions

Lock these in before the agent writes the second feature. Each one removes a choice it would otherwise make differently every time.

  1. 01 Modules by domain
  2. 02 OpenAPI generated and versioned
  3. 03 Generated clients only
  4. 04 BullMQ for side effects
  5. 05 Testcontainers so tests hit a real Postgres

When to move on

Stay here until the product forces the next tier. You are ready for Scale when:

  • More than one team deploys backend code independently
  • Data lives in more than one region or under residency rules
  • An auditor will ask who changed what
  • Latency and throughput are contractual, not aspirational
Scale · Product API Go services + Postgres, Rust where latency is the product Compiled, typed services with a generated contract each, boring infrastructure, and a compiler as the second reviewer. Next tier

Same tier, other profiles