This project is a sample implementation for Hexagonal Architecture (aka Ports And Adapters Pattern) written in Java.
- Motivation
- What is the Hexagonal Architecture
- Technologies Used
- Usage
- Useful Links From Authors
- Useful Links about Hexagonal Architecture
- History
- Roadmap
- Contributing
- Code of Conduct
- Authors
- License
We want to write clean, maintainable, well-defined boundary context, well-tested domain code and isolate business logic from outside concern.
The hexagonal architecture was invented by Alistair Cockburn in an attempt to avoid known structural pitfalls in object-oriented software design, such as undesired dependencies between layers and contamination of user interface code with business logic, and published in 2005.
A timeless goal of software engineering has been to separate code that changes frequently from code that is stable.
~ James Coplien / Lean Architecture
We recommend Hexagonal Architecture for those who want to write clean, maintainable, well-defined boundary context, well-tested domain and decoupling business logic from technical code.
You can use any programming language for implementing Hexagonal Architecture. Here is the list of technologies we used for the demo application;
- Spring Boot 2
- Java 11
- Gradle 6
- Mono Repo
- Docker
- Mysql
- Redis
- Dockerized Integration Tests
- Consumer Driven Contract Testing
After cloning the project on your local, you can use the following gradle commands to build and run tests.
# This command builds all modules, boot ups db and redis, runs contract tests and other tests, closes down db and redis
./gradlew clean build
# If your local infra is already up, then this command only builds all modules and runs contract tests and other tests
./gradlew clean build -PskipInfraSetup
You can boot up all apis and infra with the following commands.
# This command boot ups db, redis and all apis
./run.sh up-all
# This command stops db, redis and kills all apis
./run.sh down-all
- Modular Architecture for Pragmatic Developers - Slides - Youtube
- Growing Hexagonal Microservices With TDD - Slides, Youtube
- It's Not Solid Anymore: Rethinking Software Design and Modularity - Slides, Youtube
- ITT 2018 - Jakub Nabrdalik - Hexagonal Architecture in practice - Youtube
- Ian Cooper on Hexagonal Architectures at Agile Yorkshire - Youtube
- Ports and Adapters Pattern, by Juan Manuel Garrido de Paz - Blog
- DDD, Hexagonal, Onion, Clean, CQRS, … How I put it all together, by Herberto Graca - Blog
- Hexagonal Architecture: three principles and an implementation example, by Erwan Alliaume, Sébastien Roccaserra - Blog
This repository is a side project developed while preparing the conference talk "Growing Hexagonal Microservices With TDD" at Java Day Istanbul 2020. As the authors of this repository, we've been using hexagonal architecture in all microservices (i.e. more than 50+ microservices) running in production since 2017. We believe modularity is the key for building maintainable and high quality software. That's why we shared our demo project with the community to attract their interest on the topic.
We will add additional automated tests to show how hexagonal architecture has impact on implementing tests. We will also learn from you. Please feel free to open tickets to suggest new features and improvement points.
Please feel free to contribute.
Please take a lot at code of conduct before opening issues or creating pull requests.
Distributed under the MIT License. See LICENSE for more information.