# codebykabilesh/supplymind architecture

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

- Interactive diagram: https://gitdiagram.com/codebykabilesh/supplymind
- Repository: https://github.com/codebykabilesh/supplymind

## Overview

The repository combines shipment monitoring and response with a separate supply-chain control-tower workflow. Shipment creation or Kafka GPS updates feed transport event detection and a decision graph; that graph can recommend routes, assess risk, and call demand, supplier, and warehouse services. The warehouse service manages buffer stock and can request a restock suggestion. A second API invokes its own inventory/supplier/orchestrator agent chain. Some referenced modules are absent from the supplied tree, so they are not represented as repository nodes; external integrations are shown only where the excerpts document calls.

Main entry points: [`Transport_agent/graph.py`](https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/graph.py) (Shipment decision graph), [`Transport_agent/main.py`](https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/main.py) (Shipment API), [`Transport_agent/kafka_listener.py`](https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/kafka_listener.py) (GPS listener), [`Warehouse_agent/main.py`](https://github.com/codebykabilesh/supplymind/blob/main/Warehouse_agent/main.py) (Warehouse API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_transport["Transport monitoring"]
  node_transport_api["Shipment API<br/>[main.py]"]
  node_shipment_store[("Shipment records<br/>[database.py]")]
  node_shipment_model["Shipment model<br/>[models.py]"]
  node_listener["GPS listener<br/>[kafka_listener.py]"]
  node_detector["Event detection<br/>[event_detector.py]"]
  node_weather["Weather lookup<br/>[weather.py]"]
  node_maps["Geocoding and ETA<br/>[maps.py]"]
end

subgraph group_decisions["Disruption decisions"]
  node_decision_graph["Shipment decision graph<br/>[graph.py]"]
  node_risk_model["Risk prediction"]
  node_route_advisor["Route suggestions"]
  node_transport_llm["Transport recommendations<br/>[llm.py]"]
end

subgraph group_warehouse["Warehouse service"]
  node_warehouse_api["Warehouse API<br/>[main.py]"]
  node_inventory_store[("Inventory records<br/>[database.py]")]
  node_buffer_logic["Buffer activation<br/>[buffer.py]"]
  node_restock_client["Restock suggestion client<br/>[main.py]"]
end

subgraph group_control["Control tower agents"]
  node_control_api["Healing API<br/>[server.py]"]
  node_agent_chain["Agent-chain workflow<br/>[main.py]"]
  node_warehouse_agent["Inventory agent<br/>[main.py]"]
  node_supplier_agent["Supplier agent<br/>[main.py]"]
  node_orchestrator_agent["Decision agent<br/>[main.py]"]
end

node_operator(("Shipment operator"))
node_gps["GPS event producer<br/>[producer.py]"]
node_kafka["Kafka shipment events"]
node_demand_api["Demand suggestion service<br/>[main.py]"]
node_supplier_api["Supplier restock service<br/>[supplier_agent.py]"]
node_historian[("Event history")]
node_control_db[("Control-tower database<br/>[main.py]")]
node_groq{{"Groq language model"}}
node_frontend(("Frontend client"))

node_operator -->|"creates shipment"| node_transport_api
node_transport_api -->|"stores shipment"| node_shipment_store
node_transport_api -->|"queries records"| node_shipment_model
node_gps -.->|"publishes updates"| node_kafka
node_kafka -->|"delivers events"| node_listener
node_listener -->|"updates location"| node_shipment_store
node_listener -->|"loads shipment"| node_shipment_model
node_listener -->|"detects disruption"| node_detector
node_detector -->|"gets weather"| node_weather
node_detector -->|"gets ETA"| node_maps
node_listener -->|"invokes graph"| node_decision_graph
node_transport_api -->|"invokes graph"| node_decision_graph
node_transport_api -->|"detects event"| node_detector
node_transport_api -->|"updates risk"| node_shipment_store
node_decision_graph -->|"predicts risk"| node_risk_model
node_decision_graph -->|"suggests route"| node_route_advisor
node_decision_graph -->|"requests advice"| node_transport_llm
node_decision_graph -->|"activates buffer"| node_warehouse_api
node_decision_graph -->|"checks inventory"| node_warehouse_api
node_decision_graph -->|"requests quantities"| node_demand_api
node_decision_graph -->|"requests restock"| node_supplier_api
node_warehouse_api -->|"reads and writes"| node_inventory_store
node_warehouse_api -->|"activates stock"| node_buffer_logic
node_warehouse_api -->|"requests suggestion"| node_restock_client
node_buffer_logic -->|"updates stock"| node_inventory_store
node_listener -->|"logs event"| node_historian
node_operator -->|"starts healing"| node_control_api
node_control_api -->|"invokes workflow"| node_agent_chain
node_agent_chain -->|"runs first"| node_warehouse_agent
node_agent_chain -->|"runs next"| node_supplier_agent
node_agent_chain -->|"runs final"| node_orchestrator_agent
node_warehouse_agent -->|"reads inventory"| node_control_db
node_supplier_agent -->|"reads disruptions"| node_control_db
node_warehouse_agent -->|"requests analysis"| node_groq
node_supplier_agent -->|"requests action"| node_groq
node_orchestrator_agent -->|"requests decision"| node_groq
node_control_api -->|"returns results"| node_frontend

click node_gps "https://github.com/codebykabilesh/supplymind/blob/main/producer.py"
click node_transport_api "https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/main.py"
click node_shipment_store "https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/database.py"
click node_shipment_model "https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/models.py"
click node_listener "https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/kafka_listener.py"
click node_detector "https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/event_detector.py"
click node_weather "https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/weather.py"
click node_maps "https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/maps.py"
click node_decision_graph "https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/graph.py"
click node_risk_model "https://github.com/codebykabilesh/supplymind/tree/main/Transport_agent"
click node_route_advisor "https://github.com/codebykabilesh/supplymind/tree/main/Transport_agent"
click node_transport_llm "https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/llm.py"
click node_demand_api "https://github.com/codebykabilesh/supplymind/blob/main/demand_agent/main.py"
click node_supplier_api "https://github.com/codebykabilesh/supplymind/blob/main/supplier_agent/supplier_agent.py"
click node_warehouse_api "https://github.com/codebykabilesh/supplymind/blob/main/Warehouse_agent/main.py"
click node_inventory_store "https://github.com/codebykabilesh/supplymind/blob/main/Warehouse_agent/database.py"
click node_buffer_logic "https://github.com/codebykabilesh/supplymind/blob/main/Warehouse_agent/buffer.py"
click node_restock_client "https://github.com/codebykabilesh/supplymind/blob/main/Warehouse_agent/main.py"
click node_control_api "https://github.com/codebykabilesh/supplymind/blob/main/server.py"
click node_agent_chain "https://github.com/codebykabilesh/supplymind/blob/main/main.py"
click node_warehouse_agent "https://github.com/codebykabilesh/supplymind/blob/main/main.py"
click node_supplier_agent "https://github.com/codebykabilesh/supplymind/blob/main/main.py"
click node_orchestrator_agent "https://github.com/codebykabilesh/supplymind/blob/main/main.py"
click node_control_db "https://github.com/codebykabilesh/supplymind/blob/main/main.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_transport_api,node_shipment_store,node_shipment_model,node_listener,node_detector,node_weather,node_maps,node_frontend toneBlue
class node_decision_graph,node_risk_model,node_route_advisor,node_transport_llm,node_historian,node_control_db toneAmber
class node_warehouse_api,node_inventory_store,node_buffer_logic,node_restock_client toneMint
class node_control_api,node_agent_chain,node_warehouse_agent,node_supplier_agent,node_orchestrator_agent toneRose
class node_operator,node_kafka,node_groq toneIndigo
class node_gps,node_demand_api,node_supplier_api toneTeal
```

## Components

### Transport monitoring

- [Shipment API](https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/main.py): `Transport_agent/main.py`
- [Shipment records](https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/database.py): `Transport_agent/database.py`
- [Shipment model](https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/models.py): `Transport_agent/models.py`
- [GPS listener](https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/kafka_listener.py): `Transport_agent/kafka_listener.py`
- [Event detection](https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/event_detector.py): `Transport_agent/event_detector.py`
- [Weather lookup](https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/weather.py): `Transport_agent/weather.py`
- [Geocoding and ETA](https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/maps.py): `Transport_agent/maps.py`

### Disruption decisions

- [Shipment decision graph](https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/graph.py): `Transport_agent/graph.py`
- [Risk prediction](https://github.com/codebykabilesh/supplymind/tree/main/Transport_agent): `Transport_agent`
- [Route suggestions](https://github.com/codebykabilesh/supplymind/tree/main/Transport_agent): `Transport_agent`
- [Transport recommendations](https://github.com/codebykabilesh/supplymind/blob/main/Transport_agent/llm.py): `Transport_agent/llm.py`

### Warehouse service

- [Warehouse API](https://github.com/codebykabilesh/supplymind/blob/main/Warehouse_agent/main.py): `Warehouse_agent/main.py`
- [Inventory records](https://github.com/codebykabilesh/supplymind/blob/main/Warehouse_agent/database.py): `Warehouse_agent/database.py`
- [Buffer activation](https://github.com/codebykabilesh/supplymind/blob/main/Warehouse_agent/buffer.py): `Warehouse_agent/buffer.py`
- [Restock suggestion client](https://github.com/codebykabilesh/supplymind/blob/main/Warehouse_agent/main.py): `Warehouse_agent/main.py`

### Control tower agents

- [Healing API](https://github.com/codebykabilesh/supplymind/blob/main/server.py): `server.py`
- [Agent-chain workflow](https://github.com/codebykabilesh/supplymind/blob/main/main.py): `main.py`
- [Inventory agent](https://github.com/codebykabilesh/supplymind/blob/main/main.py): `main.py`
- [Supplier agent](https://github.com/codebykabilesh/supplymind/blob/main/main.py): `main.py`
- [Decision agent](https://github.com/codebykabilesh/supplymind/blob/main/main.py): `main.py`

### Other components

- **Shipment operator**
- [GPS event producer](https://github.com/codebykabilesh/supplymind/blob/main/producer.py): `producer.py`
- **Kafka shipment events**
- [Demand suggestion service](https://github.com/codebykabilesh/supplymind/blob/main/demand_agent/main.py): `demand_agent/main.py`
- [Supplier restock service](https://github.com/codebykabilesh/supplymind/blob/main/supplier_agent/supplier_agent.py): `supplier_agent/supplier_agent.py`
- **Event history**
- [Control-tower database](https://github.com/codebykabilesh/supplymind/blob/main/main.py): `main.py`
- **Groq language model**
- **Frontend client**

## Connections

- Shipment operator → Shipment API: creates shipment (evidence: `Transport_agent/main.py`)
- Shipment API → Shipment records: stores shipment (evidence: `Transport_agent/main.py`)
- Shipment API → Shipment model: queries records (evidence: `Transport_agent/main.py`)
- GPS event producer → Kafka shipment events: publishes updates
- Kafka shipment events → GPS listener: delivers events (evidence: `Transport_agent/kafka_listener.py`)
- GPS listener → Shipment records: updates location (evidence: `Transport_agent/kafka_listener.py`)
- GPS listener → Shipment model: loads shipment (evidence: `Transport_agent/kafka_listener.py`)
- GPS listener → Event detection: detects disruption (evidence: `Transport_agent/kafka_listener.py`)
- Event detection → Weather lookup: gets weather (evidence: `Transport_agent/event_detector.py`)
- Event detection → Geocoding and ETA: gets ETA (evidence: `Transport_agent/event_detector.py`)
- GPS listener → Shipment decision graph: invokes graph (evidence: `Transport_agent/kafka_listener.py`)
- Shipment API → Shipment decision graph: invokes graph (evidence: `Transport_agent/main.py`)
- Shipment API → Event detection: detects event (evidence: `Transport_agent/main.py`)
- Shipment API → Shipment records: updates risk (evidence: `Transport_agent/main.py`)
- Shipment decision graph → Risk prediction: predicts risk (evidence: `Transport_agent/graph.py`)
- Shipment decision graph → Route suggestions: suggests route (evidence: `Transport_agent/graph.py`)
- Shipment decision graph → Transport recommendations: requests advice (evidence: `Transport_agent/graph.py`)
- Shipment decision graph → Warehouse API: activates buffer (evidence: `Transport_agent/graph.py`)
- Shipment decision graph → Warehouse API: checks inventory (evidence: `Transport_agent/graph.py`)
- Shipment decision graph → Demand suggestion service: requests quantities (evidence: `Transport_agent/graph.py`)
- Shipment decision graph → Supplier restock service: requests restock (evidence: `Transport_agent/graph.py`)
- Warehouse API → Inventory records: reads and writes (evidence: `Warehouse_agent/main.py`)
- Warehouse API → Buffer activation: activates stock (evidence: `Warehouse_agent/main.py`)
- Warehouse API → Restock suggestion client: requests suggestion (evidence: `Warehouse_agent/main.py`)
- Buffer activation → Inventory records: updates stock (evidence: `Warehouse_agent/buffer.py`)
- GPS listener → Event history: logs event (evidence: `Transport_agent/kafka_listener.py`)
- Shipment operator → Healing API: starts healing (evidence: `server.py`)
- Healing API → Agent-chain workflow: invokes workflow (evidence: `server.py`)
- Agent-chain workflow → Inventory agent: runs first (evidence: `main.py`)
- Agent-chain workflow → Supplier agent: runs next (evidence: `main.py`)
- Agent-chain workflow → Decision agent: runs final (evidence: `main.py`)
- Inventory agent → Control-tower database: reads inventory (evidence: `main.py`)
- Supplier agent → Control-tower database: reads disruptions (evidence: `main.py`)
- Inventory agent → Groq language model: requests analysis (evidence: `main.py`)
- Supplier agent → Groq language model: requests action (evidence: `main.py`)
- Decision agent → Groq language model: requests decision (evidence: `main.py`)
- Healing API → Frontend client: returns results (evidence: `server.py`)
