Leanpub Header

Skip to main content

Topics

Domain-Driven Design

From the ubiquitous language, the core domain and bounded contexts to aggregates, CQRS and event sourcing, domain-driven design as told through the free samples of Leanpub books.

Created from the free samples of 8 Leanpub books and the descriptions and tables of contents of 16 more, with every source cited.

Domain-driven design, or DDD, is an approach to software for complex problem domains that puts the language and the model of the business at the centre of the design.[1] It is a collection of patterns, principles and practices more than a method, and its books insist that it is not about technology: its subject is the development of knowledge about a business and the use of that knowledge in code.[1] [3]

The approach has two sides. Strategic design decides which parts of a business problem deserve the most effort and where the boundaries between models lie; tactical design supplies building blocks, such as entities, value objects and aggregates, for writing a model inside one boundary.[3] Two architectural patterns have grown up beside it and are usually taught with it: CQRS, which separates the code that changes state from the code that reads it, and event sourcing, which stores a system's state as the series of events that produced it.[5] [6]

This article describes the problem space, the ubiquitous language, bounded contexts, tactical design and architecture, CQRS and event sourcing, and the question of when the approach is worth its cost. Its sources are the free samples of 8 Leanpub books and the public descriptions and tables of contents of 16 more, published between 2014 and 2026.

Where to start

The shortest way in is The Anatomy Of Domain-Driven Design (2017), a visual guide of 24 pages that goes from the problem domain to a software model; the same authors' The Anatomy Of Domain-Driven Design - Booklet (2017) is a booklet of the same length for people new to the practice.[1] [9] Principles, Patterns and Practices of Domain-Driven Design (2014) is a short introduction to the philosophy and its strategic side, written as a learning aid for developers starting out; it is a draft of the first part of a longer printed book.[2] Understand Your Domain First (2025), a free guide, follows one case through a discovery workshop to subdomains and bounded contexts, and Hands-on Domain-driven Design - by example (2020) explains the approach through one large case study with exercises.[10] [11]

Developers who want to see the patterns in code can choose by language. Domain-Driven Design in PHP - 2n Edition (2026) has a chapter for each tactical building block and addresses PHP developers, architects and technical leads; DDD with Spring Boot (2025) covers strategic and tactical patterns with Spring Boot; and Serverless Domain Driven Design for the Busy Developer (2025) is a hundred pages in TypeScript meant to be read in a weekend.[3] [13] [14]

For the neighbouring patterns, CQRS A Complete Visual Guide (2026) introduces CQRS with diagrams and one running example, and Event Sourcing (2025) was written so that a team can hand it to a new member joining a project that uses event sourcing.[5] [22] Readers who already know the vocabulary and want several points of view have Domain-Driven Design: The First 15 Years (2024), a collection of essays by many authors.[12]

History

The approach takes its name from a book of 2003, and the later literature defines itself against that book. Principles, Patterns and Practices of Domain-Driven Design says it is no replacement for it but a distillation of its concepts into plain prose, and Domain-Driven Design in PHP - 2n Edition names it and a second, implementation-minded book as the two a reader should go on to.[2] [3] Domain-Driven Design: The First 15 Years was assembled fifteen years after the original, when, in its editors' words, the approach was being adopted more widely than ever.[12]

The ideas spread between language communities slowly. The authors of Domain-Driven Design in PHP - 2n Edition recall attending a workshop on implementing the approach in 2014 as the only two PHP developers in a room of Java and .NET developers, at a time when rich domain models and applications independent of their framework were uncommon in PHP.[3]

CQRS has a separate lineage. CQRS in Practice (2026) traces it from an older principle that a method should either change state or return a value, to its formulation as an architectural pattern around 2009 and 2010 and its popularisation in an article of 2011.[4] CQRS (2014) dates from those first years: it collects its author's notes on an example project built after a course with the pattern's originator in 2009.[19]

The problem space

