chapter five
5 Crossing the boundaries: Adapters, repositories, and the mapping problem
This chapter covers
- Implementing input adapters that drive use cases through the bus
- Mapping application errors to protocol-specific responses
- Designing output adapters that implement core-owned ports
- Distinguishing role interfaces from header interfaces
- Understanding repositories as privileged output ports
- Splitting repository contracts by consumer need
- Wrapping data frameworks behind domain-owned ports
- Choosing a mapping strategy for each boundary
We built the inside of the hexagon: use cases expressed as honest contracts, commands and queries that validate themselves, handlers that orchestrate without owning business logic, and a bus that routes it all. The core is complete. It also has no way to talk to the outside world. That is what this chapter fixes.
For WriteFlow, this means turning the application core from a set of isolated use cases into something the outside world can actually use: publishing articles through HTTP, persisting article state, sending publication notifications, and returning stable responses without exposing internal domain objects.