# Clean Architecture

> The rules of the business sit in the middle. Tools stay at the edge.

**Field:** Software Development  
**Category:** Architecture  
**Also known as:** Onion Architecture, Uncle Bob Architecture

## Think of it like

Think of it like an onion. The most important part is in the middle, safe from the outside.

## Definition

Clean architecture puts the business rules at the center of an app. The database, the web framework and the screens sit in outer rings. The key rule is that code only points inward: the center knows nothing about the outer rings. So you can swap a database or framework without touching the rules. Robert C. Martin described it in 2012.

## Example

Lucy's pricing rules live in plain code with no database calls. Her team moves from one database to another, and not one pricing line changes.

## Why it matters

The rules are what make a business unique. Keeping them apart from tools means they outlive those tools.

## Common mistake

Adding every layer from the diagram to a small app. Four folders for twenty lines of code is too much.

## Three principles

- **Rules in the center.** The heart of the app.
- **Point inward.** Center knows nothing outside.
- **Swap the tools.** Rules stay the same.

## Related terms

- [Hexagonal Architecture](https://learn.benibix.com/term/development/hexagonal-architecture)
- [Layered Architecture](https://learn.benibix.com/term/development/layered-architecture)
- [Dependency Injection](https://learn.benibix.com/term/development/dependency-injection)
- [SOLID Principles](https://learn.benibix.com/term/development/solid-principles)

## Told apart from

- [Clean Architecture vs Hexagonal Architecture](https://learn.benibix.com/compare/clean-architecture-vs-hexagonal-architecture): People think clean and hexagonal architecture are rivals, and they are not. Both keep the business rules at the center. The database and the web depend on the rules, never the other way. One names the plugs: ports, and adapters that fill them. The other draws rings and says code points only inward. The rule is the same.

---

Source: https://learn.benibix.com/term/development/clean-architecture
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
