whatisgithub

What is ddd-by-example?

richardchanjr90-cpu/ddd-by-example — explained in plain English

Analysis updated 2026-05-18

61C#Audience · developerComplexity · 4/5LicenseSetup · moderate

In one sentence

A real C# backend turned into a Domain-Driven Design teaching reference, showing DDD patterns on a complex loyalty and ordering domain.

Mindmap

mindmap
  root((repo))
    What it does
      DDD teaching reference
      Real world domain
      Loyalty and ordering
    Tech stack
      C sharp dotnet
      Entity Framework Core
      Azure Functions
    Use cases
      Learn DDD patterns
      Study outbox pattern
      Read article series
    Audience
      Developers
      DDD learners
    Patterns shown
      State machine orders
      Versioned business rules
      Domain events

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Learn Domain-Driven Design patterns applied to a real, complex business domain instead of a toy example.

USE CASE 2

Study a transactional outbox pattern that solves the dual-write problem between database and message bus.

USE CASE 3

See how business rules can be versioned as strategies instead of requiring database migrations.

USE CASE 4

Read a five-part article series that links directly to the code implementing each pattern.

What is it built with?

C#.NETEntity Framework CoreMediatRAzure Functions

How does it compare?

richardchanjr90-cpu/ddd-by-examplenuskey8/dotwasmaidotnet/codexswitch
Stars616263
LanguageC#C#C#
Setup difficultymoderatemoderatemoderate
Complexity4/54/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 1h+

Built around Azure Functions and Service Bus, so full setup involves cloud infrastructure.

MIT license: use freely for any purpose, including commercial use, as long as you keep the copyright notice.

So what is it?

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.

Copy-paste prompts

Prompt 1
Explain how the transactional outbox pattern is implemented in this codebase.
Prompt 2
Walk me through the aggregate that locks itself once published in this domain model.
Prompt 3
Show me how versioned business rules avoid database migrations in this project.
Prompt 4
Help me apply the order-status state machine pattern from this repo to my own project.

Frequently asked questions

What is ddd-by-example?

A real C# backend turned into a Domain-Driven Design teaching reference, showing DDD patterns on a complex loyalty and ordering domain.

What language is ddd-by-example written in?

Mainly C#. The stack also includes C#, .NET, Entity Framework Core.

What license does ddd-by-example use?

MIT license: use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is ddd-by-example to set up?

Setup difficulty is rated moderate, with roughly 1h+ to a first successful run.

Who is ddd-by-example for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.