The Dependency Rule says source-code dependencies can only point inward, toward the business rules.
Clean Architecture draws concentric circles, from the centre outward:
- Entities: enterprise business rules.
- Use Cases: application rules.
- Interface Adapters: controllers, presenters and gateways.
- Frameworks and Drivers: the web framework and the database.
Nothing in an inner circle may know the name of anything in an outer circle. So the inner circles contain no ORM, HTTP or framework types.
In a traditional layered architecture, the business layer usually depends on the data access layer below it. The database sits at the bottom, and the domain depends on it. Clean Architecture inverts this with DIP (the Dependency Inversion Principle: depend on abstractions, not concrete classes). The use case defines a repository interface. The database adapter in the outer circle implements that interface.
The result:
- You can test business rules without a database or web server.
- You can replace infrastructure without touching the business rules.
Onion Architecture expresses the same idea.
- Clean Architecture has concentric circles: entities, use cases, adapters and frameworks.
- Source-code dependencies point only inward.
- Inner code never references framework, database or HTTP types.
- In a layered architecture the domain depends on data access. DIP inverts this dependency.