Alan Santos

Software Engineer

The Clean Architecture

To start this article, I have some questions for you:

  • When you start a project, how do you choose the project folder/package structure?
  • Can you change your database without change your business rules?
  • Can you test your business rules without any UI, database, external service, etc?

If you can’t answer these questions without difficulties, I will present for you, the Clean Architecture by Robert C. Martin (Uncle Bob).

Source and credit:

For all these questions and more, these architecture provides us a layer way to fallow that turns the core layer Enterprise Businesses Rules from the external layers like Frameworks and Drivers.

Here is the summary off the responsibility description of all Clean Architecture layers:

  • Enterprise Businesses Rules (Entities): Layer that encapsulate the business entities and has the specific business rules.
  • Application Businesses Rules (Use Cases) : Layer that encapsulate all application rules.
  • Interface Adapters: Layer that has the purpose of convert data in the most accessible and convenient way possible to the Entities and User Cases layers.
  • Framework and Drivers: Layer that has tools like database, user interface, etc.

Source and credit: .

Only four layers?

No, there is no rules that says you aways will have 4 layers. You may find that you need more than these 4 layers, and you can implement, but you have to keep the layer dependence where the external layers has the dependence of the internals layers.


Use the Clean Architecture may help you with a dependence pattern to implement your project, your tests and make changes on your project more easily beyond keep your project structure and code more clean.

In the next Clean Architecture article, I will show you how can you implement a project using all the layers that these architecture provide us, but you can find a done project mine here.

For the comments, I would like to know if you use the Clean Architecture or if will you start to search to implement on your project? See you next time!