# iblazhko/temporal-processmanager architecture

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

- Interactive diagram: https://gitdiagram.com/iblazhko/temporal-processmanager
- Repository: https://github.com/iblazhko/temporal-processmanager

## Overview

##### Project type and purpose
- This is a .NET-9, Docker-composed, distributed microservices system that uses Temporal.io as the durable execution engine.
- Purpose: implement a long-running shipment process (classification, orchestration, manifestation, document generation, collection booking, carrier integration) with reliability, retries, timeouts, and observability handled by Temporal.

##### File structure
- Top‐level “src” folder contains five service hosts, each paired with a Temporal worker project:
- ProcessOrchestrator.Host & ProcessOrchestrator.Temporal
- CarrierIntegration.Host & CarrierIntegration.Temporal
- CollectionBooking.Host & CollectionBooking.Temporal
- DocumentsGeneration.Host & DocumentsGeneration.Temporal
- Manifestation.Host & Manifestation.Temporal
- SharedInfrastructure and SharedKernel libraries provide cross‐cutting configuration, DTOs, domain models, and settings.
- docker-compose.yaml & temporal-dynamicconfig define the Temporal server cluster, UI, and Postgres persistence.

##### README for additional insights
- Five hosts map to five worker services, each listening on a dedicated Temporal task queue.
- ProcessOrchestrator receives incoming HTTP POST /{shipmentId}, then starts the “entry point” workflow.
- The orchestrator workflow calls child workflows in other task queues (manifestation, docs, collection booking, carrier integration).
- Temporal server persists workflow state and history in Postgres and exposes a Web UI & gRPC API.

