richardchanjr90-cpu/ddd-by-example — explained in plain English
Analysis updated 2026-05-18
Learn Domain-Driven Design patterns applied to a real, complex business domain instead of a toy example.
Study a transactional outbox pattern that solves the dual-write problem between database and message bus.
See how business rules can be versioned as strategies instead of requiring database migrations.
Read a five-part article series that links directly to the code implementing each pattern.
| richardchanjr90-cpu/ddd-by-example | nuskey8/dotwasm | aidotnet/codexswitch | |
|---|---|---|---|
| Stars | 61 | 62 | 63 |
| Language | C# | C# | C# |
| Setup difficulty | moderate | moderate | moderate |
| Complexity | 4/5 | 4/5 | 2/5 |
| Audience | developer | developer | developer |
Figures from each repo's GitHub metadata at analysis time.
Built around Azure Functions and Service Bus, so full setup involves cloud infrastructure.
This repository is a teaching resource built from a real C# backend that was written for a loyalty-and-ordering platform. The startup never launched, but the codebase was cleaned up and turned into a reference for a software design approach called Domain-Driven Design. The goal is to show DDD patterns applied to a domain with actual business rules and complexity, rather than the simplified toy examples most tutorials use. The domain itself covers venues, loyalty programs with different point rules (stamps, percentage-based, tiered), product catalogues, orders that move through a defined lifecycle, and multi-tenancy. The code demonstrates several DDD concepts: an aggregate that locks itself once published, an order status modelled as a state machine where you can only move the status forward, business rules stored as versioned strategies so they can evolve without database migrations, and domain events that fire inside the aggregate and get saved in the same database transaction. A transactional outbox pattern handles the integration between the internal domain events and the external message bus. This solves what the associated articles call the dual-write problem: the risk that a service saves data to the database but then fails before it can publish the corresponding event to other services, leaving the two systems out of sync. The architecture is layered so the domain core does not know anything about the database, the cloud infrastructure (Azure Functions and Service Bus), or HTTP. The infrastructure layer holds all the database mapping in Entity Framework Core, and the application layer handles use-case orchestration using the MediatR library. The repository includes a five-part article series written as standalone documents in the docs folder, each covering one set of patterns and linking directly to the classes that implement them. The articles cover rich domain models, state machines, domain events and the outbox, versioned business rules, and row-level multi-tenancy. The project is MIT-licensed.
A real C# backend turned into a Domain-Driven Design teaching reference, showing DDD patterns on a complex loyalty and ordering domain.
Mainly C#. The stack also includes C#, .NET, Entity Framework Core.
MIT license: use freely for any purpose, including commercial use, as long as you keep the copyright notice.
Setup difficulty is rated moderate, with roughly 1h+ to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Verify against the repo before relying on details.