Code Monkey home page Code Monkey logo

nestjs-clean-architecture's Introduction

Clean Architecture on NestJS

Clean Architecture Image

Description

This project was created to study and implement a NestJS application with clean architecture and SOLID.

The application itself it's pretty simple, two controllers and basic logics.

Layers

The outermost components of the application are inside the infrastructure folder (src/infraestructure), such as environment configuration, cloud providers and data providers.

The next layer is responsible for handling input, converting objects into DTOs and the presenters, and is inside the application folder (src/application), such as controllers and middlewares.

The last layer, called Core, is responsible for maintaining the business rules, such as use cases, entities and abstractions, inside the core folder (src/core).

Dependency Inversion (The D in S.O.L.I.D)

It's important to say that dependency inversion is a very important concept for implementing this architecture. Once you know the three layers, some architectural rules involve each layer, for example:

  • Application layer and Core layer:

    • Never depends directly on an implementation (present in the infrastructure layer), but depends on abstractions defined in the core layer
  • Infraestructure layer:

    • Implements the abstraction and configures each implementation that will be served to the entire application (see src/infraestructure/cloud/cloud.module.ts).

Installation

$ pnpm install

Running the app

# development
$ pnpm run start

# watch mode
$ pnpm run start:dev

# production mode
$ pnpm run start:prod

Test

# unit tests
$ pnpm run test

# e2e tests
$ pnpm run test:e2e

# test coverage
$ pnpm run test:cov

Stay in touch

nestjs-clean-architecture's People

Contributors

jailtoncruz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.