In recent years, Hexagonal Architecture — that is, Ports & Adapters —…
Kaan Baytan
In recent years, Hexagonal Architecture — that is, Ports & Adapters — has become very popular among large companies, and it's no accident. Let's take a quick look at why it works so well.
First of all, let's note that Hexagonal Architecture mainly consists of 3 layers that are clearly separated from each other:
1. Domain
It is the heart of the system.
All business logic resides here, and this logic is completely independent of frameworks, databases, and APIs.
A domain usually contains:
Entities — yes, these are not entities in the database
Value Objects — immutable objects
Business rules
Domain Services
Special exceptions
The main idea: the most important part of the system should remain as pure and stable as possible.
2. Application
This layer acts as a kind of "controller" that controls the input and output of the system.
These are usually located here:
Use Cases
DTOs and Mappers
IN Ports — operations entering the system
OUT Ports — outgoing operations to the infrastructure layer
This layer avoids mixing business logic with technical details and keeps the structure of the system neater.
3. Infrastructure
All the technical details are already here:
Frameworks
Databases
Message Queues
REST
GraphQL
SMTP
Integrations with external systems
This layer implements Adapters.
Thanks to adapters:
It is possible to switch from MySQL to MongoDB without touching the domain layer
Requests can be sent to external APIs
Messages can be received from queues
It is possible to work with frameworks
Technical details do not pollute the internal business code
Thanks to the Ports & Adapters approach, Infrastructure becomes one of the most flexible layers.
give hastagta
#HexagonalArchitecture #PortsAndAdapters #SoftwareArchitecture #CleanArchitecture #DomainDrivenDesign #DDD #BackendDevelopment #SoftwareEngineering #SystemDesign #DomainLayer #ApplicationLayer #InfrastructureLayer #UseCases #CleanCode #SOLID #Microservices #ModularMonolith #Backend #Programming #Developer #CodeQuality #MaintainableCode
