Catalog
concept#Architecture#Software Engineering#Design Pattern#Software Development#Testability

Hexagonal Architecture

An architectural approach that promotes the separation of business logic and infrastructure.

Hexagonal architecture, also known as the Ports-and-Adapters architecture, is a design pattern aimed at separating business logic from infrastructure.
Established
Medium

Classification

  • Medium
  • Technical
  • Architectural
  • Advanced

Technical context

DatabasesThird-Party ServicesUser Interfaces

Principles & goals

Separation of Business Logic and InfrastructureUse of Interfaces to Promote ModularityEnabling Testability through Isolation
Build
Domain, Team

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.

  • Increased Flexibility to Adapt to New Requirements
  • Improved Testability of the Application
  • Better Maintainability through Clear Structure

  • 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

  • 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.

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.

1

Gather and analyze requirements.

2

Create architecture design.

3

Implement modules and adapters.

⚠️ Technical debt & bottlenecks

  • Insufficient testing of implementations.
  • Outdated documentation.
  • Lack of modularity in the codebase.
Architecture ComplexityLack of Experience in the TeamDifficulties in Integration
  • Using adapters without clear interfaces.
  • Ignoring security requirements.
  • Lack of consideration for user experience.
  • Assuming that all requirements are already known.
  • Believing that the architecture does not need to be adjusted anymore.
  • Overlooking the importance of testing.
Knowledge in Software ArchitectureExperience with Testing MethodsAbility to Analyze Problems
Adaptability to Changing RequirementsEnabling Testing and ValidationIntegration of New Technologies and Services
  • Compliance with Security Standards
  • Technological Constraints of the Infrastructure
  • Regulatory Requirements