# sensational03/retail_inventory architecture

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

- Interactive diagram: https://gitdiagram.com/sensational03/retail_inventory
- Repository: https://github.com/sensational03/retail_inventory

## Overview

Richfield Fertilisers is a multi-agent pricing, inventory, and procurement system with a React dashboard and FastAPI backend. The primary workflow is to trigger pricing optimization, audit stock and log reorder recommendations, then process pending reorders into purchase orders; users can also inspect product, inventory, supplier, and price-history data and adjust configuration. The README documents the handoff and shared in-memory state. Source excerpts show representative agent logic and UI/API calls, but not every endpoint or agent execution detail.

Main entry points: [`backend/api.py`](https://github.com/sensational03/retail_inventory/blob/main/backend/api.py) (REST and SSE API), [`backend/pricing_agent.py`](https://github.com/sensational03/retail_inventory/blob/main/backend/pricing_agent.py) (Pricing agent), [`backend/inventory_agent.py`](https://github.com/sensational03/retail_inventory/blob/main/backend/inventory_agent.py) (Inventory agent), [`backend/supplier_agent.py`](https://github.com/sensational03/retail_inventory/blob/main/backend/supplier_agent.py) (Supplier agent)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard"]
  node_app["React entry<br/>[main.tsx]"]
  node_ui["Operations dashboard<br/>[PricingAgentUI.tsx]"]
end

subgraph group_backend["API"]
  node_api["REST and SSE API<br/>[api.py]"]
end

subgraph group_agents["Operations agents"]
  node_pricing["Pricing agent<br/>[pricing_agent.py]"]
  node_inventory["Inventory agent<br/>[inventory_agent.py]"]
  node_supplier["Supplier agent<br/>[supplier_agent.py]"]
end

subgraph group_state["Runtime state"]
  node_shared[("Shared in-memory state")]
end

node_user(("Dashboard user"))
node_groq{{"Groq LLM service"}}

node_user -->|"opens dashboard"| node_app
node_app -->|"renders"| node_ui
node_ui -->|"REST and SSE"| node_api
node_api -->|"runs optimization"| node_pricing
node_api -->|"runs audit"| node_inventory
node_api -->|"runs procurement"| node_supplier
node_pricing -->|"reads and updates"| node_shared
node_inventory -->|"reads and logs reorders"| node_shared
node_supplier -->|"reads reorders; logs POs"| node_shared
node_pricing -.->|"suggests config"| node_groq
node_inventory -.->|"suggests config"| node_groq
node_supplier -.->|"suggests strategy"| node_groq

click node_app "https://github.com/sensational03/retail_inventory/blob/main/frontend/src/main.tsx"
click node_ui "https://github.com/sensational03/retail_inventory/blob/main/frontend/src/PricingAgentUI.tsx"
click node_api "https://github.com/sensational03/retail_inventory/blob/main/backend/api.py"
click node_pricing "https://github.com/sensational03/retail_inventory/blob/main/backend/pricing_agent.py"
click node_inventory "https://github.com/sensational03/retail_inventory/blob/main/backend/inventory_agent.py"
click node_supplier "https://github.com/sensational03/retail_inventory/blob/main/backend/supplier_agent.py"
click node_shared "https://github.com/sensational03/retail_inventory/tree/main/backend"

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_app,node_ui,node_user toneBlue
class node_api toneAmber
class node_pricing,node_inventory,node_supplier toneMint
class node_shared toneRose
class node_groq toneIndigo
```

## Components

### Dashboard

- [React entry](https://github.com/sensational03/retail_inventory/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [Operations dashboard](https://github.com/sensational03/retail_inventory/blob/main/frontend/src/PricingAgentUI.tsx): `frontend/src/PricingAgentUI.tsx`

### API

- [REST and SSE API](https://github.com/sensational03/retail_inventory/blob/main/backend/api.py): `backend/api.py`

### Operations agents

- [Pricing agent](https://github.com/sensational03/retail_inventory/blob/main/backend/pricing_agent.py): `backend/pricing_agent.py`
- [Inventory agent](https://github.com/sensational03/retail_inventory/blob/main/backend/inventory_agent.py): `backend/inventory_agent.py`
- [Supplier agent](https://github.com/sensational03/retail_inventory/blob/main/backend/supplier_agent.py): `backend/supplier_agent.py`

### Runtime state

- [Shared in-memory state](https://github.com/sensational03/retail_inventory/tree/main/backend): `backend`

### Other components

- **Dashboard user**
- **Groq LLM service**

## Connections

- Dashboard user → React entry: opens dashboard (evidence: `README.md`)
- React entry → Operations dashboard: renders
- Operations dashboard → REST and SSE API: REST and SSE (evidence: `README.md`)
- REST and SSE API → Pricing agent: runs optimization (evidence: `README.md`)
- REST and SSE API → Inventory agent: runs audit (evidence: `README.md`)
- REST and SSE API → Supplier agent: runs procurement (evidence: `README.md`)
- Pricing agent → Shared in-memory state: reads and updates (evidence: `README.md`)
- Inventory agent → Shared in-memory state: reads and logs reorders (evidence: `README.md`)
- Supplier agent → Shared in-memory state: reads reorders; logs POs (evidence: `README.md`)
- Pricing agent → Groq LLM service: suggests config (evidence: `README.md`)
- Inventory agent → Groq LLM service: suggests config (evidence: `README.md`)
- Supplier agent → Groq LLM service: suggests strategy (evidence: `README.md`)
