A progressive Node.js framework for building efficient, scalable, and maintainable server-side applications using Domain-Driven Design (DDD) and Onion Architecture.
This project uses NestJS with Domain-Driven Design (DDD) principles and Onion Architecture to structure server-side applications. It focuses on separating business logic, infrastructure, and external interfaces to ensure scalability and maintainability.
In this template, the project is divided into several layers such as application, domain, infrastructure, and interfaces. The domain layer includes all core business logic, including entities, aggregates, and services. The infrastructure layer manages the database connections and repository implementations, while the application layer coordinates the use cases and application-specific logic.
/src
├── application # Use Cases (Business Logic)
├── domain # Entities, Aggregates, Domain Services
├── infrastructure # Database, Repositories, External Services
├── interfaces # Controllers, REST APIs, GraphQL, WebSockets
├── shared # Common Utilities
├── config # Configuration Management
├── main.ts # Entry Point
├── tests # Unit & Integration Tests
├───src
│ ├───application
│ ├───config
│ ├───domain
│ │ ├───Interfaces
│ │ ├───models
│ │ │ ├───DTO
│ │ │ ├───Entities
│ │ │ ├───reqeust
│ │ │ └───response
│ │ └───services
│ ├───infrastructure
│ │ ├───database
│ │ └───Repositories
│ ├───interfaces
│ │ └───user
│ └───shared
└───test
Demo table schema
CREATE TABLE "user" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT, "username" TEXT NOT NULL, "password" TEXT NOT NULL, "email" TEXT NOT NULL );
$ npm install# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:covWhen you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the deployment documentation for more information.
If you are looking for a cloud-based platform to deploy your NestJS application, check out Mau, our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
$ npm install -g mau
$ mau deployWith Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
- Author - Da-Wei Lin
- Website - David Weblog
- Twitter - @nestframework
Nest is MIT licensed.