liveBook · Manning

Domain architecture

As explained in Microservices Patterns, Second Edition

Domain architecture is the internal organization of a domain module's business logic and its interfaces to external concerns.

A domain module is a vertical slice for a subdomain, combining business logic with supporting interfaces and infrastructure. Organize its internals as a hexagonal architecture, keeping business logic distinct from adapters that communicate with the outside world. section 6.2.3

A Consumer domain module separates three responsibilities:

  • The REST API is an inbound adapter; its package contains HTTP controllers such as ConsumerController. section 6.2.3
  • The domain package holds business logic, including Consumer and the ConsumerRepository interface. section 6.2.3
  • The infrastructure package holds outbound adapters, such as ConsumerDao implementing ConsumerRepository. section 6.2.3
Figure 6.10 A domain module consists of various sub-packages, including restapi, domain, and infrastructure. The restapi package contains the REST API inbound adapter, the domain package contains the business logic, and the infrastructure package contains the outbound adapters.
domain module

Shows how the REST API, domain, and infrastructure packages divide the module’s responsibilities. section 6.2.3

Cross-module collaboration

An Order module can call Consumer entities and repositories directly to reserve or release credit, but this creates tight design-time coupling. A ConsumerService facade reduces that coupling and can be mocked. Prefer APIs over direct database access for modularity, though a cross-module SQL join may be chosen when implementation ease and efficiency matter more. section 6.2.3 section 6.2.3

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines hexagonal components and package responsibilities, then contrasts cross-module coupling choices.
Examples
Uses Consumer and Order modules to illustrate package structure, facade-based collaboration, and cross-module database queries.
What it assumes
Assumes domain modules correspond to subdomains within a modular monolith.
What you can do after
Understand how to divide a domain module and weigh API boundaries against direct database access.
How it connects
Connects hexagonal architecture with REST APIs, repositories, adapters, and modular monoliths.

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