NestJS project structure

NestJS project structure

Explorer

  • .git…
  • .devcontainernew
  • devcontainer.jsonnew
  • .huskynew
  • pre-commitnew
  • .vscodenew
  • extensions.jsonnew
  • launch.jsonnew
  • settings.jsonnew
  • coverage…new, not committed
  • dist…, not committed
  • node_modules…, not committed
  • src
  • app.controller.spec.ts
  • app.controller.ts
  • app.module.ts
  • app.service.ts
  • app.setup.tsnew
  • main.ts
  • test
  • app.e2e-spec.ts
  • auth.e2e-spec.tsnew
  • orders.e2e-spec.tsnew
  • .editorconfig
  • .envnew, not committed
  • .env.examplenew
  • .gitignore
  • .lintstagedrc.jsonnew
  • .nvmrcnew
  • .oxlintrc.json
  • .prettierrc
  • AGENTS.mdnew
  • CLAUDE.mdnew
  • compose.yamlnew
  • nest-cli.json
  • package-lock.json
  • package.json
  • README.md
  • tsconfig.build.json
  • tsconfig.json
  • vitest.config.e2e.ts
  • vitest.config.ts
  1. # Install the Nest CLI

    npm i -g @nestjs/cli
  2. # Create the project (pick ESM with Vitest when asked)

    nest new orders-api
  3. # Generate a feature: module, controller, service, DTOs, entity and tests

    nest g resource orders
  4. # Add config, validation and the database

    npm i @nestjs/config class-validator class-transformer @nestjs/typeorm typeorm pg
  5. # Add auth, queues, docs and rate limiting

    npm i @nestjs/jwt argon2 @nestjs/bullmq bullmq @nestjs/swagger @nestjs/throttler
  6. # Add production pieces: health, logging, error tracking

    npm i @nestjs/terminus nestjs-pino pino-http @sentry/nestjs
  7. # Add real-database tests

    npm i -D @testcontainers/postgresql @testcontainers/redis