NestJS is a TypeScript-first Node.js framework that layers an opinionated application architecture — modules, controllers, and providers — on top of an underlying HTTP platform such as Express, and ships a CLI that scaffolds and builds projects following that architecture.
In simpler words
Nest is Express (or Fastify) with a structure enforced on top, plus a command-line tool that generates the files and builds the project for you.
After Node and Express, map what Nest adds: modules, DI, decorators, and the CLI that scaffolds them. Nest ≠ Next — Nest is this monorepo’s HTTP API and database owner; the React/Next frontend is a client that calls it over HTTP.
Read nest-cli.json and know what nest build/start do
Trace apps/api/src/main.ts from bootstrap to listening port
Say why Nest and Next are unrelated despite similar names
Nest vs Next — and what Nest actually is
Definition
NestJS is a backend Node.js framework for building HTTP APIs, while Next.js is a frontend/full-stack React framework for building rendered UI; the two share a similar name but no codebase or runtime relationship.
In simpler words
Nest answers HTTP requests with JSON and owns the database; Next renders React pages. This monorepo uses both, for different jobs.
apps/api is a Nest application: it owns Postgres (via TypeORM), the tickets/health/auth HTTP surface, and returns JSON.
apps/web is a Next.js application: it renders React UI and calls apps/api over HTTP/cookies. It does not import Nest modules or touch the database directly.
Nest sits on an HTTP platform adapter — Express by default (Fastify is swappable) — and adds modules, controllers, providers, and a dependency-injection container around it.
If you find yourself writing SQL in apps/web or JSX in apps/api, you are in the wrong app.
What the Nest CLI generates and builds
Definition
The Nest CLI (@nestjs/cli) is a command-line tool that scaffolds new Nest projects and files from schematics, and compiles a project according to nest-cli.json.
In simpler words
nest new starts a project, nest generate adds a piece (module/controller/service) with the right boilerplate, and nest build/start compile and run it.
apps/api/nest-cli.json sets sourceRoot: "src" and deleteOutDir: true so nest build cleans dist/ before compiling.
apps/api/package.json wires the CLI: "build": "nest build" and "dev": "nest start --watch". There is no nest generate script wired here — the CLI is a devDependency you can still run directly (npx nest generate module <name>) to scaffold new features consistently.
nest start --watch recompiles and restarts on save during local development.
Mistake: hand-rolling module boilerplate
// Wrong — copy-pasted from another feature, drifts from convention
touch tickets.module.ts // then guess the shape
// Right
npx nest generate module tickets
npx nest generate controller tickets
npx nest generate service tickets
Generators keep @Module/@Controller/@Injectable wiring consistent across a team.
From CLI output to a running app
Definition
A compiled Nest application boots by creating a root application instance from the root module, then Node executes the resulting HTTP listener.
In simpler words
nest build turns TypeScript into dist/, then node dist/main.js starts the server that main.ts describes.
apps/api/src/main.ts calls NestFactory.create(AppModule) to build the app from the root module, applies cookies/CORS/global pipes/filters/interceptors, sets up Swagger at /docs, then calls app.listen(env.PORT).
AppModule is the entry point the CLI-built app boots from — every controller and provider must be reachable from it through module imports.