DDD begins with the problem and not the solution. The Anatomy Of Domain-Driven Design distinguishes two sources of complexity in software, the complexity inherent in the domain and the accidental complexity of the technical solution, and describes what happens when they mix. The first version of a system is quick to produce; over time, without care, it becomes a ball of mud that works although nobody knows how, so that every change is risky.[1] It adds that where technical complexity exists, the best developers tend to spend their time there instead of on the problem.[1]

The first remedy is to distil the problem. The parts of a complex problem are not equal, and the approach sorts them into the core domain, which is what makes the software worth writing, supporting subdomains and generic ones.[2] [1] Most effort and the strongest developers belong in the core. A generic subdomain can be met by an off-the-shelf package and needs only to be good enough, and the core is not always the most technically interesting part.[1] Domain-Driven Design in PHP - 2n Edition gives an online travel agency as its example, a domain divided into subdomains such as pricing, inventory and user management.[3]

The second is learning. Principles, Patterns and Practices of Domain-Driven Design describes DDD as a process of learning a domain, in which a team and a domain expert experiment with models, and says that a development team must value domain knowledge as much as technical skill.[2] The Anatomy Of Domain-Driven Design calls the activity knowledge crunching and gives practical advice for it: start from the use cases, sketch diagrams, ask what success would look like, and begin with the parts of the problem that keep the business awake at night instead of walking through a list of requirements.[1]

The ubiquitous language

The product of that learning is a shared vocabulary. The ubiquitous language is built by developers and domain experts together, is used in conversation, documents and diagrams, and appears in the code itself as the names of classes, properties and methods.[1] Business terms that do not help solve a use case are dropped from it even if they exist in reality, and so are technical terms the domain experts do not use.[1] Domain-Driven Design in PHP - 2n Edition makes it the first of three pillars, with strategic and tactical design, and puts the case simply: code is a medium for solving business problems, so there is no reason for it to speak a different language from the business.[3]

Event Storming

The technique most often recommended for finding the language is Event Storming, a workshop format in which the people with the questions and the people with the answers build a model of a business flow together, using a deliberately simple notation. Domain-Driven Design in PHP - 2n Edition says it has become standard practice, in a high-level variant for exploring a whole business and a design-level variant for one bounded context, and recommends it as the starting point of any DDD initiative.[3] Understand Your Domain First takes a gym through both levels before it draws any boundaries, with the stated aim of stopping legacy systems before they start.[10] Timeless Software Development Methodology in AI Era and Beyond (2026) places the workshop in a sequence for work with AI coding assistants, from use cases and written specifications through Event Storming to strategic and tactical design.[17]

Models and bounded contexts

A model, in this vocabulary, is an abstraction of the problem domain built to solve particular business use cases. It is not a reflection of real life, and The Anatomy Of Domain-Driven Design warns against trying to model reality or stopping at the first useful idea, since many models have to be rejected on the way to a good one.[1] Parts of a system that are complex or change often should rest on a model; the rest need not.[2]

A single model cannot serve a whole organisation. The same word means different things to different departments, and a model shared by several teams loses its precision. The answer is the bounded context, a boundary inside which one model and one language apply. In the booklet's example the concept of a product exists separately in a warehouse context, a procurement context and a shipping context.[1] A context map records how the contexts relate, and an anti-corruption layer protects a model from a neighbouring system that is badly structured or outside the team's control.[1] Boundaries of this kind also let one team explore and change its model without affecting the others.[2]

The idea travels beyond back-end code. Enterprise Angular: Micro Frontends and Moduliths with Angular (2024) uses strategic design to divide a large front-end application into domains before it turns to the tooling that enforces the division.[18] Domain-Driven Design And Microservices Explained with Examples (2023) relates the concepts to microservices through numbered use cases.[8]

Tactical design and architecture

