Skip to content

Using Axon Framework to build a small backend for an microservice ecommerce app. Style of coding is Domain-driven design (DDD) & Event-driven architecture

Notifications You must be signed in to change notification settings

lebronjamesuit/event-driven-products

Repository files navigation

Next challenge

Working directory: Use dockers-compose to combine Axon Server with our 4 services (products, payments, orders and users) for 1 click starting enviroment.

Testing server: Deploy microservies to AWS without the need of AWS kubernetes

1. Architecture Overview in the Project

image Screenshot 2023-08-17 at 14 26 37

2. SAGA Design Pattern Overview in the Project

  • Flowchart of successful order
image image
  • Flowchart of rollback after failed at payment microservice flowchart
image image

3. Detail of implementation Command Query Responsibility Segregation (CQRS) & Event Sourcing

3.1 Command Query Responsibility Segregation shows how microservices communicate with each other.

image

3.2 Event Sourcing

Part 1: Update to RDB

image

Part 2: Publish Event

image

Completed a lifecyle of event driven.

Aggregate product becomes first class citizen, every event ( create or update) will be tracked. image image image


4. General transactions in Microservice

image

5. Coding convention

  • Controller:

    a) Domain-CommandController (POST, PUT, DELETE)

     e.g OrderCommandController, ProductCommandController
    

    b) Domain-QueryController (GET)

     e.g ProductQueryController
    
  • Command: Action-Domain-Command

    e.g CreateOrderCommand, CreateProductCommand, UpdateProductCommand, ReserveProductCommand, DeleteProductCommand
    
  • Model: Domain-Model

    e.g  OrderRestModel, ProductRestModel
    
  • Aggregate: Domain-Aggregate

    e.g  ProductAggregate, OrderAggregate, PaymentAggregate, UserAggregate
    
  • Event: Domain-Action-Event

    e.g OrderApproveEvent, OrderCreateEvent, OrderRejectEvent
    
  • Event handler: Domain-Events-Hander

    e.g OrderEventsHandler, PaymentEventHandler, ProductEventHandler
    
  • Query : Action-Domain-Query

    e.g FindOrderQuery, FindProductQuery, FindUserQuery
    
  • Query Handler: Domain-QueryHandler

    e.g OrderQueryHandler, ProductQueryHandler
    

6. Technologies

  • Java 17+
  • Axon Framework Spring boot
  • Spring Cloud
  • Lombok
  • Postgresql, H2-DB
  • Axon Server

7. Additional features in the project

Product service by Snapshot

  • Snapshoot threhold = 4
Screenshot 2023-08-17 at 12 02 46

About

Using Axon Framework to build a small backend for an microservice ecommerce app. Style of coding is Domain-driven design (DDD) & Event-driven architecture

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages