# joysydney/o2c-event-pipeline architecture

> Architecture diagram of the GitHub repository joysydney/o2c-event-pipeline, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joysydney/o2c-event-pipeline
- Repository: https://github.com/joysydney/o2c-event-pipeline

## Overview

This is an event-driven Order-to-Cash integration pipeline: ERP orders enter through an idempotent API, then move through warehouse fulfillment, carrier delivery, and three-way financial reconciliation. A transactional outbox relay publishes durable events; inbox idempotency, broker dead-letter handling, and reconciliation holds protect against failures and billing discrepancies. The dashboard exposes operational KPIs, orders, and exceptions. Some subsystem details are documented in the README but not sampled; those links are omitted where source evidence does not establish a call.

Main entry points: [`app/main.py`](https://github.com/joysydney/o2c-event-pipeline/blob/main/app/main.py) (Order API), [`app/outbox_relay.py`](https://github.com/joysydney/o2c-event-pipeline/blob/main/app/outbox_relay.py) (Outbox Relay), [`app/logging_config.py`](https://github.com/joysydney/o2c-event-pipeline/blob/main/app/logging_config.py) (Structured Logging), [`app/broker.py`](https://github.com/joysydney/o2c-event-pipeline/blob/main/app/broker.py) (Event Broker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Order Ingestion"]
  node_api["Order API<br/>[main.py]"]
  node_schemas["Order Schemas<br/>[schemas.py]"]
  node_outbox["Outbox Relay<br/>[outbox_relay.py]"]
  node_db[("Order Database<br/>[init.sql]")]
end

subgraph group_fulfillment["Fulfillment Events"]
  node_broker["Event Broker<br/>[broker.py]"]
  node_wms["WMS Simulator<br/>[wms_simulator.py]"]
  node_carrier["Carrier Simulator"]
end

subgraph group_finance["Reconciliation"]
  node_reconcile["Reconciliation Worker"]
end

subgraph group_operations["Operations"]
  node_dashboard["Executive Dashboard<br/>[dashboard.py]"]
  node_dlq["Dead-Letter Manager<br/>[dlq_manager.py]"]
  node_logging["Structured Logging<br/>[logging_config.py]"]
end

node_erp(("ERP Client"))

node_erp -->|"submits orders"| node_api
node_api -->|"validates payload"| node_schemas
node_api -->|"writes orders"| node_db
node_api -->|"records events"| node_outbox
node_outbox -->|"claims events"| node_db
node_outbox -->|"publishes events"| node_broker
node_broker -->|"routes orders"| node_wms
node_wms -->|"records shipments"| node_db
node_wms -->|"records shipment event"| node_outbox
node_broker -->|"routes shipments"| node_carrier
node_carrier -->|"records deliveries"| node_db
node_carrier -->|"records delivery event"| node_outbox
node_broker -->|"routes delivery events"| node_reconcile
node_reconcile -->|"matches and invoices"| node_db
node_dashboard -->|"fetches KPIs and orders"| node_api
node_api -->|"serves dashboard"| node_dashboard
node_dlq -->|"inspects or replays"| node_broker
node_api -->|"configures logging"| node_logging
node_outbox -->|"configures logging"| node_logging
node_wms -->|"configures logging"| node_logging
node_carrier -->|"configures logging"| node_logging
node_reconcile -->|"configures logging"| node_logging
node_dlq -->|"configures logging"| node_logging

click node_api "https://github.com/joysydney/o2c-event-pipeline/blob/main/app/main.py"
click node_schemas "https://github.com/joysydney/o2c-event-pipeline/blob/main/app/schemas.py"
click node_outbox "https://github.com/joysydney/o2c-event-pipeline/blob/main/app/outbox_relay.py"
click node_db "https://github.com/joysydney/o2c-event-pipeline/blob/main/db/init.sql"
click node_broker "https://github.com/joysydney/o2c-event-pipeline/blob/main/app/broker.py"
click node_wms "https://github.com/joysydney/o2c-event-pipeline/blob/main/app/wms_simulator.py"
click node_carrier "https://github.com/joysydney/o2c-event-pipeline/blob/main/app/carrier_simulator.py"
click node_reconcile "https://github.com/joysydney/o2c-event-pipeline/blob/main/app/reconciliation_worker.py"
click node_dashboard "https://github.com/joysydney/o2c-event-pipeline/blob/main/app/dashboard.py"
click node_dlq "https://github.com/joysydney/o2c-event-pipeline/blob/main/app/dlq_manager.py"
click node_logging "https://github.com/joysydney/o2c-event-pipeline/blob/main/app/logging_config.py"

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_api,node_schemas,node_outbox,node_db,node_erp toneBlue
class node_broker,node_wms,node_carrier toneAmber
class node_reconcile toneMint
class node_dashboard,node_dlq,node_logging toneRose
```

## Components

### Order Ingestion

- [Order API](https://github.com/joysydney/o2c-event-pipeline/blob/main/app/main.py): `app/main.py`
- [Order Schemas](https://github.com/joysydney/o2c-event-pipeline/blob/main/app/schemas.py): `app/schemas.py`
- [Outbox Relay](https://github.com/joysydney/o2c-event-pipeline/blob/main/app/outbox_relay.py): `app/outbox_relay.py`
- [Order Database](https://github.com/joysydney/o2c-event-pipeline/blob/main/db/init.sql): `db/init.sql`

### Fulfillment Events

- [Event Broker](https://github.com/joysydney/o2c-event-pipeline/blob/main/app/broker.py): `app/broker.py`
- [WMS Simulator](https://github.com/joysydney/o2c-event-pipeline/blob/main/app/wms_simulator.py): `app/wms_simulator.py`
- [Carrier Simulator](https://github.com/joysydney/o2c-event-pipeline/blob/main/app/carrier_simulator.py): `app/carrier_simulator.py`

### Reconciliation

- [Reconciliation Worker](https://github.com/joysydney/o2c-event-pipeline/blob/main/app/reconciliation_worker.py): `app/reconciliation_worker.py`

### Operations

- [Executive Dashboard](https://github.com/joysydney/o2c-event-pipeline/blob/main/app/dashboard.py): `app/dashboard.py`
- [Dead-Letter Manager](https://github.com/joysydney/o2c-event-pipeline/blob/main/app/dlq_manager.py): `app/dlq_manager.py`
- [Structured Logging](https://github.com/joysydney/o2c-event-pipeline/blob/main/app/logging_config.py): `app/logging_config.py`

### Other components

- **ERP Client**

## Connections

- ERP Client → Order API: submits orders (evidence: `README.md`)
- Order API → Order Schemas: validates payload (evidence: `app/main.py`)
- Order API → Order Database: writes orders (evidence: `app/main.py`)
- Order API → Outbox Relay: records events (evidence: `app/main.py`)
- Outbox Relay → Order Database: claims events (evidence: `app/outbox_relay.py`)
- Outbox Relay → Event Broker: publishes events (evidence: `app/outbox_relay.py`)
- Event Broker → WMS Simulator: routes orders (evidence: `app/broker.py`)
- WMS Simulator → Order Database: records shipments (evidence: `app/wms_simulator.py`)
- WMS Simulator → Outbox Relay: records shipment event (evidence: `app/wms_simulator.py`)
- Event Broker → Carrier Simulator: routes shipments (evidence: `app/broker.py`)
- Carrier Simulator → Order Database: records deliveries (evidence: `app/carrier_simulator.py`)
- Carrier Simulator → Outbox Relay: records delivery event (evidence: `app/carrier_simulator.py`)
- Event Broker → Reconciliation Worker: routes delivery events (evidence: `app/broker.py`)
- Reconciliation Worker → Order Database: matches and invoices (evidence: `app/reconciliation_worker.py`)
- Executive Dashboard → Order API: fetches KPIs and orders (evidence: `app/dashboard.py`)
- Order API → Executive Dashboard: serves dashboard (evidence: `app/main.py`)
- Dead-Letter Manager → Event Broker: inspects or replays (evidence: `app/dlq_manager.py`)
- Order API → Structured Logging: configures logging (evidence: `app/main.py`)
- Outbox Relay → Structured Logging: configures logging (evidence: `app/outbox_relay.py`)
- WMS Simulator → Structured Logging: configures logging (evidence: `app/wms_simulator.py`)
- Carrier Simulator → Structured Logging: configures logging (evidence: `app/carrier_simulator.py`)
- Reconciliation Worker → Structured Logging: configures logging (evidence: `app/reconciliation_worker.py`)
- Dead-Letter Manager → Structured Logging: configures logging (evidence: `app/dlq_manager.py`)
