Search IconIcon to open search

Hexagonal Architecture

Last updated Mar 30, 2023

# Swappable data sources

# Leveraging Hexagonal Architecture

The idea of Hexagonal Architecture is to put inputs and outputs at the edges of the system design. Business logic should not depend on whether we expose a REST or GraphQL API, and it should not depend on where we get data from - a database, microservice API expose via gRPC or REST, or just a simple CSV file.

# Defining the core concepts

# Entities

# Repositories

# Interactors

With the three types of objects described above, we are able to define business logic without any knowledge or care where the data is kept and how business logic is triggered. Outside the business logic are Data Sources and Transport Layer:

# Data Sources

# Transport Layer

In Hexagonal Architecture, all dependencies point inward - core business logic doesn’t know anything about the transport layer or the data sources. Still, the transport layer knows how to use interactors, and the data sources know how to conform to the repository interface.

# Swapping data sources

# Hiding data source details

# Testing strategy

# Interactors

# Data sources

# Integration tests

# References