Giter VIP home page Giter VIP logo

nestjs-conduit-onion-architecture's Introduction

Realword Conduit API: Nest + PostgreSQL + Onion Architecture

The onion architecture, introduced by Jeffrey Palermo in 2008. The main idea of this architecture is that the Domain Layer (Entities and Validation Rules that are common to the business case) is the Core of entire Application. In this project, I implement a variant of Onion Architecture with NestJs.

Development

  1. Install PostgreSQL
  2. Create new database in your local with whatever name you want.
  3. Go to .env file and change the database connection config based on the database create in step 2.
  4. Install all dependencies via npm install
  5. Start project in development watch mode via npm run start:dev

Project Structure

Onion Architecture

Domain:

  • This layer contains entities, abstract of repository and constants.

Infrastructure:

  • This layer contains all things which are infrastructure of this project such as: connecting database (Typeorm config, Migration), Environment Config, Authentication Service...
  • We implement repository for each entity in this layer. Typeorm already has its own repository but we define wrapper repository classes so it's easy to change other library if we want.

Application:

  • Application layer will do the following tasks:

    1. Validate User Input.

    2. Handle business logic.

    3. Return data transfer objects (DTO) as a result of business logic.

API:

  • Contains controllers of this apllication.
  • It receives the requests made to the server and send it to services in Application Layer to execute some business logic.

nestjs-conduit-onion-architecture's People

Contributors

andyt2503 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.