Clean architecture pattern

The main idea is to have layers that only depend on inner layers (see the image below).

Let’s imagine you have a repository that includes several applications.


Domain (Entities)

Has basic types and interfaces for your application. Including the application config and Registry with all the interfaces.
Optionally could also include some common logic for several applications.


Has logic for the application that can potentially be shared between several handlers.

Adapters (Presenters)

Handlers. Uses interfaces from the Domain layer to implement the logic needed for the handler.


Populates Domain’s Registry with all the interface implementations on the app start.

(Optional) Prepares input and output to fit the Adapters handlers’ signature. It is here to reuse the same handlers for HTTP and GRPC interaction, for instance.


To make the app testable and easy to maintain (replacing one implementation with another one will be less painful as only needs updating of the Infrastructure level).

Further reading

Further watching

Similar Posts