Clean Architecture
# Clean Architecture
The Software Architecture should be:
- Independent of frameworks: The architecture does not depend on the existence of some library.
- Testable: The business rules can be tested without the UI, Database, Web Server, or any other external element.
- Independent of UI: The UI can change easily, without changing the rest of the system.
- Independent of Database: Your business rules are not bound to the database.
- Independent of any external agency: Your business rules don’t know anything at all about the outside world.
This diagram gives us an abstract view of the Clean Architecture, as proposed by Uncle Bob.
# The Dependency Rule
- Source code dependencies can only point inwards.
- Nothing in an inner circle can know anything at all about something in an outer circle.
- In particular, the name of something declared in an outer circle must not be mentioned by the code in the an inner circle. That includes, functions, classes. variables, or any other named software entity.
- The outermost circle is low level concrete detail. As you move inwards the software grows more abstract, and encapsulates higher level policies.
# Layers/Circles
The Clean Architecture follows a layered approach to achieve code separation. It generally includes four layers but you can add more circles/layers as long as they follow the dependency rule.