My take on hexagonal architecture with Elixir

A rant about a design pattern that might enlighten the core, the ins and outs of your microservices and address technology fragmentation

Rafa Noronha
Noronha dot tech
2 min readNov 10, 2021

--

Little context on my background with hexagonal arch

I was not bitten by the clean architecture bug. Don’t think I was even bitten by the microservices bug. At least in the early days and in absolutely lack of purpose.
I was blessed to take my time and I mean many years, meeting many different stories on the adoption of these stuff. Specially microservices. For some reason, clean architecture, and from now on let’s stay with hexagonal architecture please, took more time to get my attention. I mean, couple years ago I was even on the side of people messing up other engineers’ adoption endeavors.

This year I’ve put Elixir code in production for the first time. The simplest and most reliable microservice I had ever written. And simple to the point of realizing it was lacking something.

What I now realize hexagonal architecture brings to the table

This is the kind of structure I think my first Elixir microservice missed:

The one thing I like the most about this take on the pattern?
Core / business logic gives you a warm hug in your first contact with the project. All other stuff respectfully step back!

Adoption of microservices is now the norm in engineering orgs with headcount above fifty-ish engineers. Given the potentially growing number of different teams and services, code-bases structures are going to emerge with design patterns surely taking place. MVC being super expected given its popularity.
Even in front of an homogeneous stack and/or adoption of Service Mesh/Sidecar patterns, you still need to figure out how to organize the different citizens of the source-code. Models, Views and Controllers? We can do better in 2021.

I believe hexagonal architecture is the big star here: ports and adapters concepts fit pretty nicely on top of the distributed nature of microservices because every microservice needs well defined boundaries.
Ports and Adapters are essentially enlightening the core, the ins and outs of your microservices and addressing technology fragmentation.

Sign me up on taking the ability to navigate around git repos written by other people, easily discovering the domain and boundaries of such applications, given the more contained cognitive load.
Different teams building different applications in similar ways. Leveraging more opportunity to learning and mastery development.

--

--

Rafa Noronha
Noronha dot tech

Construindo produtos digitais desde antes da bolha tech