# temporal-sa/temporal-order-fulfill-demo architecture

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

- Interactive diagram: https://gitdiagram.com/temporal-sa/temporal-order-fulfill-demo
- Repository: https://github.com/temporal-sa/temporal-order-fulfill-demo

## Overview

This TypeScript Temporal demo submits sample or generated orders, executes an order-fulfillment workflow, and reports workflow outcomes. The workflow invokes payment, inventory-reservation, and delivery activities; inventory reservation checks the local stock database. A separate worker registers the workflow and activities with Temporal. The README also documents approval and troubleshooting scenarios, but the sampled workflow does not implement those paths; the demo variants are therefore shown as documented scenarios, not as verified runtime calls.

Main entry points: [`src/client.ts`](https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/client.ts) (Workflow client), [`src/worker.ts`](https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/worker.ts) (Temporal worker), [`src/activities.ts`](https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/activities.ts) (Fulfillment activities), [`src/workflows.ts`](https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/workflows.ts) (Fulfillment workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_submission["Order submission"]
  node_client["Workflow client<br/>[client.ts]"]
  node_orders["Order submission<br/>[starter.ts]"]
end

subgraph group_orchestration["Temporal orchestration"]
  node_worker["Temporal worker<br/>[worker.ts]"]
  node_workflow["Fulfillment workflow<br/>[workflows.ts]"]
  node_scenarios["Demo scenarios"]
end

subgraph group_fulfillment["Fulfillment operations"]
  node_activities["Fulfillment activities<br/>[activities.ts]"]
  node_inventory_api["Inventory lookup<br/>[api.ts]"]
end

subgraph group_configuration["Configuration and data"]
  node_order["Order model<br/>[order.ts]"]
  node_stock[("Stock database")]
  node_env["Connection settings<br/>[env.ts]"]
end

node_user(("Operator"))
node_temporal{{"Temporal Server"}}

node_user -->|"starts run"| node_client
node_client -->|"loads settings"| node_env
node_client -->|"submits orders"| node_orders
node_orders -->|"executes workflow"| node_workflow
node_worker -->|"loads settings"| node_env
node_worker -->|"registers workflow"| node_workflow
node_worker -->|"registers activities"| node_activities
node_client -->|"connects to"| node_temporal
node_worker -->|"connects to"| node_temporal
node_orders -->|"starts workflows"| node_temporal
node_workflow -->|"invokes activities"| node_activities
node_activities -->|"reserves inventory"| node_inventory_api
node_inventory_api -->|"reads stock"| node_stock
node_client -->|"builds orders"| node_order
node_activities -->|"accepts orders"| node_order
node_scenarios -->|"documents variants"| node_workflow

click node_client "https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/client.ts"
click node_orders "https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/starter.ts"
click node_order "https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/interfaces/order.ts"
click node_worker "https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/worker.ts"
click node_workflow "https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/workflows.ts"
click node_activities "https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/activities.ts"
click node_inventory_api "https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/api.ts"
click node_stock "https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/data/stock_database.json"
click node_env "https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/interfaces/env.ts"
click node_scenarios "https://github.com/temporal-sa/temporal-order-fulfill-demo/tree/main/demo"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client,node_orders toneBlue
class node_worker,node_workflow,node_scenarios toneAmber
class node_activities,node_inventory_api,node_temporal toneMint
class node_order,node_stock,node_env toneRose
class node_user toneIndigo
```

## Components

### Order submission

- [Workflow client](https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/client.ts): `src/client.ts`
- [Order submission](https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/starter.ts): `src/starter.ts`

### Temporal orchestration

- [Temporal worker](https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/worker.ts): `src/worker.ts`
- [Fulfillment workflow](https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/workflows.ts): `src/workflows.ts`
- [Demo scenarios](https://github.com/temporal-sa/temporal-order-fulfill-demo/tree/main/demo): `demo`

### Fulfillment operations

- [Fulfillment activities](https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/activities.ts): `src/activities.ts`
- [Inventory lookup](https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/api.ts): `src/api.ts`

### Configuration and data

- [Order model](https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/interfaces/order.ts): `src/interfaces/order.ts`
- [Stock database](https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/data/stock_database.json): `data/stock_database.json`
- [Connection settings](https://github.com/temporal-sa/temporal-order-fulfill-demo/blob/main/src/interfaces/env.ts): `src/interfaces/env.ts`

### Other components

- **Operator**
- **Temporal Server**

## Connections

- Operator → Workflow client: starts run (evidence: `README.md`)
- Workflow client → Connection settings: loads settings (evidence: `src/client.ts`)
- Workflow client → Order submission: submits orders (evidence: `src/client.ts`)
- Order submission → Fulfillment workflow: executes workflow (evidence: `src/starter.ts`)
- Temporal worker → Connection settings: loads settings (evidence: `src/worker.ts`)
- Temporal worker → Fulfillment workflow: registers workflow (evidence: `src/worker.ts`)
- Temporal worker → Fulfillment activities: registers activities (evidence: `src/worker.ts`)
- Workflow client → Temporal Server: connects to (evidence: `src/client.ts`)
- Temporal worker → Temporal Server: connects to (evidence: `src/worker.ts`)
- Order submission → Temporal Server: starts workflows (evidence: `src/starter.ts`)
- Fulfillment workflow → Fulfillment activities: invokes activities (evidence: `src/workflows.ts`)
- Fulfillment activities → Inventory lookup: reserves inventory (evidence: `src/activities.ts`)
- Inventory lookup → Stock database: reads stock (evidence: `src/api.ts`)
- Workflow client → Order model: builds orders (evidence: `src/client.ts`)
- Fulfillment activities → Order model: accepts orders (evidence: `src/activities.ts`)
- Demo scenarios → Fulfillment workflow: documents variants (evidence: `README.md`)
