Where does this code go?
Use this table when you are unsure which folder owns a change. Paths below are Core roles; host folder names vary by adapter — see Adapters. For fair multi-host examples of persistence / composition / UI / async, open those concept pages (they list every documented host, not one favorite).
| Scenario | Core location |
|---|---|
| Database schema / migrations | Module Infrastructure/Persistence/… |
| Application input DTO | Application/DTO/{Capability}/ |
| Intra-module Domain DTO | Domain/DTO/ |
| Pure business rules (Entities) | Domain/Entities/ |
| Persistence / I/O contracts | Domain/Ports/{Capability}/ |
| Process orchestration | Application/UseCases/{Capability}/ |
| Persistence adapter | Infrastructure/Persistence/… |
| External / peer integration | Infrastructure/ExternalServices/ (ACL adapters, HTTP clients) |
| Tech adapter used by one module | That module’s Infrastructure (+ local port if needed) |
| Same tech port used by ≥2 modules | Promote to Shared kernel |
| Cross-module data needed now | Consumer local port + ACL adapter → thin peer *ModuleInterface |
| Cross-module side effect later | Publisher Domain Event → consumer translation listener → inbound Use Case |
| Multi-step cross-module flow | Orchestration Use Case or Infra process manager (ACL + Events only) |
| Cross-context report / list | Owned projection or ACL read — not ORM join across modules |
Processed eventId store | Consumer Infrastructure |
| Cross-module business types in Shared | Forbidden — use ACL / Events |
Decision shortcuts
| Question | Answer |
|---|---|
| Is it a business invariant? | Domain Entity / Domain service |
| Is it orchestration of a user intention? | First-level *UseCase |
| Does it talk to DB / HTTP / peer? | Port in Domain, adapter in Infrastructure |
| Does UI need to call it? | Only first-level Use Cases |
| Do two modules need the same tech helper? | Promote to Shared |
| Do two modules need the same business concept? | ACL or Events — never Shared |
Design test
If the peer module is deleted and replaced by HTTP, does Application/Domain still compile?
If you are placing a use statement and the test would fail, you are in the wrong layer — see Anti-patterns and the Decision tree.