The idea is to separate what the business pays for — domain rules — from details: the web framework, the database, external APIs. Details can be changed or rewritten without touching the rules. This is achieved with a single rule: source code may only depend inwards, towards the business rules.
The dependency rule and the circles
| Circle | What it contains | Depends on |
|---|---|---|
| Entities | enterprise business rules: domain objects and terms | nothing |
| Use cases | application rules: how entities are used, input and output ports | entities only |
| Interface adapters | controllers, presenters, gateways: converting data between the formats of the circles | use cases and entities |
| Frameworks and drivers | web framework, database, user interface, external services | adapters |
Dependencies cross circle boundaries only inwards. Use case code does not know what is outside — PostgreSQL or a file, REST or GraphQL; the outer layer knows about the inner one, not the other way round. Where control flows outwards, the boundary is crossed through an interface: it is declared inside and implemented outside, so the direction of dependencies does not change. Frameworks are therefore kept at the edge: your code calls the framework, not the other way round.
What it looks like in code
# core/orders.py — knows only about the domaindef place_order(cart, payment_gateway): if not cart.items: raise EmptyCart return payment_gateway.charge(cart.total()) # adapters/payments.py — the detail depends on the core, not the other way roundclass StripeGateway: def charge(self, amount): return stripe.Charge.create(amount=amount.kopecks, currency="usd")What it provides and when to use it
- Business logic is tested without a database or framework — tests are fast and independent of the environment.
- Details change with less pain: replacing the ORM or the web framework means rewriting the outer circle, not the core.
- Boundaries are visible in the project structure: domain rules are not smeared across the whole codebase.
- In mobile development it separates the core with the rules from the platform SDK and the UI framework.
- It pays off where rules are complex and long-lived: banking, insurance, billing. For typical CRUD applications the price is extra layers and data conversions.
The term was popularised by Robert Martin: the 2012 article “The Clean Architecture” and the 2017 book “Clean Architecture”. He brought related approaches under a single rule: Alistair Cockburn’s hexagonal architecture with ports and adapters, and Jeffrey Palermo’s onion architecture. The circles are named differently in the variants, the rule is the same.
Sources
the term is written from these pages- Robert C. Martin — The Clean Architecture (2012)blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html(opens in a new tab)
- Robert C. Martin — Clean Architecture: A Craftsman's Guide to Software Structure and Designpearson.com/en-us/subject-catalog/p/clean-architecture-a-craftsmans-guide-to-software-structure-and-design/P200000009528(opens in a new tab)
Verified 8 Nov