# mithun-22/scm-agent- architecture

> Architecture diagram of the GitHub repository mithun-22/scm-agent-, 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/mithun-22/scm-agent-
- Repository: https://github.com/mithun-22/scm-agent-

## Overview

SCM Agent is a Streamlit supply-chain analytics application. Users upload Excel workbooks, explore the extracted tables, then analyze them through natural-language queries, pivots, risk insights, KPIs, and what-if scenarios. The README documents the AI query path from context construction through Azure OpenAI-generated Pandas code, sandboxed execution, result formatting, and rendering. The repository has one substantial source file, so these responsibilities share app.py; connections beyond the documented query pipeline are limited to README-described behavior.

Main entry points: [`app.py`](https://github.com/mithun-22/scm-agent-/blob/main/app.py) (Streamlit App)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_streamlit["Streamlit App<br/>[app.py]"]
  node_explorer["Data Explorer<br/>[app.py]"]
  node_visuals["Result Renderer<br/>[app.py]"]
end

subgraph group_data["Data Analysis"]
  node_excel["Excel Extraction<br/>[app.py]"]
  node_pivot["Pivot Analysis<br/>[app.py]"]
  node_kpis["KPI Analysis<br/>[app.py]"]
end

subgraph group_intelligence["AI Query"]
  node_context["Context Builder<br/>[app.py]"]
  node_azure["Azure OpenAI"]
  node_executor["Safe Code Executor<br/>[app.py]"]
  node_formatter["Result Formatter<br/>[app.py]"]
end

subgraph group_planning["Planning Insights"]
  node_insights["Risk Insights<br/>[app.py]"]
  node_simulation["What-If Simulation<br/>[app.py]"]
end

node_user(("Supply Chain User"))

node_user -->|"uses"| node_streamlit
node_streamlit -->|"uploads workbooks"| node_excel
node_streamlit -->|"opens explorer"| node_explorer
node_streamlit -->|"creates pivots"| node_pivot
node_streamlit -->|"shows KPIs"| node_kpis
node_streamlit -->|"shows alerts"| node_insights
node_streamlit -->|"runs scenarios"| node_simulation
node_streamlit -->|"submits question"| node_context
node_context -->|"requests code"| node_azure
node_azure -->|"generates Pandas code"| node_executor
node_executor -->|"returns result"| node_formatter
node_formatter -->|"formats response"| node_visuals
node_visuals -->|"renders results"| node_user

click node_streamlit "https://github.com/mithun-22/scm-agent-/blob/main/app.py"
click node_excel "https://github.com/mithun-22/scm-agent-/blob/main/app.py"
click node_explorer "https://github.com/mithun-22/scm-agent-/blob/main/app.py"
click node_pivot "https://github.com/mithun-22/scm-agent-/blob/main/app.py"
click node_kpis "https://github.com/mithun-22/scm-agent-/blob/main/app.py"
click node_context "https://github.com/mithun-22/scm-agent-/blob/main/app.py"
click node_executor "https://github.com/mithun-22/scm-agent-/blob/main/app.py"
click node_formatter "https://github.com/mithun-22/scm-agent-/blob/main/app.py"
click node_visuals "https://github.com/mithun-22/scm-agent-/blob/main/app.py"
click node_insights "https://github.com/mithun-22/scm-agent-/blob/main/app.py"
click node_simulation "https://github.com/mithun-22/scm-agent-/blob/main/app.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_streamlit,node_explorer,node_visuals,node_user toneBlue
class node_excel,node_pivot,node_kpis toneAmber
class node_context,node_azure,node_executor,node_formatter toneMint
class node_insights,node_simulation toneRose
```

## Components

### User Interface

- [Streamlit App](https://github.com/mithun-22/scm-agent-/blob/main/app.py): `app.py`
- [Data Explorer](https://github.com/mithun-22/scm-agent-/blob/main/app.py): `app.py`
- [Result Renderer](https://github.com/mithun-22/scm-agent-/blob/main/app.py): `app.py`

### Data Analysis

- [Excel Extraction](https://github.com/mithun-22/scm-agent-/blob/main/app.py): `app.py`
- [Pivot Analysis](https://github.com/mithun-22/scm-agent-/blob/main/app.py): `app.py`
- [KPI Analysis](https://github.com/mithun-22/scm-agent-/blob/main/app.py): `app.py`

### AI Query

- [Context Builder](https://github.com/mithun-22/scm-agent-/blob/main/app.py): `app.py`
- **Azure OpenAI**
- [Safe Code Executor](https://github.com/mithun-22/scm-agent-/blob/main/app.py): `app.py`
- [Result Formatter](https://github.com/mithun-22/scm-agent-/blob/main/app.py): `app.py`

### Planning Insights

- [Risk Insights](https://github.com/mithun-22/scm-agent-/blob/main/app.py): `app.py`
- [What-If Simulation](https://github.com/mithun-22/scm-agent-/blob/main/app.py): `app.py`

### Other components

- **Supply Chain User**

## Connections

- Supply Chain User → Streamlit App: uses (evidence: `README.md`)
- Streamlit App → Excel Extraction: uploads workbooks (evidence: `README.md`)
- Streamlit App → Data Explorer: opens explorer (evidence: `README.md`)
- Streamlit App → Pivot Analysis: creates pivots (evidence: `README.md`)
- Streamlit App → KPI Analysis: shows KPIs (evidence: `README.md`)
- Streamlit App → Risk Insights: shows alerts (evidence: `README.md`)
- Streamlit App → What-If Simulation: runs scenarios (evidence: `README.md`)
- Streamlit App → Context Builder: submits question (evidence: `README.md`)
- Context Builder → Azure OpenAI: requests code (evidence: `README.md`)
- Azure OpenAI → Safe Code Executor: generates Pandas code (evidence: `README.md`)
- Safe Code Executor → Result Formatter: returns result (evidence: `README.md`)
- Result Formatter → Result Renderer: formats response (evidence: `README.md`)
- Result Renderer → Supply Chain User: renders results (evidence: `README.md`)
