All Projects → draphyz → DDD

draphyz / DDD

Licence: other
Domain-Driven Design example

Programming Languages

C#
18002 projects
PLSQL
303 projects
TSQL
950 projects

Projects that are alternatives of or similar to DDD

ftgogo
FTGOGO - event-driven architecture demonstration application using edat
Stars: ✭ 82 (-29.31%)
Mutual labels:  cqrs, ddd, hexagonal-architecture, ports-and-adapters
Library
This is a project of a library, driven by real business requirements. We use techniques strongly connected with Domain Driven Design, Behavior-Driven Development, Event Storming, User Story Mapping.
Stars: ✭ 2,685 (+2214.66%)
Mutual labels:  ddd, domain-driven-design, hexagonal-architecture, ports-and-adapters
educational-platform
Modular Monolith Java application with DDD
Stars: ✭ 124 (+6.9%)
Mutual labels:  cqrs, ddd, domain-driven-design, hexagonal-architecture
typescript-ddd-course
🔷🔖 TypeScript DDD Course: Learn Domain-Driven Design in TS lesson by lesson
Stars: ✭ 28 (-75.86%)
Mutual labels:  cqrs, ddd, domain-driven-design, hexagonal-architecture
typescript-ddd-example
🔷🎯 TypeScript DDD Example: Complete project applying Hexagonal Architecture and Domain-Driven Design patterns
Stars: ✭ 607 (+423.28%)
Mutual labels:  cqrs, ddd, domain-driven-design, hexagonal-architecture
Php Ddd Example
🐘🎯 Hexagonal Architecture + DDD + CQRS in PHP using Symfony 5
Stars: ✭ 1,960 (+1589.66%)
Mutual labels:  cqrs, ddd, domain-driven-design, hexagonal-architecture
financial
POC de uma aplicação de domínio financeiro.
Stars: ✭ 62 (-46.55%)
Mutual labels:  cqrs, domain-driven-design, hexagonal-architecture
kingdom-python-server
Modular, cohesive, transparent and fast web server template
Stars: ✭ 20 (-82.76%)
Mutual labels:  ddd, hexagonal-architecture, ports-and-adapters
e-shop
Sample Spring Cloud microservices e-shop.
Stars: ✭ 48 (-58.62%)
Mutual labels:  cqrs, ddd, domain-driven-design
MonolithicArchitecture
This repository presents an approach on how to build an application using Monolithic architecture, ASP.NET Core, EntityFrameworkCore, Identity Server, CQRS, DDD
Stars: ✭ 18 (-84.48%)
Mutual labels:  cqrs, ddd, domain-driven-design
repository
[PHP 7] Implementation and definition of a base Repository in Domain land.
Stars: ✭ 26 (-77.59%)
Mutual labels:  ddd, domain-driven-design, hexagonal-architecture
eventuous
Minimalistic Event Sourcing library for .NET
Stars: ✭ 236 (+103.45%)
Mutual labels:  cqrs, ddd, domain-driven-design
Clean-Architecture-Template
Configurable Clean Architecture template containing the DDD + CQRS approach for .NET Core applications.
Stars: ✭ 14 (-87.93%)
Mutual labels:  cqrs, ddd, domain-driven-design
permacoop
Open source and eco design ERP solution reserved for worker-owned business.
Stars: ✭ 167 (+43.97%)
Mutual labels:  cqrs, ddd, hexagonal-architecture
EcommerceDDD
Experimental full-stack application using Domain-Driven Design, CQRS, and Event Sourcing.
Stars: ✭ 178 (+53.45%)
Mutual labels:  cqrs, ddd, domain-driven-design
ddd-for-python
A domain-driven design framework for Python.
Stars: ✭ 30 (-74.14%)
Mutual labels:  ddd, domain-driven-design, hexagonal-architecture
Plastic
This project provides encapsulation of things like Domain, Application Rules, Business Rules or Business Logic in Application.
Stars: ✭ 30 (-74.14%)
Mutual labels:  cqrs, ddd, domain-driven-design
go-hexagonal http api-course
Ejemplos del curso de API HTTP en Go aplicando Arquitectura Hexagonal
Stars: ✭ 78 (-32.76%)
Mutual labels:  ddd, domain-driven-design, hexagonal-architecture
archunit-junit5-kotlin
Generic Architecture Tests written in Kotlin using ArchUnit and Junit5
Stars: ✭ 22 (-81.03%)
Mutual labels:  onion-architecture, hexagonal-architecture, ports-and-adapters
Messagebus
A MessageBus (CommandBus, EventBus and QueryBus) implementation in PHP7
Stars: ✭ 178 (+53.45%)
Mutual labels:  cqrs, ddd, domain-driven-design

