advanced
Clean Architecture
Protect use cases and domain rules from framework and delivery details by pointing dependencies inward and translating at boundaries.
Clean Architecture organizes code into concentric rings—entities, use cases, interface adapters, frameworks—with dependencies pointing inward. Use cases orchestrate application-specific rules; entities hold enterprise-wide invariants. Frameworks and drivers stay at the outer edge as replaceable details.
On interviews: explain the dependency rule and where DTOs live. Contrast ceremonial folder trees with teams that achieve the same rule via modules.
Common pitfalls: renaming folders without changing dependencies; use cases that are pass-through CRUD; skipping boundaries in small scripts then copying structure blindly.
The trade-off is flexibility versus complexity—know when the simpler path is enough.
Checklist:
- Inner rings never import outer rings.
- Use case classes map to application workflows.
- Mappers translate at adapter boundaries.
- Architecture tests enforce forbidden imports.