# glboysagar1-prog/sih_final architecture

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

- Interactive diagram: https://gitdiagram.com/glboysagar1-prog/sih_final
- Repository: https://github.com/glboysagar1-prog/sih_final

## Overview

The repository is an on-premise industrial inspection workbench: users submit inspection documents and a task, the backend runs an agent workflow with model routing and verification tools, then returns compliance results and office deliverables. The React workbench is the primary documented interface; Streamlit is an alternate entry point. Sampled source confirms the API, model gateway, standards retrieval, reporting, and optional Temporal integration. Some agent internals are unsampled, so uncertain tool-dispatch links are omitted; the README’s Data Formulator capability is external to the sampled runtime modules.

Main entry points: [`src/server.py`](https://github.com/glboysagar1-prog/sih_final/blob/main/src/server.py) (Workbench API), [`src/agent/graph.py`](https://github.com/glboysagar1-prog/sih_final/blob/main/src/agent/graph.py) (Agent Graph), [`src/orchestration/activities.py`](https://github.com/glboysagar1-prog/sih_final/blob/main/src/orchestration/activities.py) (Workflow Activities), [`src/agent/llm_client.py`](https://github.com/glboysagar1-prog/sih_final/blob/main/src/agent/llm_client.py) (LLM Gateway)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_react["React Workbench<br/>[App.jsx]"]
  node_streamlit["Streamlit Dashboard<br/>[app.py]"]
end

subgraph group_workflow["Inspection Workflow"]
  node_api["Workbench API<br/>[server.py]"]
  node_agent["Agent Graph<br/>[graph.py]"]
  node_router["Task Router<br/>[router.py]"]
  node_state["Workflow State<br/>[state.py]"]
end

subgraph group_tools["Analysis Tools"]
  node_ocr["Document OCR<br/>[ocr_tool.py]"]
  node_rag["Standards Retrieval<br/>[rag_tool.py]"]
  node_sandbox["Sandbox Verification<br/>[sandbox_tool.py]"]
  node_reports["Office Deliverables<br/>[report_tool.py]"]
end

subgraph group_runtime["Models And Orchestration"]
  node_gateway["LLM Gateway<br/>[llm_client.py]"]
  node_mlx["Local MLX Inference<br/>[server1.py]"]
  node_temporal["Temporal Workflow<br/>[workflows.py]"]
  node_activities["Workflow Activities<br/>[activities.py]"]
  node_worker["Temporal Worker<br/>[worker.py]"]
end

subgraph group_records["Local Records"]
  node_files["File Utilities<br/>[file_manager.py]"]
  node_standards["Standards Corpus"]
  node_workspace["Inspection Files"]
  node_outputs["Generated Outputs"]
end

node_inspector(("Inspector"))
node_cloudmodels["Cloud Model APIs"]
node_temporalservice["Temporal Service"]

node_inspector -->|"submits task"| node_react
node_inspector -.->|"submits task"| node_streamlit
node_react -->|"posts workflow"| node_api
node_streamlit -.->|"runs workflow"| node_agent
node_api -->|"executes directly"| node_agent
node_api -.->|"starts optionally"| node_temporal
node_api -->|"searches standards"| node_rag
node_api -->|"hashes deliverables"| node_files
node_api -->|"reads and stores uploads"| node_workspace
node_agent -->|"classifies task"| node_router
node_router -->|"classifies fallback"| node_gateway
node_gateway -.->|"requests inference"| node_cloudmodels
node_gateway -.->|"requests local inference"| node_mlx
node_api -.->|"serves inference"| node_mlx
node_rag -->|"indexes and searches"| node_standards
node_agent -->|"updates state"| node_state
node_agent -->|"produces results"| node_outputs
node_worker -->|"registers workflow"| node_temporal
node_worker -->|"registers activities"| node_activities
node_api -.->|"connects optionally"| node_temporalservice
node_temporal -.->|"dispatches activities"| node_activities
node_activities -.->|"runs pipeline"| node_agent
node_activities -.->|"compiles deliverables"| node_reports
node_reports -->|"writes deliverables"| node_outputs

click node_react "https://github.com/glboysagar1-prog/sih_final/blob/main/frontend/src/App.jsx"
click node_streamlit "https://github.com/glboysagar1-prog/sih_final/blob/main/ui/app.py"
click node_api "https://github.com/glboysagar1-prog/sih_final/blob/main/src/server.py"
click node_agent "https://github.com/glboysagar1-prog/sih_final/blob/main/src/agent/graph.py"
click node_router "https://github.com/glboysagar1-prog/sih_final/blob/main/src/agent/router.py"
click node_state "https://github.com/glboysagar1-prog/sih_final/blob/main/src/agent/state.py"
click node_ocr "https://github.com/glboysagar1-prog/sih_final/blob/main/src/tools/ocr_tool.py"
click node_rag "https://github.com/glboysagar1-prog/sih_final/blob/main/src/tools/rag_tool.py"
click node_sandbox "https://github.com/glboysagar1-prog/sih_final/blob/main/src/tools/sandbox_tool.py"
click node_reports "https://github.com/glboysagar1-prog/sih_final/blob/main/src/tools/report_tool.py"
click node_gateway "https://github.com/glboysagar1-prog/sih_final/blob/main/src/agent/llm_client.py"
click node_mlx "https://github.com/glboysagar1-prog/sih_final/blob/main/server1.py"
click node_temporal "https://github.com/glboysagar1-prog/sih_final/blob/main/src/orchestration/workflows.py"
click node_activities "https://github.com/glboysagar1-prog/sih_final/blob/main/src/orchestration/activities.py"
click node_worker "https://github.com/glboysagar1-prog/sih_final/blob/main/src/orchestration/worker.py"
click node_files "https://github.com/glboysagar1-prog/sih_final/blob/main/src/utils/file_manager.py"
click node_standards "https://github.com/glboysagar1-prog/sih_final/tree/main/data/standards"
click node_workspace "https://github.com/glboysagar1-prog/sih_final/tree/main/data/sample_inputs"
click node_outputs "https://github.com/glboysagar1-prog/sih_final/tree/main/data/outputs"

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_react,node_streamlit toneBlue
class node_api,node_agent,node_router,node_state toneAmber
class node_ocr,node_rag,node_sandbox,node_reports,node_cloudmodels toneMint
class node_gateway,node_mlx,node_temporal,node_activities,node_worker toneRose
class node_files,node_standards,node_workspace,node_outputs,node_inspector,node_temporalservice toneIndigo
```

## Components

### User Interfaces

- [React Workbench](https://github.com/glboysagar1-prog/sih_final/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Streamlit Dashboard](https://github.com/glboysagar1-prog/sih_final/blob/main/ui/app.py): `ui/app.py`

### Inspection Workflow

- [Workbench API](https://github.com/glboysagar1-prog/sih_final/blob/main/src/server.py): `src/server.py`
- [Agent Graph](https://github.com/glboysagar1-prog/sih_final/blob/main/src/agent/graph.py): `src/agent/graph.py`
- [Task Router](https://github.com/glboysagar1-prog/sih_final/blob/main/src/agent/router.py): `src/agent/router.py`
- [Workflow State](https://github.com/glboysagar1-prog/sih_final/blob/main/src/agent/state.py): `src/agent/state.py`

### Analysis Tools

- [Document OCR](https://github.com/glboysagar1-prog/sih_final/blob/main/src/tools/ocr_tool.py): `src/tools/ocr_tool.py`
- [Standards Retrieval](https://github.com/glboysagar1-prog/sih_final/blob/main/src/tools/rag_tool.py): `src/tools/rag_tool.py`
- [Sandbox Verification](https://github.com/glboysagar1-prog/sih_final/blob/main/src/tools/sandbox_tool.py): `src/tools/sandbox_tool.py`
- [Office Deliverables](https://github.com/glboysagar1-prog/sih_final/blob/main/src/tools/report_tool.py): `src/tools/report_tool.py`

### Models And Orchestration

- [LLM Gateway](https://github.com/glboysagar1-prog/sih_final/blob/main/src/agent/llm_client.py): `src/agent/llm_client.py`
- [Local MLX Inference](https://github.com/glboysagar1-prog/sih_final/blob/main/server1.py): `server1.py`
- [Temporal Workflow](https://github.com/glboysagar1-prog/sih_final/blob/main/src/orchestration/workflows.py): `src/orchestration/workflows.py`
- [Workflow Activities](https://github.com/glboysagar1-prog/sih_final/blob/main/src/orchestration/activities.py): `src/orchestration/activities.py`
- [Temporal Worker](https://github.com/glboysagar1-prog/sih_final/blob/main/src/orchestration/worker.py): `src/orchestration/worker.py`

### Local Records

- [File Utilities](https://github.com/glboysagar1-prog/sih_final/blob/main/src/utils/file_manager.py): `src/utils/file_manager.py`
- [Standards Corpus](https://github.com/glboysagar1-prog/sih_final/tree/main/data/standards): `data/standards`
- [Inspection Files](https://github.com/glboysagar1-prog/sih_final/tree/main/data/sample_inputs): `data/sample_inputs`
- [Generated Outputs](https://github.com/glboysagar1-prog/sih_final/tree/main/data/outputs): `data/outputs`

### Other components

- **Inspector**
- **Cloud Model APIs**
- **Temporal Service**

## Connections

- Inspector → React Workbench: submits task
- Inspector → Streamlit Dashboard: submits task
- React Workbench → Workbench API: posts workflow
- Streamlit Dashboard → Agent Graph: runs workflow
- Workbench API → Agent Graph: executes directly
- Workbench API → Temporal Workflow: starts optionally
- Workbench API → Standards Retrieval: searches standards
- Workbench API → File Utilities: hashes deliverables
- Workbench API → Inspection Files: reads and stores uploads
- Agent Graph → Task Router: classifies task
- Task Router → LLM Gateway: classifies fallback
- LLM Gateway → Cloud Model APIs: requests inference
- LLM Gateway → Local MLX Inference: requests local inference
- Workbench API → Local MLX Inference: serves inference
- Standards Retrieval → Standards Corpus: indexes and searches
- Agent Graph → Workflow State: updates state
- Agent Graph → Generated Outputs: produces results
- Temporal Worker → Temporal Workflow: registers workflow
- Temporal Worker → Workflow Activities: registers activities
- Workbench API → Temporal Service: connects optionally
- Temporal Workflow → Workflow Activities: dispatches activities
- Workflow Activities → Agent Graph: runs pipeline
- Workflow Activities → Office Deliverables: compiles deliverables
- Office Deliverables → Generated Outputs: writes deliverables