Inside a bounded context the model is written with a known set of building blocks. Domain-Driven Design in PHP - 2n Edition lists them, value objects, entities, services, domain events, aggregates, factories, repositories and application services, and gives each a chapter; its authors say they came to DDD through these patterns, which is why the book is mainly about them.[3] An aggregate, in the definition of CQRS A Complete Visual Guide, is a consistency boundary whose state is changed as one unit, and an invariant is a condition that must hold whenever a transaction commits.[5] (Start) Making Sense Of DDD-Based Software Engineering (2026) treats the design of aggregates as the part most in need of a systematic method, and Domain-Driven Design (2025) works an e-commerce example from requirements to architecture in under thirty pages.[15] [16]

The sources warn against mistaking the building blocks for the whole. DDD is not a pattern language, says The Anatomy Of Domain-Driven Design, and it does not dictate an architectural style; it asks only that the model be kept apart from technical concerns.[1] The style most often paired with it is hexagonal architecture, also called ports and adapters. The domain layer sits at the centre and does not care where its input came from or where its output is stored or sent; adapters at the edge connect it to databases, message brokers and user interfaces, and a new one can be added without touching the centre.[8] Domain-Driven Design in PHP - 2n Edition grew from an article on that architecture and presents it as the way to keep an application independent of its framework.[3]

When to use it

The books are frank that the approach has a price. Applying it takes time, the commitment of domain experts and a continuing conversation with them.[3] An application that mostly creates, reads, updates and deletes rows does not need it, and Domain-Driven Design in PHP - 2n Edition offers a rule of thumb: use DDD to simplify a domain and never to add complexity.[3] The signs that a system is outgrowing simple code are accumulating conditional logic, rules that span several concepts and workflows that cannot be explained in a sentence.[3] Principles, Patterns and Practices of Domain-Driven Design gives a chapter to when not to use DDD, on the ground that simple systems call for straightforward solutions and that applying it to simple problems produces overdesigned systems.[2] Hands-on Domain-driven Design - by example opens with a similar disclaimer against following the approach blindly.[11]

CQRS

Command Query Responsibility Segregation starts from an observation about ordinary applications: the shape of data that suits writing rarely suits reading. A write must validate, enforce rules and commit a transaction; a read must be fast and often combines many tables; and reads commonly outnumber writes by ten or a hundred to one.[4] A single model for both serves neither well. CQRS uses one model to update information and another to read it, and lets the two diverge.[4]

CQRS A Complete Visual Guide supplies the vocabulary. A command expresses an intent to change state, a query asks for information without changing anything, a read model is data shaped for a particular screen or report, and a projection is the logic that turns committed changes into a read model.[5] The guide is emphatic about what the pattern does not require: two databases, a message broker, microservices or event sourcing. It separates four things that are often confused, separation of responsibility, of model, of storage and of deployment, and holds that only the first is essential.[5] Its rule is to use the least distributed form that meets the requirement, and it describes a range of adoption from one model, through separate command and query code in one database, to read models updated asynchronously, adding that this is not a ladder every system should climb.[5]

The warnings are as prominent as the pattern. CQRS in Practice repeats the early advice that CQRS belongs in particular bounded contexts and never across a whole system, that it pays where command and query logic differ greatly or where reads and writes must scale separately, and that for most systems it adds risky complexity.[4]

Several books teach it through one application. CQRS by Example (2024) moves a clone of a microblogging service from hexagonal architecture to separate write and read models, in PHP, and Building Conduit (2019) builds a blogging platform in Elixir with an event-sourced domain model and a read model optimised for queries.[7] [20] Event-Driven Architecture & DDD in TypeScript. Event Sourcing, CQRS, and Microservices at Scale (2026) combines DDD, CQRS and event sourcing for services written in TypeScript.[21]

Event sourcing

Event sourcing records the state of a system as a series of events instead of keeping only the current state. Because the store holds everything that ever happened, it provides an audit trail at no extra cost, and the events can be analysed later to see how the system behaved at any moment in the past.[6] Practical Event Sourcing with Scala (2021), which builds a small web application on the pattern, also notes the difficulty: the approach is uncommon, its best practices are not widely known, and developers who adopt it are often on their own. It observes that the pattern usually travels with DDD and CQRS in large organisations, while web companies tend to begin with a conventional design and move to events later.[6]

