liveBook · Manning

Domain-driven design

As explained in Go in Action, Second Edition

Domain-Driven Design is a software design approach that structures software around real-world business concepts and domain behavior.

Domain-driven design organizes software around real-world business concepts instead of technical implementation details. A shared domain module defines stable business logic that API and worker modules can depend on. section 11.1.2

Build the domain boundary around:

  • Entities such as Article and Feed, which name the system’s core concepts. section 11.1.2
  • Interfaces such as Fetcher, ArticleReader, and Storage, which define required behavior without prescribing implementations. section 11.1.2
  • An inward dependency flow: infrastructure and services depend on the domain, while the domain depends on nothing. section 11.1.2

RSS reader domain

An RSS reader can model Article and Feed with standard-library types such as time.Time. Fetcher retrieves feeds, while Storage persists and reads articles. API and worker implementations can change independently because they depend on these domain abstractions rather than concrete databases, HTTP frameworks, or feed parsers. section 11.1.2 section 11.4

Figure 11.4 Hexagonal architecture: Domain at the center with ports and adapters

Use the architecture diagram to trace how the domain stays at the center while ports define boundaries and adapters provide concrete infrastructure integrations. section 11.4

How Go in Action, Second Edition covers it

How deep it goes
Defines entities, interfaces, and dependency direction, then connects them to hexagonal architecture and testable implementations.
Examples
Uses an RSS reader with Article, Feed, Fetcher, ArticleReader, Storage, API, and worker components.
What you can do after
Build shared domain boundaries, swap interface implementations, and test handlers without databases or external services.
How it connects
Connects entities, interfaces, dependency inversion, hexagonal architecture, ports, adapters, and test doubles.

Also explained in

Compare how 7 books explain domain-driven design →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Go in Action, Second Edition. The section links point to the parts of the book it draws on.