# sachinsahu460368/bharat-standard-ai architecture

> Architecture diagram of the GitHub repository sachinsahu460368/bharat-standard-ai, 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/sachinsahu460368/bharat-standard-ai
- Repository: https://github.com/sachinsahu460368/bharat-standard-ai

## Overview

Bharat Standards AI turns procurement documents into explainable Indian Standards recommendations and structured reports. The main workflow starts in the web dashboard, submits a document to the analysis API, extracts requirements, retrieves and ranks standards, and returns recommendations with compliance, version, and explanation details for display or reporting. The README documents these capabilities, while sampled source confirms the frontend calls, search orchestration, and report service behavior. Analysis-route wiring and several domain service interactions are represented at the documented capability level because their source was not sampled.

Main entry points: [`backend/app/api/routes/analyze.py`](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/api/routes/analyze.py) (Analysis Endpoint), [`frontend/src/App.tsx`](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/frontend/src/App.tsx) (Dashboard Workflow), [`backend/app/services/hybrid_search_service.py`](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/hybrid_search_service.py) (Hybrid Search), [`frontend/src/apiService.ts`](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/frontend/src/apiService.ts) (API Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web Dashboard"]
  node_dashboard["Dashboard Workflow<br/>[App.tsx]"]
  node_dashboard_panels["Results Panels"]
  node_frontend_api["API Client<br/>[apiService.ts]"]
end

subgraph group_api["API"]
  node_analysis_api["Analysis Endpoint<br/>[analyze.py]"]
  node_search_api["Search Endpoint<br/>[search.py]"]
  node_reports_api["Reports Endpoint<br/>[reports.py]"]
end

subgraph group_analysis["Analysis"]
  node_document_processing["Document Processing"]
  node_requirement_extraction["Requirement Extraction"]
  node_local_extraction["Local Fallback"]
  node_compliance["Compliance Checks"]
  node_explanations["Recommendation Explanations"]
  node_version_alerts["Version Alerts<br/>[version_service.py]"]
end

subgraph group_retrieval["Standards Retrieval"]
  node_hybrid_search["Hybrid Search"]
  node_lexical_search["Lexical Search"]
  node_semantic_search["Semantic Search"]
  node_reranking["Relevance Reranking"]
  node_standards[("Standards Knowledge Base")]
  node_standards_graph["Related Standards"]
end

subgraph group_reporting["Reporting"]
  node_report_service["Report Generation<br/>[report_service.py]"]
end

node_procurement_user(("Procurement User"))
node_llm_provider{{"LLM Provider"}}

node_procurement_user -->|"uploads document"| node_dashboard
node_dashboard -->|"requests analysis"| node_frontend_api
node_frontend_api -->|"posts document"| node_analysis_api
node_analysis_api -->|"processes file"| node_document_processing
node_document_processing -->|"provides text"| node_requirement_extraction
node_requirement_extraction -.->|"extracts with"| node_llm_provider
node_requirement_extraction -->|"falls back to"| node_local_extraction
node_analysis_api -->|"retrieves standards"| node_hybrid_search
node_hybrid_search -->|"queries"| node_lexical_search
node_hybrid_search -->|"queries"| node_semantic_search
node_lexical_search -->|"reads records"| node_standards
node_semantic_search -->|"reads records"| node_standards
node_hybrid_search -->|"checks metadata"| node_standards
node_analysis_api -->|"ranks candidates"| node_reranking
node_analysis_api -->|"checks QCO status"| node_compliance
node_analysis_api -->|"builds explanations"| node_explanations
node_analysis_api -->|"checks versions"| node_version_alerts
node_analysis_api -->|"finds related standards"| node_standards_graph
node_analysis_api -->|"returns findings"| node_dashboard
node_dashboard -->|"displays results"| node_dashboard_panels
node_dashboard -->|"requests report"| node_frontend_api
node_frontend_api -->|"posts analysis ID"| node_reports_api
node_reports_api -->|"generates report"| node_report_service
node_reports_api -->|"returns report"| node_dashboard
node_search_api -->|"dispatches lexical"| node_lexical_search
node_search_api -->|"dispatches semantic"| node_semantic_search
node_search_api -->|"dispatches hybrid"| node_hybrid_search

click node_dashboard "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/frontend/src/App.tsx"
click node_dashboard_panels "https://github.com/sachinsahu460368/bharat-standard-ai/tree/main/frontend/src/components"
click node_frontend_api "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/frontend/src/apiService.ts"
click node_analysis_api "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/api/routes/analyze.py"
click node_search_api "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/api/routes/search.py"
click node_reports_api "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/api/routes/reports.py"
click node_document_processing "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/document_service.py"
click node_requirement_extraction "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/requirement_extraction_service.py"
click node_local_extraction "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/local_extraction_service.py"
click node_compliance "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/compliance_service.py"
click node_explanations "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/explanation_service.py"
click node_version_alerts "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/version_service.py"
click node_hybrid_search "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/hybrid_search_service.py"
click node_lexical_search "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/lexical_search_service.py"
click node_semantic_search "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/semantic_search_service.py"
click node_reranking "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/reranking_service.py"
click node_standards "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/standards_service.py"
click node_standards_graph "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/standards_graph_service.py"
click node_report_service "https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/report_service.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_dashboard_panels,node_frontend_api,node_procurement_user toneBlue
class node_analysis_api,node_search_api,node_reports_api toneAmber
class node_document_processing,node_requirement_extraction,node_local_extraction,node_compliance,node_explanations,node_version_alerts toneMint
class node_hybrid_search,node_lexical_search,node_semantic_search,node_reranking,node_standards,node_standards_graph toneRose
class node_report_service,node_llm_provider toneIndigo
```

## Components

### Web Dashboard

- [Dashboard Workflow](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Results Panels](https://github.com/sachinsahu460368/bharat-standard-ai/tree/main/frontend/src/components): `frontend/src/components`
- [API Client](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/frontend/src/apiService.ts): `frontend/src/apiService.ts`

### API

- [Analysis Endpoint](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/api/routes/analyze.py): `backend/app/api/routes/analyze.py`
- [Search Endpoint](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/api/routes/search.py): `backend/app/api/routes/search.py`
- [Reports Endpoint](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/api/routes/reports.py): `backend/app/api/routes/reports.py`

### Analysis

- [Document Processing](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/document_service.py): `backend/app/services/document_service.py`
- [Requirement Extraction](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/requirement_extraction_service.py): `backend/app/services/requirement_extraction_service.py`
- [Local Fallback](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/local_extraction_service.py): `backend/app/services/local_extraction_service.py`
- [Compliance Checks](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/compliance_service.py): `backend/app/services/compliance_service.py`
- [Recommendation Explanations](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/explanation_service.py): `backend/app/services/explanation_service.py`
- [Version Alerts](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/version_service.py): `backend/app/services/version_service.py`

### Standards Retrieval

- [Hybrid Search](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/hybrid_search_service.py): `backend/app/services/hybrid_search_service.py`
- [Lexical Search](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/lexical_search_service.py): `backend/app/services/lexical_search_service.py`
- [Semantic Search](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/semantic_search_service.py): `backend/app/services/semantic_search_service.py`
- [Relevance Reranking](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/reranking_service.py): `backend/app/services/reranking_service.py`
- [Standards Knowledge Base](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/standards_service.py): `backend/app/services/standards_service.py`
- [Related Standards](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/standards_graph_service.py): `backend/app/services/standards_graph_service.py`

### Reporting

- [Report Generation](https://github.com/sachinsahu460368/bharat-standard-ai/blob/main/backend/app/services/report_service.py): `backend/app/services/report_service.py`

### Other components

- **Procurement User**
- **LLM Provider**

## Connections

- Procurement User → Dashboard Workflow: uploads document
- Dashboard Workflow → API Client: requests analysis
- API Client → Analysis Endpoint: posts document
- Analysis Endpoint → Document Processing: processes file
- Document Processing → Requirement Extraction: provides text
- Requirement Extraction → LLM Provider: extracts with
- Requirement Extraction → Local Fallback: falls back to
- Analysis Endpoint → Hybrid Search: retrieves standards
- Hybrid Search → Lexical Search: queries
- Hybrid Search → Semantic Search: queries
- Lexical Search → Standards Knowledge Base: reads records
- Semantic Search → Standards Knowledge Base: reads records
- Hybrid Search → Standards Knowledge Base: checks metadata
- Analysis Endpoint → Relevance Reranking: ranks candidates
- Analysis Endpoint → Compliance Checks: checks QCO status
- Analysis Endpoint → Recommendation Explanations: builds explanations
- Analysis Endpoint → Version Alerts: checks versions
- Analysis Endpoint → Related Standards: finds related standards
- Analysis Endpoint → Dashboard Workflow: returns findings
- Dashboard Workflow → Results Panels: displays results
- Dashboard Workflow → API Client: requests report
- API Client → Reports Endpoint: posts analysis ID
- Reports Endpoint → Report Generation: generates report
- Reports Endpoint → Dashboard Workflow: returns report
- Search Endpoint → Lexical Search: dispatches lexical
- Search Endpoint → Semantic Search: dispatches semantic
- Search Endpoint → Hybrid Search: dispatches hybrid