Event Sourcing in Scala (2026) states the mechanism in a sentence, an append-only log of immutable facts from which the current state is derived by replay, with read models built by projections.[23] The practical questions follow from that. The contents of Event Sourcing include what to do when something has to be deleted, snapshots, projections and eventual consistency, the condition in which a derived view lags briefly behind a write.[22] [5] Event Sourcing in Python (2026) arranges the subject as a pattern language in three parts, the domain model, the application and the distributed system.[24]

Event sourcing remains optional even where CQRS is used. In the range of adoption drawn by CQRS A Complete Visual Guide it is the last step, bought at the price of permanent responsibility for old events and for replaying them.[5]

Questions about Domain-Driven Design

What is domain-driven design?

It is an approach to software for complex problem domains that centres the design on the language and model of the business.[1] It is not about technology; it concerns developing knowledge of the business and expressing it in code.[3]

What is a bounded context?

A bounded context is a boundary within which one model and one language apply.[1] Large models are divided this way where terms are ambiguous or several teams are involved, so that the same concept, a product for example, can be modelled separately for a warehouse, for procurement and for shipping.[1]

What is the ubiquitous language?

It is the vocabulary that developers and domain experts build together and use consistently in conversation, in documents and in the code.[1] The same terms appear as the names of classes, properties and methods.[1]

When should I not use domain-driven design?

An application that mostly creates, reads, updates and deletes rows does not need it.[3] Applied to simple problems it produces overdesigned systems, and the rule of thumb is to use it to simplify a domain and never to add complexity.[2] [3]

Does CQRS require event sourcing or two databases?

No. CQRS separates the path that changes state from the path that reads it, and a useful version can live inside one application and one database.[5] Separate storage, separate deployment and event-sourced writes are optional steps to take only when a measured need justifies them.[5]

What is event sourcing?

Event sourcing stores the state of a system as a series of events instead of only its current state.[6] The event store gives an audit trail without extra work, but the approach is considered hard to implement because its practices are not widely known.[6]

Sources

