• Stars
    star
    537
  • Rank 82,649 (Top 2 %)
  • Language
    Java
  • License
    MIT License
  • Created almost 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Hexagonal Architecture Demo Project about Ticketing and Payment

Modular Architecture - Hexagonal Demo Project

This project is a sample production-ready implementation for demonstrating the power of Hexagonal Architecture (aka Ports And Adapters Pattern) written in Java.

Build Ticket API Build Payment API

Lines of Code Coverage Technical Debt Code Smells Maintainability Rating


Table of Contents

Wiki

Reports


Hexagonal Architecture Flow Diagram (click to enlarge)

Hexagonal Architecture Flow Diagram

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 7
  • Mono Repo
  • Docker
  • Mysql
  • Redis
  • Kafka
  • Groovy 3
  • Cucumber
  • GitHub Actions

It's so easy to reach 100% code coverage if you design by tests wisely via TDD. There are the types of tests written:

  • Unit tests
  • Dockerized integration tests
  • Consumer-driven contract tests
  • External verifier contract tests
  • Acceptance tests

What You Will Learn

  • Implementing two microservices with spring boot
  • Designing the APIs with hexagonal architecture
  • Packaging by functions and screaming architecture
  • How Ports and adapters separate business from integration points
  • Writing behavior focused unit tests at domain module
  • Writing integration tests isolated from the business at infra module
  • Using Gradle to configure microservices and modules
  • Using mono-repo to handle all APIs in a single git repository
  • Implementing consumer-driven contract tests
  • Creating different testing styles for validating data adapters, event consumers/publishers, controllers

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 to building maintainable and high-quality software. That's why we shared our demo project with the community to attract their interest in the topic.

Contributing

Please feel free to open tickets to suggest new features and improvement points. Please feel free to contribute.

Code of Conduct

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

Authors

License

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

More Repositories

1

java8

contains a several samples for java 8
Java
24
star
2

microservice-docker

Dockerized Microservice with Spring Cloud (Config Server, Discovery Server, Feign Client)
Java
21
star
3

docker-compose-initializr

bootstrap your containers now
JavaScript
16
star
4

hexagonal-demo

demo for hexagonal architect
Java
13
star
5

docker-moon

The DockerMoon project is a dashboard application built for the docker.
Java
7
star
6

spring-cloud-contract-sample

Consumer Driven Contact application with Spring Cloud Contract
Java
6
star
7

java9

Sample Java 9 example(s)
HTML
4
star
8

guardian-app

A Spring Boot validation library
Java
3
star
9

springboot-kafka-sample

Java
3
star
10

Data-Class-Java

Data class with reflection
Java
3
star
11

props4j

Using properties files efficiently
Java
2
star
12

MailSender

You can send very easily e-mail from Java application with MailSender.
Java
2
star
13

spring-reactive

spring reactive sample
Java
2
star
14

CPower

with CPower you can viewing memory statistic in your applications.
Java
2
star
15

java-library-2017

Java libraries you can't miss in 2017
Java
2
star
16

springboot-kotlin

sample spring boot kotlin applicaiton
Kotlin
1
star
17

alicanakkus.github.io

personal blog site
JavaScript
1
star
18

UserSessionManagement

Avoid multiple session per-username
Java
1
star
19

String-Formatter

Java
1
star
20

LogAnalys

Log Analys application running on the Apache hadoop. Summary of application : data cleaning.
Java
1
star
21

syslog-springboot

A sample project for send spring boot application logs to syslog server
Java
1
star
22

alicanakkus

Personal Information
1
star
23

android-spectrum-analyzer

Automatically exported from code.google.com/p/android-spectrum-analyzer
Java
1
star
24

spboot-i18n

this application aims to describe the how spring boot application handle internationalization
Java
1
star
25

FileWatchDog

Java
1
star