Skip to content

mabulgu/Modular-Architecture-Hexagonal-Demo-Project

 
 

Repository files navigation

Modular Architecture - Hexagonal Demo Project

This project is a sample implementation for Hexagonal Architecture (aka Ports And Adapters Pattern) written in Java.

Build Ticket API Build Payment API

Table of Contents

Motivation

We want to write clean, maintainable, well-defined boundary context, well-tested domain code and isolate business logic from outside concern.

What is the Hexagonal Architecture

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.

Technologies Used

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

Usage

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

Useful Links From Authors

  • 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

Useful Links about Hexagonal Architecture

  • 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

History

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.

Roadmap

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.

Contributing

Please feel free to contribute.

Code of Conduct

Please take a lot at code of conduct before opening issues or creating pull requests.

Authors

License

Distributed under the MIT License. See LICENSE for more information.

About

Hexagonal Architecture Demo Project about Ticketing and Payment

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 87.4%
  • Shell 9.5%
  • Groovy 2.7%
  • Dockerfile 0.4%