Every source is a Leanpub book or course. The note after each says which part of it was read; where no sample was available, only the public description and table of contents were used.

  1. 1.
    The Anatomy Of Domain-Driven Design, Scott Millett, Samuel Knight Free sample: the text of the visual guide, from complexity and the core domain to the ubiquitous language and bounded contexts. 2017. Free sample: PDF
  2. 2.
    Principles, Patterns and Practices of Domain-Driven Design, Scott Millett: Practical advice for teams implementing the development philosophy of Domain-Driven Design. With code examples in C# .NET. Free sample: who the book is for, the overview of DDD as problem space and solution space, and the outline of the chapters. A draft of the first part of a printed book. 2014. Free sample: PDF · EPUB
  3. 3.
    Domain-Driven Design in PHP - 2n Edition, Carlos Buenosvinos, Christian Soronellas, Keyvan Akbary: Discover DDD, Architectural Styles, Tactical Design Implementations, and Bounded Context Integration with PHP 8.5 examples Free sample: the foreword, the preface and the opening of chapter 1, on why DDD matters, its three pillars, Event Storming and when to consider it. 2026. Free sample: PDF · EPUB
  4. 4.
    CQRS in Practice, Steve Publications: A Practical Guide to Building Scalable, Maintainable Systems with CQRS Free sample: the introduction and the start of chapter 1, on the tension between reading and writing. 2026. Free sample: PDF · EPUB
  5. 5.
    CQRS A Complete Visual Guide, Reiner Braun: A Practical Visual Learning Guide for Systems Engineers Free sample: the overview and chapter 1, with the vocabulary, the four kinds of separation and the range of adoption. 2026. Free sample: PDF · EPUB
  6. 6.
    Practical Event Sourcing with Scala, Denis Kalinin: A comprehensive example based on Scala, Play and Akka Streams Free sample: the preface, on what event sourcing is, and the setup of the project. 2021. Free sample: PDF · EPUB
  7. 7.
    CQRS by Example, Carlos Buenosvinos, Christian Soronellas, Keyvan Akbary: Command-Query Responsibility Segregation is an architectural style for developing applications that split the Domain Model in Read and Write operations in order to maximize semantics, performance, and scalability. What are all the benefits of CQRS? What are the drawbacks? In which cases does it worth applying it? How does it relate to Hexagonal Architecture? How do we properly implement the Write Model and Read Models? How do we keep in sync both sides? What are the following steps to move towards Event Sourcing? This book will answer all these questions and many more, guided through lots of practical examples. Brought to you by the same authors behind "Domain-Driven Design in PHP". Free sample: the preface and the summary of the chapters. 2024. Free sample: PDF · EPUB
  8. 8.
    Domain-Driven Design And Microservices Explained with Examples, Sandeep Jagtap: Learn to clarify and focus the boundaries of your system’s architecture Free sample: one chapter, on the domain layer in layered and hexagonal architecture; the others appear as headings. 2023. Free sample: PDF · EPUB
  9. 9.
    The Anatomy Of Domain-Driven Design - Booklet, Scott Millett, Samuel Knight No sample: from the description. 2017.
  10. 10.
    Understand Your Domain First, Maciej "MJ" Jedrzejewski: An Introduction to Event Storming and Domain-Driven Design No sample: from the description and table of contents. 2025.
  11. 11.
    Hands-on Domain-driven Design - by example, Michael Plöd: Domain-driven Design practically explained with a massive case study No sample: from the description and table of contents. The book is unfinished. 2020.
  12. 12.
    Domain-Driven Design: The First 15 Years, The DDD Community: Essays from the DDD Community No sample: from the description and table of contents. 2024.
  13. 13.
    DDD with Spring Boot, Enrique Medina Montenegro: Implementing Robust, Scalable Applications Using Strategic and Tactical DDD Patterns No sample: from the description and table of contents. 2025.
  14. 14.
    Serverless Domain Driven Design for the Busy Developer, Oskar Flores No sample: from the description and table of contents. 2025.
  15. 15.
    (Start) Making Sense Of DDD-Based Software Engineering, Stephan M. Bauer: Apply DDD professionally to build Clean Backend Applications with Clean Aggregates, Clean Domain-Driven Code and Ports & Adapters No sample: from the description and table of contents. 2026.
  16. 16.
    Domain-Driven Design, Eduard Ghergu, Ph.D.: A pragmatic approach No sample: from the description and table of contents. 2025.
  17. 17.
    Timeless Software Development Methodology in AI Era and Beyond, Irwansyah: with DDD and C4 No sample: from the description and table of contents. 2026.
  18. 18.
    Enterprise Angular: Micro Frontends and Moduliths with Angular, Manfred Steyer: Module Federation - Nx - DDD No sample: from the description and table of contents. 2024.
  19. 19.
    CQRS, Mark Nijhof: The Example No sample: from the description and table of contents. 2014.
  20. 20.
    Building Conduit, Ben Smith: Applying CQRS/ES to an Elixir and Phoenix web app No sample: from the description and table of contents. 2019.
  21. 22.
    Event Sourcing, Greg Young No sample: from the description and table of contents. 2025.
  22. 23.
    Event Sourcing in Scala, Piotr Pruchniewicz: Scala 3, ZIO, PostgreSQL and the log beyond the database No sample: from the description and table of contents. 2026.
  23. 24.
    Event Sourcing in Python, John Bywater: Event-oriented analysis and design with applications No sample: from the description and table of contents. 2026.

Further reading

Other books in the library on the same ground, not cited above.

This is an article created from the free samples of 8 Leanpub books and the descriptions and tables of contents of 16 more. We're building these articles to provide you, the Leanpub reader, with a good jumping-off point to discover more Leanpub books that are interesting and relevant to you. We never use material which is paid-only when building these articles: we only use material which is already free on Leanpub. However, Leanpub authors can opt out from inclusion in articles from their book settings page.

Updated November 2026.

All topics