NestJS + Layered (Clean) Architecture + TypeORM + Serverless

This is a project template for building NestJS applications with layered architecture (Clean), utilizing TypeORM for database access, and designed for serverless deployment. This template is a starting point for your serverless NestJS projects.

Features

Getting Started

  1. Clone this repository to your local machine:
   git clone https://github.com/benedya/nestjs-layered-architecture.git
  1. Configure your environment variables by creating a .env file and populating it with your database connection details and other configuration:
    cd nestjs-layered-architecture
    cp .env.example .env
    
  2. Run services:
    make up
    
  3. Run migrations:
    
    make m
    
  4. Your NestJS application is now running locally. You can access it at http://localhost:3001/api/users. Controllers you can find in the src/ApiGateway/UI directory.

Project Structure

The project is structured as follows:

├─ src/
│   ├── ApiGateway
│   ├── Common
│   ├── Constant
│   ├── Database
│   ├── Helper
│   ├── Lambda
│   ├── Module
│   └── app.module.ts

Anticorruption

To prevent uncontrolled dependencies between modules there we can use Anticorruption layer.

The main ideas are the next:

Example of the Anticorruption layer you can find in the src/Module/Notification/Infrastructure/Anticorruption/User directory. There we have interaction between the Notification module and the User module.

Contributing

Contributions are warmly encouraged to enhance and extend this template. If you have any ideas, bug fixes, or enhancements, please feel free to open an issue or submit a pull request.


Hopefully this example helps you build robust and scalable applications using the power of Clean Architecture. Happy coding! If you have any questions or need assistance, please don't hesitate to reach out.