##### Diagramming conventions and elements
- Client → ProcessOrchestrator.Host (HTTP POST)
- Host → Temporal Cluster (gRPC Start/Signal).
- Temporal Cluster → Worker (“poll & task delivery”).
- Worker → Temporal Cluster (“task complete”).
- “Client” lane
- “Application Hosts” lane
- “Temporal Infrastructure” lane
- “External Systems” lane
- Flows with brief labels (“StartWorkflow”, “PollTaskQueue”, “ExecuteActivity”, “ReturnResult”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Swimlanes
    subgraph "Client" 
        direction TB
        Client["Client"]:::external
    end

    subgraph "Application Hosts" 
        direction TB
        POHost["ProcessOrchestrator.Host\n(queue: ProcessOrchestrator)"]:::host
        MIHost["Manifestation.Host\n(queue: Manifestation)"]:::host
        DGHost["DocumentsGeneration.Host\n(queue: DocumentsGeneration)"]:::host
        CBHost["CollectionBooking.Host\n(queue: CollectionBooking)"]:::host
        CIHost["CarrierIntegration.Host\n(queue: CarrierIntegration)"]:::host
    end

    subgraph "Temporal Workers" 
        direction TB
        POWorker["ProcessOrchestrator.Temporal\n(queue: ProcessOrchestrator)"]:::worker
        MIWorker["Manifestation.Temporal\n(queue: Manifestation)"]:::worker
        DGWorker["DocumentsGeneration.Temporal\n(queue: DocumentsGeneration)"]:::worker
        CBWorker["CollectionBooking.Temporal\n(queue: CollectionBooking)"]:::worker
        CIWorker["CarrierIntegration.Temporal\n(queue: CarrierIntegration)"]:::worker
    end

    subgraph "Temporal Infrastructure" 
        direction TB
        subgraph "Temporal Cluster"
            direction TB
            Frontend["Frontend Service"]:::infra
            Matching["Matching Service"]:::infra
            History["History Service"]:::infra
            WebUI["Temporal Web UI"]:::infra
        end
        DB["PostgreSQL Persistence"]:::infra
    end

    subgraph "External Systems"
        direction TB
        CarrierAPI["Carrier REST APIs"]:::external
    end

    %% Flows
    Client -->|"HTTP POST /{shipmentId}"| POHost
    POHost -->|"StartWorkflow (gRPC)"| Frontend
    Frontend -->|"Writes state"| DB
    Matching -->|"Dispatch tasks"| POWorker
    POWorker -->|"PollTaskQueue"| Matching
    POWorker -->|"Schedule ChildWorkflows"| Frontend
    POWorker -->|"ReturnResult"| Frontend
    Frontend -->|"Persist events"| History

    %% Orchestrator to child queues
    POWorker -->|"ChildWorkflow: Manifestation"| MIWorker
    POWorker -->|"ChildWorkflow: DocumentsGeneration"| DGWorker
    POWorker -->|"ChildWorkflow: CollectionBooking"| CBWorker
    POWorker -->|"ChildWorkflow: CarrierIntegration"| CIWorker

    %% Workers polling and completing
    MIWorker -->|"PollTaskQueue / ExecuteActivity"| Matching
    MIWorker -->|"ReturnResult"| Frontend
    DGWorker -->|"PollTaskQueue / ExecuteActivity"| Matching
    DGWorker -->|"ReturnResult"| Frontend
    CBWorker -->|"PollTaskQueue / ExecuteActivity"| Matching
    CBWorker -->|"ReturnResult"| Frontend
    CIWorker -->|"PollTaskQueue / ExecuteActivity"| Matching
    CIWorker -->|"ReturnResult"| Frontend
    CIWorker -.->|"Invoke Activities"| CarrierAPI

    %% Shared libraries usage
    POHost --> SharedInfra
    MIHost --> SharedInfra
    DGHost --> SharedInfra
    CBHost --> SharedInfra
    CIHost --> SharedInfra
    POWorker --> SharedInfra
    MIWorker --> SharedInfra
    DGWorker --> SharedInfra
    CBWorker --> SharedInfra
    CIWorker --> SharedInfra

    POHost --> SharedKernel
    MIHost --> SharedKernel
    DGHost --> SharedKernel
    CBHost --> SharedKernel
    CIHost --> SharedKernel
    POWorker --> SharedKernel
    MIWorker --> SharedKernel
    DGWorker --> SharedKernel
    CBWorker --> SharedKernel
    CIWorker --> SharedKernel

    %% Click Events
    click POHost "https://github.com/iblazhko/temporal-processmanager/blob/main/src/ProcessOrchestrator.Host"
    click POWorker "https://github.com/iblazhko/temporal-processmanager/blob/main/src/ProcessOrchestrator.Temporal"
    click MIHost "https://github.com/iblazhko/temporal-processmanager/blob/main/src/Manifestation.Host"
    click MIWorker "https://github.com/iblazhko/temporal-processmanager/blob/main/src/Manifestation.Temporal"
    click DGHost "https://github.com/iblazhko/temporal-processmanager/blob/main/src/DocumentsGeneration.Host"
    click DGWorker "https://github.com/iblazhko/temporal-processmanager/blob/main/src/DocumentsGeneration.Temporal"
    click CBHost "https://github.com/iblazhko/temporal-processmanager/blob/main/src/CollectionBooking.Host"
    click CBWorker "https://github.com/iblazhko/temporal-processmanager/blob/main/src/CollectionBooking.Temporal"
    click CIHost "https://github.com/iblazhko/temporal-processmanager/blob/main/src/CarrierIntegration.Host"
    click CIWorker "https://github.com/iblazhko/temporal-processmanager/blob/main/src/CarrierIntegration.Temporal"
    click SharedInfra "https://github.com/iblazhko/temporal-processmanager/tree/main/src/SharedInfrastructure"
    click SharedKernel "https://github.com/iblazhko/temporal-processmanager/tree/main/src/SharedKernel"
    click DB "https://github.com/iblazhko/temporal-processmanager/blob/main/docker-compose.yaml"

    %% Styles
    classDef host fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef worker fill:#FFE8C0,stroke:#333,stroke-width:1px
    classDef infra fill:#DFFFE0,stroke:#333,stroke-width:1px
    classDef external fill:#F0F0F0,stroke:#333,stroke-width:1px
```
