Hexagonal Architecture Pattern with Spring Boot example

Ali Zeynalli
2 min readJan 17, 2022
Photo by James Hon on Unsplash

Hexagonal Architecture, firstly introduced by Alistair Cockburn back in early 2000s, (who is also one of the main protogonists of Manifesto of Agile Software Development) is pretty popular architectural style applied to layered architectured software systems, which lack of flexibility, entaglement. This architectural pattern is widely inspired by Eric Evan’s DDD, but they are by far not same.

According to the Hexagonal Architecture, the software system should be divided to decoupled parts mainly: user interface, core business logic, server/database. This layers are connected with each other through different Ports/Adapters. The Ports are interfaces that offer functionalities. Adapters are users of these functionalities.

The hexagonal architecture divides a system into several loosely-coupled interchangeable components, such as the application core, the database, the user interface, test scripts and interfaces with other systems. This approach is an alternative to the traditional layered architecture. Basically, the one can define ports for databases, logging, event sourcing, notifications etc. There can be multiple Adapters that call same port.

--

--

Ali Zeynalli

IT-Architect | BMW Group | M.Sc. Technical University of Berlin