Directory Structure NestJS
# Source(src) Directory Structure
src
├── auth
├── common
├── config
├── models
├── ... modules
├── jobs
├── providers
├── app.controller.ts
├── app.module.ts
├── app.service.ts
└── main.ts
# Authentication(auth) Directory Structure
https://docs.nestjs.com/security/authenticationsrc/auth
├── strategies
├── guards
├── auth.dto.ts
├── auth.controller.ts
├── auth.service.ts
└── auth.module.ts
# Common(common) Directory Structure
These are the common files basically needed for the development such as enums,helpers,exceptions,guards,interfaces,interceptors,middlewares,pipes and serializers
src/common
├── enum
│ └── permission.enum.ts
├── decorators
│ ├── metadata
│ │ └── user-types.decorator.ts
│ ├── requests
│ │ └── logged-in-user.decorator.ts
│ └── validations
│ ├── UserExists.ts
│ └── UniqueUserEmail.ts
├── exceptions
│ └── http-exception.filter.ts
├── guards
│ └── role.guard.ts
├── helpers
│ ├── exceptions
│ │ └── validation.helper.ts
│ ├── data-type.helper.ts
├── interceptors
│ └── http-cache.interceptor.ts
├── interfaces
│ ├── inputs.interface.ts
│ └── search.interface.ts
├── middleware
│ └── api-request-logger.middleware.ts
│ └── correlation-id.middleware.ts
├── pipes
│ ├── models
│ │ └── user-entity.pipe.ts
│ ├── search.pipe.ts
│ └── validation.pipe.ts
└── serializers
├── responses
│ ├── error.serializer.ts
│ └── success.serializer.ts
└──validation
└── validation-error.serializer.ts
# Config(config) Directory Structure
https://docs.nestjs.com/techniques/configurationsrc/config
├── app
│ ├── app-config.service.ts
│ ├── app-config.controller.ts
│ └── config.ts
└── [...]
# Models(model) Directory Structure
This can be configure relatively depending upon the database (MongoDb, Postgres or Something different like DynamoDb, S3, etc)
#Job(job) Directory Structure
https://docs.nestjs.com/techniques/queuessrc/jobs
├── consumers
└── producers
#Providers(provider) Directory Structure
Providers are basically core modules that initiate a connection between the app, such as AWS and its services.