Clean architecture pattern

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

cleanarch-layers
CleanArchitecture

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

Layers

Domain (Entities)

Has basic types and interfaces for your application.
As well as common logic for your domain.

Usecase

Services, handlers, controllers, whatever we call them.

Adapters

Implementations for API integrations.

Infrastructure

Presentation logic (handlers: HTTP/GRPC/GraphQL), DB integration, hardware details.

Motivation

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

https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html
https://medium.com/@manakuro/clean-architecture-with-go-bce409427d31

Further watching

https://www.youtube.com/watch?v=Nsjsiz2A9mg
https://www.youtube.com/watch?v=2dKZ-dWaCiU
https://www.youtube.com/watch?v=cPH5AiqLQTo

Similar Posts

LEAVE A COMMENT