Welcome to the NestJS Boilerplate. This project provides a solid foundation for building scalable and maintainable backend applications with NestJS, following the Clean Architecture. It also integrates concepts from Domain-Driven Design (DDD) to help organize your code around the core business logic.
Important
To run the backend locally, you need a PostgreSQL database with migrations applied.
- Start PostgreSQL using docker-compose.yaml
docker compose -f docker/docker-compose.yaml up database -d
- Run the SQL migrations
pnpm drizzle-kit migrate
# Run the backend in watch mode
pnpm dev
- Guaranteed Event Delivery: ensure events are reliably stored and dispatched achieving at-least-once delivery.
- Concurrency: Leverages
REPEATABLE READ
isolation andFOR UPDATE SKIP LOCKED
to ensure efficient and exclusive message processing, even under high load. NOT_IMPLEMENTED
Transaction Safety: Events are saved in the outbox as part of the same database transaction as aggregate updates, ensuring consistency.
-
Optimized for Deployments: Multi-stage build keeps the production image lean, reducing network footprint and speeding up deployments.
-
Run Locally: Launch the entire stack (API + Database) with docker-compose.yaml
-
Security: Runs as a non-root user to reduce security risks
📁 src/
├── 📁 core/
│ ├── 📁 errors/ # Base error classes such as ResourceNotFound, etc.
│ ├── 📁 primitives/ # Building blocks like Entity, etc.
│ └── 📁 utils/ # Utility functions
│
├── 📁 identity-and-access/
│ ├── 📁 domain/ # Business logic (e.g. Account, ForgotPasswordRequest ...)
│ ├── 📁 infrastructure/ # Driver adapters (e.g., Jwt, Mailer, etc.)
│ ├── 📁 use-cases/ # Implements business use cases, connecting ports and domains
│ └── 📄 identity-and-access.module.ts
│
├── 📁 shared-kernel/
│ ├── 📁 domain/
│ ├── 📁 infrastructure/ # Driver adapters used across multiple bounded-contexts (e.g. GoogleCloudTasks, ...)
│ ├── 📁 use-cases/
│ └── 📄 shared-kernel.module.ts
│
├── 📄 application.module.ts
└── 📄 main.ts