# darshsoam07/failurelab architecture

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

- Interactive diagram: https://gitdiagram.com/darshsoam07/failurelab
- Repository: https://github.com/darshsoam07/failurelab

## Overview

FailureLab is an AI-assisted reliability-experiment platform. An SRE uses the dashboard to launch or stop an experiment; the controller injects a downstream fault, drives or monitors traffic, and enforces SLO guardrails. Orders travel through an outbox and broker to fulfillment and inventory, while telemetry and experiment state are persisted. After completion or abort, the AI worker analyzes the recorded timeline and stores a report for the dashboard. The README documents the principal service links; some internal controller and worker details are unsampled, so the graph avoids asserting unshown calls.

Main entry points: [`services/experiment_controller/main.py`](https://github.com/darshsoam07/failurelab/blob/main/services/experiment_controller/main.py) (Experiment controller), [`services/frontend/src/App.jsx`](https://github.com/darshsoam07/failurelab/blob/main/services/frontend/src/App.jsx) (React dashboard), [`services/fulfillment_worker/worker.py`](https://github.com/darshsoam07/failurelab/blob/main/services/fulfillment_worker/worker.py) (Fulfillment worker), [`services/frontend/src/api/client.js`](https://github.com/darshsoam07/failurelab/blob/main/services/frontend/src/api/client.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Dashboard"]
  node_dashboard["React dashboard<br/>[App.jsx]"]
  node_api_client["API client<br/>[client.js]"]
  node_launcher["Experiment launcher"]
  node_telemetry["Live telemetry"]
  node_history["History and reports"]
  node_polling["Polling hook<br/>[usePolling.js]"]
  node_topology["Topology view<br/>[TopologyBanner.jsx]"]
end

subgraph group_control["Experiment control"]
  node_controller["Experiment controller<br/>[main.py]"]
  node_watchdog["SLO watchdog<br/>[watchdog.py]"]
  node_traffic["Traffic generator<br/>[traffic_gen.py]"]
  node_toxiclient["Toxiproxy client"]
end

subgraph group_commerce["Order fulfillment"]
  node_order_api["Order API<br/>[main.py]"]
  node_outbox["Outbox relay<br/>[outbox_relay.py]"]
  node_fulfillment["Fulfillment worker<br/>[worker.py]"]
  node_resilience["Retries and breaker<br/>[resilience.py]"]
  node_inventory["Inventory service<br/>[main.py]"]
end

subgraph group_analysis["AI analysis"]
  node_ai_worker["AI analysis worker<br/>[main.py]"]
  node_analyzer["Report analyzer<br/>[analyzer.py]"]
  node_prompts["Analysis prompts<br/>[prompts.py]"]
end

subgraph group_shared["Shared data contracts"]
  node_models["Persistence models<br/>[models.py]"]
  node_schemas["API and event schemas<br/>[schemas.py]"]
  node_db_runtime["Database runtime<br/>[database.py]"]
  node_consumer["AMQP consumer supervisor<br/>[consumer.py]"]
  node_config["Shared configuration<br/>[config.py]"]
end

node_sre(("SRE"))
node_toxiproxy["Toxiproxy"]
node_rabbit["RabbitMQ"]
node_llm["LLM provider"]
node_database[("PostgreSQL")]

node_sre -->|"uses"| node_dashboard
node_dashboard -->|"renders"| node_launcher
node_dashboard -->|"renders"| node_telemetry
node_dashboard -->|"renders"| node_history
node_dashboard -->|"renders"| node_topology
node_launcher -->|"requests"| node_api_client
node_history -->|"requests"| node_api_client
node_telemetry -->|"requests"| node_api_client
node_dashboard -->|"polls with"| node_polling
node_api_client -->|"controls experiments"| node_controller
node_api_client -->|"fetches metrics"| node_order_api
node_controller -->|"configures traffic"| node_traffic
node_controller -->|"monitors SLOs"| node_watchdog
node_controller -->|"manages faults"| node_toxiclient
node_toxiclient -->|"injects faults"| node_toxiproxy
node_controller -->|"polls metrics"| node_order_api
node_controller -->|"stores experiment state"| node_database
node_controller -->|"publishes analysis event"| node_rabbit
node_traffic -->|"generates orders"| node_order_api
node_order_api -->|"writes order and outbox"| node_database
node_outbox -->|"reads pending events"| node_database
node_outbox -->|"publishes fulfillment"| node_rabbit
node_rabbit -->|"delivers events"| node_fulfillment
node_fulfillment -->|"reserves stock"| node_inventory
node_fulfillment -->|"calls through proxy"| node_toxiproxy
node_fulfillment -->|"records outcome"| node_database
node_fulfillment -->|"uses retry and breaker"| node_resilience
node_inventory -->|"records reservation"| node_database
node_inventory -->|"stores idempotency"| node_database
node_rabbit -->|"delivers analysis event"| node_ai_worker
node_ai_worker -->|"reads timeline and saves report"| node_database
node_ai_worker -->|"analyzes experiment"| node_analyzer
node_analyzer -->|"uses prompts"| node_prompts
node_analyzer -.->|"requests analysis"| node_llm
node_db_runtime -->|"opens sessions"| node_database
node_db_runtime -->|"loads settings"| node_config
node_models -->|"defines tables"| node_database
node_schemas -->|"uses domain enums"| node_models
node_consumer -->|"supervises consumers"| node_rabbit

click node_dashboard "https://github.com/darshsoam07/failurelab/blob/main/services/frontend/src/App.jsx"
click node_api_client "https://github.com/darshsoam07/failurelab/blob/main/services/frontend/src/api/client.js"
click node_launcher "https://github.com/darshsoam07/failurelab/blob/main/services/frontend/src/components/ExperimentLauncher.jsx"
click node_telemetry "https://github.com/darshsoam07/failurelab/blob/main/services/frontend/src/components/LiveTelemetryPanel.jsx"
click node_history "https://github.com/darshsoam07/failurelab/blob/main/services/frontend/src/components/ExperimentHistoryAndAIReport.jsx"
click node_polling "https://github.com/darshsoam07/failurelab/blob/main/services/frontend/src/hooks/usePolling.js"
click node_topology "https://github.com/darshsoam07/failurelab/blob/main/services/frontend/src/components/TopologyBanner.jsx"
click node_controller "https://github.com/darshsoam07/failurelab/blob/main/services/experiment_controller/main.py"
click node_watchdog "https://github.com/darshsoam07/failurelab/blob/main/services/experiment_controller/watchdog.py"
click node_traffic "https://github.com/darshsoam07/failurelab/blob/main/services/experiment_controller/traffic_gen.py"
click node_toxiclient "https://github.com/darshsoam07/failurelab/blob/main/services/experiment_controller/toxiproxy_client.py"
click node_order_api "https://github.com/darshsoam07/failurelab/blob/main/services/order_api/main.py"
click node_outbox "https://github.com/darshsoam07/failurelab/blob/main/services/order_api/outbox_relay.py"
click node_fulfillment "https://github.com/darshsoam07/failurelab/blob/main/services/fulfillment_worker/worker.py"
click node_resilience "https://github.com/darshsoam07/failurelab/blob/main/services/fulfillment_worker/resilience.py"
click node_inventory "https://github.com/darshsoam07/failurelab/blob/main/services/inventory_service/main.py"
click node_ai_worker "https://github.com/darshsoam07/failurelab/blob/main/services/ai_worker/main.py"
click node_analyzer "https://github.com/darshsoam07/failurelab/blob/main/services/ai_worker/analyzer.py"
click node_prompts "https://github.com/darshsoam07/failurelab/blob/main/services/ai_worker/prompts.py"
click node_models "https://github.com/darshsoam07/failurelab/blob/main/services/common/models.py"
click node_schemas "https://github.com/darshsoam07/failurelab/blob/main/services/common/schemas.py"
click node_db_runtime "https://github.com/darshsoam07/failurelab/blob/main/services/common/database.py"
click node_consumer "https://github.com/darshsoam07/failurelab/blob/main/services/common/consumer.py"
click node_config "https://github.com/darshsoam07/failurelab/blob/main/services/common/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_dashboard,node_api_client,node_launcher,node_telemetry,node_history,node_polling,node_topology toneBlue
class node_controller,node_watchdog,node_traffic,node_toxiclient,node_database toneAmber
class node_order_api,node_outbox,node_fulfillment,node_resilience,node_inventory toneMint
class node_ai_worker,node_analyzer,node_prompts toneRose
class node_models,node_schemas,node_db_runtime,node_consumer,node_config,node_sre,node_toxiproxy,node_rabbit,node_llm toneIndigo
```

## Components

### Dashboard

- [React dashboard](https://github.com/darshsoam07/failurelab/blob/main/services/frontend/src/App.jsx): `services/frontend/src/App.jsx`
- [API client](https://github.com/darshsoam07/failurelab/blob/main/services/frontend/src/api/client.js): `services/frontend/src/api/client.js`
- [Experiment launcher](https://github.com/darshsoam07/failurelab/blob/main/services/frontend/src/components/ExperimentLauncher.jsx): `services/frontend/src/components/ExperimentLauncher.jsx`
- [Live telemetry](https://github.com/darshsoam07/failurelab/blob/main/services/frontend/src/components/LiveTelemetryPanel.jsx): `services/frontend/src/components/LiveTelemetryPanel.jsx`
- [History and reports](https://github.com/darshsoam07/failurelab/blob/main/services/frontend/src/components/ExperimentHistoryAndAIReport.jsx): `services/frontend/src/components/ExperimentHistoryAndAIReport.jsx`
- [Polling hook](https://github.com/darshsoam07/failurelab/blob/main/services/frontend/src/hooks/usePolling.js): `services/frontend/src/hooks/usePolling.js`
- [Topology view](https://github.com/darshsoam07/failurelab/blob/main/services/frontend/src/components/TopologyBanner.jsx): `services/frontend/src/components/TopologyBanner.jsx`

### Experiment control

- [Experiment controller](https://github.com/darshsoam07/failurelab/blob/main/services/experiment_controller/main.py): `services/experiment_controller/main.py`
- [SLO watchdog](https://github.com/darshsoam07/failurelab/blob/main/services/experiment_controller/watchdog.py): `services/experiment_controller/watchdog.py`
- [Traffic generator](https://github.com/darshsoam07/failurelab/blob/main/services/experiment_controller/traffic_gen.py): `services/experiment_controller/traffic_gen.py`
- [Toxiproxy client](https://github.com/darshsoam07/failurelab/blob/main/services/experiment_controller/toxiproxy_client.py): `services/experiment_controller/toxiproxy_client.py`

### Order fulfillment

- [Order API](https://github.com/darshsoam07/failurelab/blob/main/services/order_api/main.py): `services/order_api/main.py`
- [Outbox relay](https://github.com/darshsoam07/failurelab/blob/main/services/order_api/outbox_relay.py): `services/order_api/outbox_relay.py`
- [Fulfillment worker](https://github.com/darshsoam07/failurelab/blob/main/services/fulfillment_worker/worker.py): `services/fulfillment_worker/worker.py`
- [Retries and breaker](https://github.com/darshsoam07/failurelab/blob/main/services/fulfillment_worker/resilience.py): `services/fulfillment_worker/resilience.py`
- [Inventory service](https://github.com/darshsoam07/failurelab/blob/main/services/inventory_service/main.py): `services/inventory_service/main.py`

### AI analysis

- [AI analysis worker](https://github.com/darshsoam07/failurelab/blob/main/services/ai_worker/main.py): `services/ai_worker/main.py`
- [Report analyzer](https://github.com/darshsoam07/failurelab/blob/main/services/ai_worker/analyzer.py): `services/ai_worker/analyzer.py`
- [Analysis prompts](https://github.com/darshsoam07/failurelab/blob/main/services/ai_worker/prompts.py): `services/ai_worker/prompts.py`

### Shared data contracts

- [Persistence models](https://github.com/darshsoam07/failurelab/blob/main/services/common/models.py): `services/common/models.py`
- [API and event schemas](https://github.com/darshsoam07/failurelab/blob/main/services/common/schemas.py): `services/common/schemas.py`
- [Database runtime](https://github.com/darshsoam07/failurelab/blob/main/services/common/database.py): `services/common/database.py`
- [AMQP consumer supervisor](https://github.com/darshsoam07/failurelab/blob/main/services/common/consumer.py): `services/common/consumer.py`
- [Shared configuration](https://github.com/darshsoam07/failurelab/blob/main/services/common/config.py): `services/common/config.py`

### Other components

- **SRE**
- **Toxiproxy**
- **RabbitMQ**
- **LLM provider**
- **PostgreSQL**

## Connections

- SRE → React dashboard: uses (evidence: `README.md`)
- React dashboard → Experiment launcher: renders (evidence: `services/frontend/src/App.jsx`)
- React dashboard → Live telemetry: renders (evidence: `services/frontend/src/App.jsx`)
- React dashboard → History and reports: renders (evidence: `services/frontend/src/App.jsx`)
- React dashboard → Topology view: renders (evidence: `services/frontend/src/App.jsx`)
- Experiment launcher → API client: requests (evidence: `services/frontend/src/components/ExperimentLauncher.jsx`)
- History and reports → API client: requests (evidence: `services/frontend/src/components/ExperimentHistoryAndAIReport.jsx`)
- Live telemetry → API client: requests (evidence: `services/frontend/src/components/LiveTelemetryPanel.jsx`)
- React dashboard → Polling hook: polls with (evidence: `services/frontend/src/App.jsx`)
- API client → Experiment controller: controls experiments (evidence: `services/frontend/src/api/client.js`)
- API client → Order API: fetches metrics (evidence: `services/frontend/src/api/client.js`)
- Experiment controller → Traffic generator: configures traffic (evidence: `services/experiment_controller/main.py`)
- Experiment controller → SLO watchdog: monitors SLOs (evidence: `README.md`)
- Experiment controller → Toxiproxy client: manages faults (evidence: `services/experiment_controller/main.py`)
- Toxiproxy client → Toxiproxy: injects faults (evidence: `services/experiment_controller/toxiproxy_client.py`)
- Experiment controller → Order API: polls metrics (evidence: `README.md`)
- Experiment controller → PostgreSQL: stores experiment state (evidence: `README.md`)
- Experiment controller → RabbitMQ: publishes analysis event (evidence: `README.md`)
- Traffic generator → Order API: generates orders (evidence: `README.md`)
- Order API → PostgreSQL: writes order and outbox (evidence: `services/order_api/main.py`)
- Outbox relay → PostgreSQL: reads pending events (evidence: `README.md`)
- Outbox relay → RabbitMQ: publishes fulfillment (evidence: `README.md`)
- RabbitMQ → Fulfillment worker: delivers events (evidence: `README.md`)
- Fulfillment worker → Inventory service: reserves stock (evidence: `README.md`)
- Fulfillment worker → Toxiproxy: calls through proxy (evidence: `README.md`)
- Fulfillment worker → PostgreSQL: records outcome (evidence: `README.md`)
- Fulfillment worker → Retries and breaker: uses retry and breaker (evidence: `services/fulfillment_worker/worker.py`)
- Inventory service → PostgreSQL: records reservation (evidence: `README.md`)
- Inventory service → PostgreSQL: stores idempotency (evidence: `README.md`)
- RabbitMQ → AI analysis worker: delivers analysis event (evidence: `README.md`)
- AI analysis worker → PostgreSQL: reads timeline and saves report (evidence: `README.md`)
- AI analysis worker → Report analyzer: analyzes experiment (evidence: `services/ai_worker/main.py`)
- Report analyzer → Analysis prompts: uses prompts (evidence: `services/ai_worker/analyzer.py`)
- Report analyzer → LLM provider: requests analysis
- Database runtime → PostgreSQL: opens sessions (evidence: `services/common/database.py`)
- Database runtime → Shared configuration: loads settings (evidence: `services/common/database.py`)
- Persistence models → PostgreSQL: defines tables (evidence: `README.md`)
- API and event schemas → Persistence models: uses domain enums (evidence: `services/common/schemas.py`)
- AMQP consumer supervisor → RabbitMQ: supervises consumers (evidence: `README.md`)
