# nzuguem/quarkus-temporal-petstore architecture

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

- Interactive diagram: https://gitdiagram.com/nzuguem/quarkus-temporal-petstore
- Repository: https://github.com/nzuguem/quarkus-temporal-petstore

## Overview

##### Main Components

a. Client Layer:
- Web UI (Purchase Order Gateway - Port 8082)
- REST API endpoints

b. Microservices:
- Purchase Order Gateway Service (Workflow Orchestrator)
- Notification Service
- Order Service
- Payment Service
- Warehouse Service
- Shipment Service

c. Infrastructure Components:
- Temporal Server
- PostgreSQL Database
- Mailpit (SMTP Server)
- Jaeger (Distributed Tracing)

**┌─ Client Layer ─────────────────────────────────┐**
- Web UI (JSF) │ REST API                        │
- Service Layer ──────────────────────────────┐ │

- ┌─────────────┐  ┌─────────────┐            │ │
- Purchase   │  │ Notification │            │ │
- Gateway   │──▶   Service   │            │ │
- ┘  └─────────────┘            │ │

- ┌─────────────┐            │ │
- ▶│   Order     │            │ │
- Service    │            │ │
- ┘            │ │

- ┌─────────────┐            │ │
- ▶│  Payment    │            │ │
- Service    │            │ │
- ┘            │ │

- ┌─────────────┐            │ │
- ▶│ Warehouse   │            │ │
- Service    │            │ │
- ┘            │ │

- ┌─────────────┐            │ │
- ▶│  Shipment   │            │ │
- Service    │            │ │
- ┘            │ │
- Infrastructure Layer ────────────────────────┤

- ┌─────────┐ ┌────────┐ ┌───────┐ ┌────────┐ │
- Temporal │ │Postgres│ │Mailpit│ │ Jaeger │ │
- ┘ └────────┘ └───────┘ └────────┘ │
- ┘

##### Important Workflow Patterns to Highlight

- Main workflow path:
1. Order Submission → Gateway
2. Notification (Order Received)
3. Order Creation
4. Payment Processing
5. Inventory Check
6. Shipment Creation
7. Order Completion
8. Final Notification

- Compensation workflow:
1. Error Detection
2. Payment Reversal
3. Order Status Update
4. Error Notification

##### Additional Elements

- Port numbers for each service
- Temporal workflow boundaries
- Error handling paths
- Monitoring points for Jaeger tracing

##### Technical Details

- Quarkus Framework indicators
- Temporal workflow boundaries
- Database connections
- Email notification paths
- REST endpoint locations
- OpenTelemetry integration points

##### Notes for Implementation

- Keep the main workflow path clear and central
- Related services together
- Clear boundaries between layers
- External integration points
- Critical transaction boundaries
- Where compensating transactions occur

Remember to maintain a balance between detail and clarity, focusing on the key architectural components while ensuring the workflow patterns are easily understood.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef client fill:#b3d1ff,stroke:#333,stroke-width:2px
    classDef service fill:#90EE90,stroke:#333,stroke-width:2px
    classDef infrastructure fill:#FFB366,stroke:#333,stroke-width:2px
    classDef database fill:#FFB366,stroke:#333,stroke-width:2px,shape:cylinder
    classDef api fill:#b3d1ff,stroke:#333,stroke-width:2px
    
    %% Client Layer
    subgraph ClientLayer
        WebUI["Web UI (Port 8082)"]:::client
        RestAPI["REST API Endpoints"]:::api
    end
    click WebUI "https://github.com/nzuguem/quarkus-temporal-petstore/blob/main/purchase-order-gateway/src/main/resources/META-INF/resources/index.xhtml"
    
    %% Service Layer
    subgraph ServiceLayer
        POGateway["Purchase Order Gateway"]:::service
        NotifService["Notification Service"]:::service
        OrderService["Order Service"]:::service
        PaymentService["Payment Service"]:::service
        WarehouseService["Warehouse Service"]:::service
        ShipmentService["Shipment Service"]:::service
    end
    click POGateway "https://github.com/nzuguem/quarkus-temporal-petstore/blob/main/purchase-order-gateway/src/main/java/com/melloware/petstore/order/gateway/temporal/PurchaseOrderWorkflow.java"
    click NotifService "https://github.com/nzuguem/quarkus-temporal-petstore/blob/main/notification-service/src/main/java/com/melloware/petstore/notification/temporal/NotificationService.java"
    click OrderService "https://github.com/nzuguem/quarkus-temporal-petstore/blob/main/order-service/src/main/java/com/melloware/petstore/order/temporal/OrderService.java"
    click PaymentService "https://github.com/nzuguem/quarkus-temporal-petstore/blob/main/payment-service/src/main/java/com/melloware/petstore/payment/temporal/PaymentService.java"
    click WarehouseService "https://github.com/nzuguem/quarkus-temporal-petstore/blob/main/warehouse-service/src/main/java/com/melloware/petstore/warehouse/temporal/WarehouseService.java"
    click ShipmentService "https://github.com/nzuguem/quarkus-temporal-petstore/blob/main/shipment-service/src/main/java/com/melloware/petstore/shipment/temporal/ShipperService.java"
    
    %% Infrastructure Layer
    subgraph InfraLayer
        Temporal["Temporal Server"]:::infrastructure
        PostgreSQL[(PostgreSQL)]:::database
        Mailpit["Mailpit SMTP"]:::infrastructure
        Jaeger["Jaeger Tracing"]:::infrastructure
    end
    click Temporal "https://github.com/nzuguem/quarkus-temporal-petstore/blob/main/docker-compose/docker-compose.yml"
    
    %% Common Components
    CommonLib["Temporal Common Library"]:::service
    click CommonLib "https://github.com/nzuguem/quarkus-temporal-petstore/tree/main/temporal-common/src/main/java/com/melloware/petstore/common/activities/"
    
    %% Relationships
    WebUI --> RestAPI
    RestAPI --> POGateway
    
    POGateway --> NotifService
    POGateway --> OrderService
    POGateway --> PaymentService
    POGateway --> WarehouseService
    POGateway --> ShipmentService
    
    NotifService --> Mailpit
    OrderService --> PostgreSQL
    PaymentService --> PostgreSQL
    WarehouseService --> PostgreSQL
    ShipmentService --> PostgreSQL
    
    POGateway --> Temporal
    NotifService --> Temporal
    OrderService --> Temporal
    PaymentService --> Temporal
    WarehouseService --> Temporal
    ShipmentService --> Temporal
    
    CommonLib -.-> POGateway
    CommonLib -.-> NotifService
    CommonLib -.-> OrderService
    CommonLib -.-> PaymentService
    CommonLib -.-> WarehouseService
    CommonLib -.-> ShipmentService
    
    %% Monitoring
    POGateway -.-> Jaeger
    NotifService -.-> Jaeger
    OrderService -.-> Jaeger
    PaymentService -.-> Jaeger
    WarehouseService -.-> Jaeger
    ShipmentService -.-> Jaeger
```
