Skip to content

Instantly share code, notes, and snippets.

@morisono
Forked from corlaez/README.md
Created August 18, 2025 04:57
Show Gist options
  • Save morisono/e146830f74fc093091b4196db708602f to your computer and use it in GitHub Desktop.
Save morisono/e146830f74fc093091b4196db708602f to your computer and use it in GitHub Desktop.
Hexagonal Architecture and Modular Implementation

Hexagonal Architecture

Conceptualized by Alistair Cockburn initially under the name "Ports and Adapters".

In a nutshell: Application Driver -> Primary Adapter -> Primary Port -> Use Case -> Secondary Port -> Secondary Adapter -> External System/Side Effect

image

Use Cases

They define the business rules and they should not depend on code related on how the system communicates with the outside world. Throught the use of Ports and Adapters the Use Cases can be reliably tested and change mainly if the business rules change

Ports

They expose the ways in which the use cases can be reached (primary) or reach to (secundary) to the outside world. They are technology agnostic.

image

Adapters

They deal with the code that communicates outside of the system.

image

Modules

Based on talks by Jakub Nabrdalik such as https://www.youtube.com/watch?v=2vEoL3Irgiw

image

Modules Project Structure

Based on Jakub Nabrdalik's talks About Hexagonal Architecture and TDD.

image

Module configuration and it's relationship with mock testing:

https://gist.github.com/corlaez/aa2c1a657438f5c998af9340a3339051

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment