Clean / Onion / Hexagonal Architecture
Problem
Business rules become mixed with:
HTTP
SQL
Azure
Kafka
UI
Soon the business logic cannot be understood or tested without all of its infrastructure.
Solution — Isolate the Business Core
Onion places the domain at the center, application logic around it, and infrastructure—including persistence—outside; code dependencies point inward.
Clean Architecture similarly points dependencies inward, separating entities (business rules), use cases (application actions), interface adapters, and outer frameworks.
Hexagonal (Ports and Adapters) connects the core through interfaces: for example, an OrderRepository interface implemented by a SQL adapter. Both approaches can work together.
HTTP
↓
Adapter
↓
Domain
↑
Adapter
↑
Database
Core idea: isolate core business logic from changing external technologies.