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.
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