Domain-Driven Design example

This project is an example of a .NET implementation of a medical prescription model using the "Domain-Driven Design" (DDD) approach and the "Command and Query Responsibility Segregation" (CQRS) architectural pattern.

Points of interest

This project has been created to test an implementation in .NET of the core concepts of DDD (entities, value objects, domain events, ...) and CQRS (commands, queries, command and query handlers, ...) on the basis of a concrete model.

The final goal of the project is to develop, for personal use, the main components of a message-based architecture that combines the benefits of the Hexagonal Architecture, CQRS and DDD, namely :

  • reusability of the application code
  • isolation of the business and application logic from external dependencies
  • reduction of complexity by splitting the system into smaller parts with high cohesion and low coupling
  • maintainability, testability and readability of code
  • encapsulation of the business logic and rules in domain objects if necessary

The scalability of the system is important, but is not the main concern. I want to develop a solution that combines the above-mentioned benefits, but that is accessible to small development teams and that can be deployed in different types of environment. For this reason, only a light version of CQRS (no data projection, one data store) has been considered and no messaging framework (like Apache Kafka or NServiceBus) has been used.

The main components are developed from technologies commonly used by .NET developers :

  • a relational database
  • an ORM framework
  • an Ioc container

Model

The model considered is a simplified model reflecting the life cycle of a medical prescription and, in particular, of a pharmaceutical prescription. This life cycle can be summarized by the following diagram.

Alt Prescription Lifecycle

The current model only takes into account the use cases related to the prescriber : the creation and revocation of a prescription.

Command Model

On the write side, a rich domain model has been used to encapsulate the business logic and to control the creation of domain events. This model represents the business model. It incorporates both behavior and data, and is composed of entities and value objects.

The domain modeling has been focused on two important aspects :

  • Encapsulation (to ensure that the aggregate is in a consistent state at all times)
  • Separation of concerns (also known as persistence ignorance)

Therefore, the domain model has been implemented as an object model without public setters and by hiding some information (like database identifiers for the value objects). Entity inheritance and value object inheritance has been used and some value types like enumerations has been implemented as value objects.

Two options has been considered to map the domain objects to the database tables :

  • Mapping the domain model directly to the database by using a flexible and mature ORM like NHibernate 5 (branch nhibernate).

Alt NHibernate Mapping

  • Mapping the domain model to an intermediate model (state or persistence model) and then mapping the intermediate model to the database by using a less flexible and mature ORM like Entity Framework Core (branch entityframework).

Alt Entity Framework Mapping

By comparing the purity/complexity ratios of the two options, the first option is preferred to map the domain model to the database. In the branch "NHibernate", some minor changes have been made to the domain model, such as adding protected constructors or private setters.

The interactions between the main components on the write side can be represented as follows :

Alt Command Components

Query Model

As mentioned above, the command and query data stores are not differentiated but the architecture on the query side is simplified (as shown on the following diagram). The query side is composed of simple Data Transfer Objects mapped to the database by using the Micro ORM Dapper.

Alt Query Components

Projects

The libraries are distributed by component (bounded context) :

  • The "Core" libraries include the core components (Entity, ValueObject, CommandHandler, ...) necessary to implement the DDD approach according to the CQRS architectural pattern.
  • The "Common" libraries include common components (EmailAddress, FullName, ...) that can be reused in multiple bounded contexts (shared kernel).
  • The "HealthcareDelivery" libraries include components related to the context of healthcare delivery.

The application layer can be tested by using the "DDD.HealthcareDelivery.IntegrationTests" project.

Cross-cutting concerns

The decorator pattern is especially useful in CQRS to handle cross-cutting concerns such as logging or error handling. Command or query handlers (small interfaces) can be easily decorated. You will find some examples of decorators in the "DDD.Core.Polly" and "DDD.Core" projects.

Exception chaining (or exception wrapping) has been used. Each abstraction has its own set of exceptions :

  • ISerializer throws a SerializationException
  • IObjectMapper or IObjectTranslator throws a MappingException
  • IRepository throws a RepositoryException
  • IQueryHandler throws a QueryException
  • ICommandHandler throws a CommandException

The Domain and Application layers have their own base exception class (respectively DomainException and ApplicationException). These classes defines a property IsTransient indicating whether the exception is transient.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].