Skip to content

Repository files navigation

Clean Architecture with DDD(without Domain Events)

This implementation is without domain events, instead of events there are nested aggregates.

Example

export class WarehouseEntity implements Attributes {
  id: string;
  name: string;
  orders: OrderEntity[];
  report?: ReportEntity; // nested aggregate

  constructor(attributes: Attributes) {
    this.id = attributes.id;
    this.name = attributes.name;
    this.orders = attributes.orders;
  }

  addOrder(order: OrderEntity) {
    this.orders.push(order);
  }

  changeOrderStatusToValid(orderId: string, report: ReportEntity) {
    const order = this.orders.find((el) => el.id === orderId);
    order.changeStatus(true);
    this.report = report;
  }
}

If you are interested in the option with domain events, then follow the link

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

Architecture

architecture schema

Installation

npm install

Running the app

# development
$ cp .env.example .env
$ npm run start:dev

Test

# unit tests
$ npm run test

# arch tests
$ npm run test:arch

# test coverage
$ npm run test:cov

About

Clean architecture for nest.js, typescript, clean architecture without domain events. Instead of events there are nested aggregates ⚡

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages