Hexagonal Architecture
An architectural approach that promotes the separation of business logic and infrastructure.
Classification
- ComplexityMedium
- Impact areaTechnical
- Decision typeArchitectural
- Organizational maturityAdvanced
Technical context
Principles & goals
Use cases & scenarios
Compromises
- Incorrect implementation can lead to serious issues
- Excessive abstraction can reduce understandability
- Difficulties in integrating new technologies
- Regular review of the architecture.
- Documentation of all decisions.
- Training the team in the principles of hexagonal architecture.
I/O & resources
- Software Requirements
- Technical Specifications
- Resource Allocation
- Functional Software Solution
- Architecture Documentation
- Test Reports
Description
Hexagonal architecture, also known as the Ports-and-Adapters architecture, is a design pattern aimed at separating business logic from infrastructure. This allows for better testability, flexibility, and maintainability of software applications by using various interfaces (ports) and implementations (adapters) to enable interaction with external systems.
✔Benefits
- Increased Flexibility to Adapt to New Requirements
- Improved Testability of the Application
- Better Maintainability through Clear Structure
✖Limitations
- Can lead to increased complexity if not implemented correctly
- Requires a certain level of experience in the team
- May not be suitable for very small projects
Trade-offs
Metrics
- Test Coverage
The percentage of code covered by tests.
- Error Rate
The number of errors per 1000 lines of code.
- Development Time
The time taken to develop new features.
Examples & implementations
E-Commerce Platform Example
An example of an e-commerce platform developed using hexagonal architecture to ensure flexibility and maintainability.
Integration of Payment Providers
An example of integrating various payment providers into an existing application using adapters.
Migration to Microservices
An example of the gradual migration of a monolithic application to a microservices architecture.
Implementation steps
Gather and analyze requirements.
Create architecture design.
Implement modules and adapters.
⚠️ Technical debt & bottlenecks
Technical debt
- Insufficient testing of implementations.
- Outdated documentation.
- Lack of modularity in the codebase.
Known bottlenecks
Misuse examples
- Using adapters without clear interfaces.
- Ignoring security requirements.
- Lack of consideration for user experience.
Typical traps
- Assuming that all requirements are already known.
- Believing that the architecture does not need to be adjusted anymore.
- Overlooking the importance of testing.
Required skills
Architectural drivers
Constraints
- • Compliance with Security Standards
- • Technological Constraints of the Infrastructure
- • Regulatory Requirements