Skip to content

Airline management in a multimodule Maven project with Hexagonal Arch, CQRS, Event Sourcing, Event Driven Arch and Kafka for synchronizing databases

License

Notifications You must be signed in to change notification settings

Ivan-Montes/hex-cqrs-es-eda

Repository files navigation

hex-cqrs-es-eda

Airline management in a multimodule Maven project with Hexagonal Arch, CQRS, Event Sourcing, Event Driven Arch and Kafka for synchronizing databases

Components

  • Kafka [9092] + [9093]
  • Kafka-UI [8080]
  • REST API ms-client with OpenApi Swagger and two separate DB for R/RW actions [8081]
  • REST API ms-flight with OpenApi Swagger and two separate DB for R/RW actions [8082]
  • REST API ms-seat with OpenApi Swagger and two separate DB for R/RW actions [8083]
  • REST API ms-reservation with OpenApi Swagger and two separate DB for R/RW actions [8084]
  • Service ms-payment simulates an event driven payment gateway.
  • Service ms-notification working as an event driven notification service
  • REST API ms-registry with OpenApi Swagger and two separate DB for R/RW storaging all events [8085]
  • REST API ms-oauth2 with OpenApi Swagger working as JWT Token generator [9000]
graph BT

subgraph KafkaUI
 Kafka-UI
end  

subgraph Kafka
  subgraph Kafka Server   
  end
end 

subgraph ms-client
   C{{Client}}
end 

subgraph ms-client-db
  direction RL
   C1[(NoSql Read Db)]
   C2[(NoSql Write Db)]
   C3[(Redis Backup Db)]
end

subgraph ms-flight
   F{{Flight}} 
end  

subgraph ms-flight-db
  direction RL
   F1[(NoSql Read Db)]
   F2[(NoSql Write Db)]
   F3[(Redis Backup Db)]
end

subgraph ms-seat
   S{{Seat}}
   P{{Plane}}
end

subgraph ms-seat-db
  direction RL
   S1[(NoSql Read Db)]
   S2[(NoSql Write Db)]
   S3[(Redis Backup Db)] 
end

subgraph ms-reservation
   R{{Reservation}}
end  

subgraph ms-reservation-db
  direction RL
   R1[(Sql Read Db)]
   R2[(NoSql Write Db)]
   R3[(Redis Backup Db)] 
end

subgraph ms-registry
   RE{{Registry}}
end 

subgraph ms-registry-db
  direction RL
   RE1[(Sql Read Db)]
   RE2[(NoSql Write Db)]
end

subgraph ms-payment
   PAY(Payment)
end

subgraph ms-notification
    NOT(Notification)
end 
 
subgraph ms-oauth2
  msoauth2{{JWT Token}}
end
    
  ms-client-db <--> ms-client
  ms-flight-db <--> ms-flight
  ms-seat-db <--> ms-seat
  ms-reservation-db <--> ms-reservation
  ms-registry-db <--> ms-registry

  C1 <-. Synchro .-> C2
  F1 <-. Synchro .-> F2
  S1 <-. Synchro .-> S2
  R1 <-. Synchro .-> R2
  RE1 <-. Synchro .-> RE2

  ms-client <-->|Publish-Subscriber| Kafka   
  ms-flight <-->|Publish-Subscriber| Kafka  
  ms-seat <-->|Publish-Subscriber| Kafka
  ms-reservation <-->|Publish-Subscriber| Kafka 
  ms-payment <-->|Publish-Subscriber| Kafka
  ms-notification <-->|Publish-Subscriber| Kafka
  ms-registry <-->|Subscriber| Kafka

  KafkaUI <--> |  | Kafka
  ms-oauth2 <--> |  | Kafka
  
  classDef canvas_basic fill:#B1D690,stroke:#333;
  class ms-client-db,ms-flight-db,ms-seat-db,ms-reservation-db,ms-registry-db canvas_basic
  class ms-client,ms-flight,ms-seat,ms-reservation,ms-payment,ms-notification,ms-registry,ms-oauth2,Kafka,KafkaUI canvas_basic
  
  
Loading

Table of contents

Installation

  1. First of all clone or download the project.

  2. Inside the main folder, you could find two docker-compose yaml files.

  3. From there use the command line to start the project in dev or production mode

    **Generate .jar**
    mvn clean package
    
    **Developer mode**  
    docker-compose -f docker-compose-dev.yml up -d

    **Production mode**
    docker-compose -f docker-compose-prod.yml up -d

The dev environment is ready for using with your IDE. The microservice attempts to communicate with Kafka using the local host. In production, it uses the archive Dockerfile to build an image of the project, so you wont need the IDE.

  1. You could stop the project and free resources with any of these orders
    **Developer mode**
    docker-compose -f docker-compose-dev.yml down --rmi local -v
      
    **Production mode**
    docker-compose -f docker-compose-prod.yml down --rmi local -v  

Usage

First of all, please visit the REST API documentation. Replace ${port} for the suitable microservice port:

http://localhost:${port}/swagger-ui/index.html

Kafka-UI allow you to check your Kafka server using a practical dashboard, so visit the following url:

http://localhost:8080

Features

➡️ Unit testing for business logic classes using Test Containers for Repositories

➡️ Include two docker-compose yaml files for easy change of environment

➡️ Hexagonal Architecture following Clean Architecture principle

➡️ CQRS pattern with independent databases for Read or RW actions

➡️ DB synchronization by Publisher-Subscriber pattern

➡️ Redis DB for each microservice works as caches to store ID references for other REST APIs

➡️ Event Sourcing for persisting as an ordered sequence of events

Maintainers

Just me, Iván 😅

License

GPLv3 license


Java Maven Spring GitHub Eclipse SonarQube Docker Kafka GPLv3 license

About

Airline management in a multimodule Maven project with Hexagonal Arch, CQRS, Event Sourcing, Event Driven Arch and Kafka for synchronizing databases

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages