In recent years, many companies have started to adopt a Clean Archite…
Kaan Baytan
In recent years, many companies have started to adopt a Clean Architecture approach for a very simple reason: to keep the core of the business clean and protect it from technological chaos.
### 1. Domain (Entities)
Here lies the purest logic of business:
- Entities
- Value Objects / Records
- Business rules
There is no framework, no database. There are only business rules that should never be broken.
### 2. Use Cases
It is the layer where operations in the system are performed:
- Use Cases
- Flow orchestration
- Process validations
It's the part that decides what happens when the user does something.
### 3. Interface Adapters
It is the layer that transforms the external world into a form that the internal system can understand:
- Controllers
- DTOs / Mappers
- Ports and Adapters
- Repository interfaces
This layer acts as a kind of "interpreter" between the business logic and the technologies we use.
### 4. Frameworks & Drivers
It is the outermost layer and the technology-related parts are located here:
- REST API
- ORMs
- Databases
- Message Queues
- Frameworks
Even if you switch from MySQL to MongoDB or Spring to NestJS tomorrow, the Domain and Use Case layers won't even know about it.
### But how similar is it to Hexagonal Architecture?
They can be considered very close architectures.
- Clean Architecture is built on more rings.
- Hexagonal Architecture uses the Ports & Adapters approach more clearly.
But the main idea is almost the same:
- Separating business logic from technology
- Reduce technological dependencies
- Creating more easily testable software
- Facilitate system maintenance and development
#CleanArchitecture #SoftwareArchitecture #HexagonalArchitecture #DomainDrivenDesign #DDD #BackendDevelopment #SoftwareEngineering #SystemDesign #CleanCode #SOLID #UseCases #DomainLayer #PortsAndAdapters #Microservices #ModularMonolith #Backend #Programming #Developer #CodeQuality #MaintainableCode