# bayajidalam/saga-flow architecture

> Architecture diagram of the GitHub repository bayajidalam/saga-flow, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bayajidalam/saga-flow
- Repository: https://github.com/bayajidalam/saga-flow

## Overview

##### Main Components

a. Microservices (represent as rectangles):
- Order Service (Port 3000)
- Inventory Service
- Payment Service
- Notification Service

b. Message Broker:
- RabbitMQ (represent as a hexagon to distinguish it as the event bus)

- OrderCreated events
- InventoryUpdated events
- PaymentProcessed events

**┌─ Services Layer ─────────────────────────┐**
- ┌────────┐    ┌────────┐    ┌────────┐ │
- Order  │    │Payment │    │Notif.  │ │
- Service │    │Service │    │Service │ │
- ┘    └────────┘    └────────┘ │
- ▲            ▲             ▲       │

- ▼            ▼             ▼       │
- ┌─────── Message Broker ──────────┐   │
- RabbitMQ              │    │
- ┘    │
- ┘

##### Event Flow Representation

- Order Service → RabbitMQ (OrderCreated)
- RabbitMQ → Inventory Service (OrderCreated)
- RabbitMQ → Payment Service (OrderCreated)
- Inventory Service → RabbitMQ (InventoryUpdated)
- RabbitMQ → Notification Service (InventoryUpdated)
- Payment Service → RabbitMQ (PaymentProcessed)

##### Additional Elements

Include:
- Port numbers where applicable (e.g., Order Service: 3000)
- Version/environment information

##### Technical Details to Note

Annotations showing:
- Node.js runtime for each service (indicated by package.json files)
- Docker Compose orchestration
- Event payload types (as notes)

##### Documentation Elements

Add:
- Title: "Microservices Choreography Architecture"
- Subtitle: "Event-Driven System with RabbitMQ"
- Version information
- Date of last update

Remember to:
- Use consistent spacing and alignment
- Critical interaction paths
- Failure scenarios or compensation events if applicable
- Document any assumptions made in the design

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Infrastructure
        RMQ[RabbitMQ Message Broker]:::messagebroker
    end

    subgraph Services
        OS[Order Service<br>Port: 3000]:::service
        click OS "https://github.com/BayajidAlam/saga-flow/tree/main/order-service"
        click OSI "https://github.com/BayajidAlam/saga-flow/blob/main/order-service/src/index.js"
        click OSD "https://github.com/BayajidAlam/saga-flow/tree/main/order-service/Dockerfile"

        IS[Inventory Service]:::service
        click IS "https://github.com/BayajidAlam/saga-flow/tree/main/inventory-service"
        click ISI "https://github.com/BayajidAlam/saga-flow/blob/main/inventory-service/src/index.js"
        click ISD "https://github.com/BayajidAlam/saga-flow/tree/main/inventory-service/Dockerfile"

        PS[Payment Service]:::service
        click PS "https://github.com/BayajidAlam/saga-flow/tree/main/payment-service"
        click PSI "https://github.com/BayajidAlam/saga-flow/blob/main/payment-service/src/index.js"
        click PSD "https://github.com/BayajidAlam/saga-flow/tree/main/payment-service/Dockerfile"

        NS[Notification Service]:::service
        click NS "https://github.com/BayajidAlam/saga-flow/tree/main/notification-service"
        click NSI "https://github.com/BayajidAlam/saga-flow/blob/main/notification-service/src/index.js"
        click NSD "https://github.com/BayajidAlam/saga-flow/tree/main/notification-service/Dockerfile"
    end

    subgraph Docker
        DC[Docker Compose]:::docker
        click DC "https://github.com/BayajidAlam/saga-flow/blob/main/docker-compose.yml"
        CU[Container Utilities]:::docker
        click CU "https://github.com/BayajidAlam/saga-flow/blob/main/stop_and_remove_containers.sh"
    end

    %% Event Flows
    OS -->|OrderCreated| RMQ
    RMQ -->|OrderCreated| IS
    RMQ -->|OrderCreated| PS
    IS -->|InventoryUpdated| RMQ
    RMQ -->|InventoryUpdated| NS
    PS -->|PaymentProcessed| RMQ

    %% Styles
    classDef service fill:#a8d5e5,stroke:#666
    classDef messagebroker fill:#f9d471,stroke:#666
    classDef docker fill:#d3d3d3,stroke:#666

    %% Legend
    subgraph Legend
        L1[Service]:::service
        L2[Message Broker]:::messagebroker
        L3[Docker Component]:::docker
    end
```
