Clean Architecture — Notes
Packaging
- One module per layer (
domain, application, infra-sql, web).
- The build tool enforces the dependency rule (
domain cannot depend on infra-sql).
Mapping
- Adapters map outward types (DTO, ORM entity) ↔ domain types.
- Domain never sees JSON / SQL row types.
Cross-cutting concerns
- Tracing / metrics / logging → in adapters or via decorators around use cases.
- Auth → adapter (HTTP) verifies token; use case receives a principal value object.
Tests
- Domain: pure unit tests, no IO.
- Application: in-memory port fakes; assert use-case outcomes.
- Adapter: integration tests against the real tech (Postgres, Stripe sandbox).
- End-to-end: a small handful covering critical paths.
Refs
- Robert C. Martin: Clean Architecture (2017).
- Alistair Cockburn: "Hexagonal Architecture" (2005, alistair.cockburn.us).
- Jeffrey Palermo: "The Onion Architecture" (2008).
- Vaughn Vernon: Implementing DDD (DDD + Hexagonal).