The Layers of Clean Architecture
Learn the about of the layers of clean architecture.
We'll cover the following...
Clean architecture captures both the conceptual hierarchy of components as well as their type hierarchy through a layered approach. In clean architecture, the components of the system are categorized and belong to a specific layer. Their rules are relative to the communication between components that belong to the same or different layers. In particular, clean architecture is a spherical structure—inner (lower) layers are completely encompassed by outer (higher) ones. In this description, the inner layer is oblivious to the outer layer’s existence.
In computer science, the words “lower” and “higher” almost always refer to abstraction and not the importance of a system component. Each part of a system is important. Otherwise, there’s no reason for it to be there.
Let’s look at the main layers depicted in the figure. It’s important to keep in mind that a specific implementation may require us to create new layers or split some of them into multiple ones.
There are four main layers in clean architecture. These layers include the following:
- Entities
- Use cases
- Gateway
- External systems
The entities layer
The entities layer is the innermost layer. This layer of clean architecture represents the domain models. These are what our system needs to interact with and are complex enough to require their own representation.
For example, strings in Python are very powerful and complex objects. They provide many unique methods, and it ...