Play a scenario
The request travels inward to the business rules and back out to the database. Notice the last hop: control flows from the service out to the repository, yet the arrow points the other way. The service owns an interface, the repository implements it. That is dependency inversion.
Or test a dependency
Click a component in the diagram, then a second one. You will see whether that import is allowed in this architecture, and why.
An arrow means "depends on" (imports).
Clean Architecture arranges code in rings. The business rules sit in the middle and know nothing about the outside world. Frameworks, databases, and the web are details at the edge.
The one rule
Dependencies point inward. Nothing in an inner ring knows anything about an outer ring.
What it buys you
- Business rules are independent of frameworks, UI, and database
- The core is trivially testable
- Technology decisions can be postponed or reversed
What it costs
- More interfaces and more mapping between rings
- Too much ceremony for simple CRUD applications
- The inversion at the boundary takes a while to get used to
When to pick it
Long-lived systems with real business logic, where the rules will outlive the framework they were first written in. Hexagonal and Onion Architecture follow the same idea.
Keeping it that way
A diagram like the one above only holds as long as nobody adds the one import that breaks it. TangleGuard reads your real code, shows it as this kind of graph, and checks every dependency against the rule you drew: while you or your agent write, and again before a pull request merges.
Architecture VerificationProtect your codebase now
Two minutes to set up: the CLI, the hook for your agent, and the GitHub Action for every pull request. It runs locally, so your code never leaves your machine.
