zhuravlevma / ddd-typeorm-unit-of-work

Clean architecture for nest.js with unit of work, typescript, clean architecture, domain model, aggregates, typeorm ⚡

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clean Architecture with DDD with Unit of Work Pattern

Domain model with a clean architecture with ports and adapters. It takes into account some tactical patterns from DDD.

Unit of work

return this.uow.runInTransaction(async (tx) => {
  const updatedWh = await this.saveWh.saveWarehouse(warehouse, tx);
  await this.saveReport.save(report, tx);
  return updatedWh;
});

Architecture

architecture schema

Module boundaries

If you have a large monolith that contains many bounded contexts, then the service can be divided into modules by context.

If you have a micro service architecture and you prefer to allocate contexts to different services (which is preferable), then the service can be divided into modules by aggregates.

In this example, there are more than one bounded contexts, you have a monolith in front of you. And this monolith is internally divided into modules according to bounded contexts.

Event Storming schema

image

Installation

npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# arch tests
$ npm run test:arch

# test coverage
$ npm run test:cov

About

Clean architecture for nest.js with unit of work, typescript, clean architecture, domain model, aggregates, typeorm ⚡


Languages

Language:TypeScript 97.4%Language:JavaScript 2.6%