Goal: a core domain that does not depend on delivery or infrastructure.
Use for:
- keeping business rules testable and framework-agnostic
- isolating database and UI choices from core logic
- structuring layers and their dependencies
Workflow:
- Put business rules in a core that imports nothing external.
- Define ports (interfaces) the core needs.
- Implement adapters for db, UI, and services at the edges.
- Point all dependencies inward, toward the core.
- Pass data across boundaries as plain structures.
- Test the core without frameworks or a database.
Layers:
- entities and use cases at the center
- interface adapters (controllers, presenters, gateways)
- frameworks and drivers at the outer edge
Rules:
- dependencies point inward only; core knows no framework
- depend on interfaces, inject implementations
- keep framework code out of use cases
- the domain must be testable in isolation