nestjs-ddd-quickstarter

NestJS Quickstarter

Build pages-build-deployment Node Current

GitHub license Semantic Release Conventional Commits

GitHub Pull Requests GitHub Issues GitHub Repo stars GitHub contributors

The purpose of this repository is to create a ready-to-use project following Domain-Driven Design, Clean Architecture and Functional Programming best practices combined with some DevOps techniques such as Continuous Integration, Continuous Delivery and Quality Assurance.

The project is completely open source using the MIT license, feel free to contribute by opening a issue, a pull request or a discussion topic.

In the following chapters you will find a description of the main choices, technologies and techniques adopted.

Stack

NodeJS TypeScript NestJS PostgreSQL Mikro-ORM Docker

nodejs typescript nestjs postgresql docker

Instructions

  1. Fork this repository and use it as template repository
  2. Install all dependencies
      npm install
    
  3. Start the PostgreSQL development database in a local container
      docker-compose up -d
    
  4. Provide a .env file with all required environment variables (check out .env.dist example file)
  5. Create and generate the database schema from your entities metadata:
      npm run schema:update
    
  6. Start to create your modules and entities following all the principles explained in the below chapters!

Table of Contents

Architecture

NestJS provides a modular architecture that allows the creation of loosely coupled and easily testable components.
Although this framework natively supports the development of microservice or event-driven architectures, they will not be considered because the purpose of this project is just to create a simple, extensible and ready-to-use application.
For this reason, we are going to implement a Modular Monolith: an architectural pattern that structures the application into independent modules or components with well-defined boundaries.

Modular Monolith Architecture
Example of a Modular Monolith Architecture.

In addition to simplicity and extensibility, a modular monolith allows us to start the development of the application as a single repository and deployment unit, with distinct and clear boundaries between business contexts. By this way, we can gradually refactor our architecture to a microservice architecture rather than implementing it from the beginning.
In NestJS, applications typically consists of multiple modules, each serving a specific purpose or feature set. A module is a class annotated with the @Module() decorator, and it encapsulates a specific domain or feature of the application. A module class define providers and inject them into other components leveraging Dependency Injection.

Domain-Driven Design

Clean Architecture

Clean Architecture
Different layers of the Clean Architecture.

Functional Programming

Testing

Continuous Integration

Continuous Delivery

Automatic Dependency Update

Automatic API Documentation Generation

Semantic Versioning

Backend Best Practices

Contributors

Contributors