# thiyan07/sih-26 architecture

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

- Interactive diagram: https://gitdiagram.com/thiyan07/sih-26
- Repository: https://github.com/thiyan07/sih-26

## Overview

GramBiz AI is a rural micro-business feasibility and loan-planning platform. An entrepreneur submits a village, business category, and available capital; the app returns market and location evidence, an opportunity assessment, financing options, repayment scenarios, and a GO/MODIFY/AVOID recommendation. The README documents deterministic engines as the source of computed figures and AI as an explanation layer. The graph preserves major discovery, data provenance, and scheme-document capabilities; several backend links are dashed where the sampled excerpts do not establish the exact runtime call.

Main entry points: [`apps/web/src/pages/Analyze.tsx`](https://github.com/thiyan07/sih-26/blob/master/apps/web/src/pages/Analyze.tsx) (Business intake), [`apps/web/src/lib/analysisStore.tsx`](https://github.com/thiyan07/sih-26/blob/master/apps/web/src/lib/analysisStore.tsx) (Analysis state), [`apps/api/app/db/models.py`](https://github.com/thiyan07/sih-26/blob/master/apps/api/app/db/models.py) (Application database), [`apps/web/src/App.tsx`](https://github.com/thiyan07/sih-26/blob/master/apps/web/src/App.tsx) (Web application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web app"]
  node_webapp["Web application<br/>[App.tsx]"]
  node_analyze["Business intake<br/>[Analyze.tsx]"]
  node_state["Analysis state<br/>[analysisStore.tsx]"]
  node_dashboard["Opportunity report<br/>[Dashboard.tsx]"]
  node_financeui["Finance and scenarios<br/>[Finance.tsx]"]
  node_client["API client<br/>[api.ts]"]
end

subgraph group_api["API workflows"]
  node_apiapp["FastAPI application<br/>[main.py]"]
  node_analysisroute["Analysis endpoint<br/>[analysis.py]"]
  node_analysis["Analysis workflow<br/>[analysis.py]"]
  node_financeapi["Financial planning<br/>[financial.py]"]
  node_marketapi["Market and business APIs<br/>[businesses.py]"]
end

subgraph group_engines["Analysis engines"]
  node_engines["Deterministic engines"]
  node_costmodels["Business cost models<br/>[cost_templates.py]"]
end

subgraph group_data["Data and discovery"]
  node_discovery["Business discovery<br/>[orchestrator.py]"]
  node_providers["Discovery providers"]
  node_database[("Application database<br/>[models.py]")]
  node_datasources["Data source status<br/>[data_sources.py]"]
end

subgraph group_ai["AI explanations"]
  node_ragapi["Scheme document API<br/>[rag.py]"]
  node_rag["Grounded retrieval<br/>[rag.py]"]
  node_llm["Language model<br/>[llm.py]"]
end

node_entrepreneur(("Entrepreneur"))
node_externaldata(("Map and government data"))

node_entrepreneur -->|"submits inputs"| node_analyze
node_webapp -->|"routes to"| node_analyze
node_analyze -->|"requests analysis"| node_client
node_analyze -->|"updates state"| node_state
node_state -->|"persists drafts"| node_client
node_webapp -->|"routes to"| node_dashboard
node_webapp -->|"routes to"| node_financeui
node_client -.->|"calls endpoint"| node_analysisroute
node_apiapp -->|"registers router"| node_analysisroute
node_analysisroute -->|"invokes workflow"| node_analysis
node_analysis -.->|"computes assessment"| node_engines
node_financeapi -.->|"computes financing"| node_engines
node_marketapi -->|"loads competitors"| node_discovery
node_discovery -->|"dispatches searches"| node_providers
node_discovery -->|"stores observations"| node_database
node_providers -.->|"queries sources"| node_externaldata
node_datasources -.->|"reports freshness"| node_database
node_ragapi -->|"retrieves answers"| node_rag
node_rag -->|"reads document chunks"| node_database
node_rag -->|"grounds responses"| node_llm
node_dashboard -->|"reads results"| node_state
node_financeui -->|"reads analysis"| node_state
node_database -.->|"stores sourced facts"| node_externaldata
node_costmodels -.->|"supplies assumptions"| node_engines

click node_webapp "https://github.com/thiyan07/sih-26/blob/master/apps/web/src/App.tsx"
click node_analyze "https://github.com/thiyan07/sih-26/blob/master/apps/web/src/pages/Analyze.tsx"
click node_state "https://github.com/thiyan07/sih-26/blob/master/apps/web/src/lib/analysisStore.tsx"
click node_dashboard "https://github.com/thiyan07/sih-26/blob/master/apps/web/src/pages/Dashboard.tsx"
click node_financeui "https://github.com/thiyan07/sih-26/blob/master/apps/web/src/pages/Finance.tsx"
click node_client "https://github.com/thiyan07/sih-26/blob/master/apps/web/src/lib/api.ts"
click node_apiapp "https://github.com/thiyan07/sih-26/blob/master/apps/api/app/main.py"
click node_analysisroute "https://github.com/thiyan07/sih-26/blob/master/apps/api/app/api/analysis.py"
click node_analysis "https://github.com/thiyan07/sih-26/blob/master/apps/api/app/services/analysis.py"
click node_financeapi "https://github.com/thiyan07/sih-26/blob/master/apps/api/app/api/financial.py"
click node_marketapi "https://github.com/thiyan07/sih-26/blob/master/apps/api/app/api/businesses.py"
click node_engines "https://github.com/thiyan07/sih-26/tree/master/apps/api/app/engines"
click node_costmodels "https://github.com/thiyan07/sih-26/blob/master/apps/api/app/engines/cost_templates.py"
click node_discovery "https://github.com/thiyan07/sih-26/blob/master/apps/api/app/discovery/orchestrator.py"
click node_providers "https://github.com/thiyan07/sih-26/tree/master/apps/api/app/discovery/providers"
click node_database "https://github.com/thiyan07/sih-26/blob/master/apps/api/app/db/models.py"
click node_datasources "https://github.com/thiyan07/sih-26/blob/master/apps/api/app/api/data_sources.py"
click node_ragapi "https://github.com/thiyan07/sih-26/blob/master/apps/api/app/api/rag.py"
click node_rag "https://github.com/thiyan07/sih-26/blob/master/apps/api/app/ai/rag.py"
click node_llm "https://github.com/thiyan07/sih-26/blob/master/apps/api/app/ai/llm.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_webapp,node_analyze,node_state,node_dashboard,node_financeui,node_client toneBlue
class node_apiapp,node_analysisroute,node_analysis,node_financeapi,node_marketapi toneAmber
class node_engines,node_costmodels toneMint
class node_discovery,node_providers,node_database,node_datasources toneRose
class node_ragapi,node_rag,node_llm,node_entrepreneur,node_externaldata toneIndigo
```

## Components

### Web app

- [Web application](https://github.com/thiyan07/sih-26/blob/master/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [Business intake](https://github.com/thiyan07/sih-26/blob/master/apps/web/src/pages/Analyze.tsx): `apps/web/src/pages/Analyze.tsx`
- [Analysis state](https://github.com/thiyan07/sih-26/blob/master/apps/web/src/lib/analysisStore.tsx): `apps/web/src/lib/analysisStore.tsx`
- [Opportunity report](https://github.com/thiyan07/sih-26/blob/master/apps/web/src/pages/Dashboard.tsx): `apps/web/src/pages/Dashboard.tsx`
- [Finance and scenarios](https://github.com/thiyan07/sih-26/blob/master/apps/web/src/pages/Finance.tsx): `apps/web/src/pages/Finance.tsx`
- [API client](https://github.com/thiyan07/sih-26/blob/master/apps/web/src/lib/api.ts): `apps/web/src/lib/api.ts`

### API workflows

- [FastAPI application](https://github.com/thiyan07/sih-26/blob/master/apps/api/app/main.py): `apps/api/app/main.py`
- [Analysis endpoint](https://github.com/thiyan07/sih-26/blob/master/apps/api/app/api/analysis.py): `apps/api/app/api/analysis.py`
- [Analysis workflow](https://github.com/thiyan07/sih-26/blob/master/apps/api/app/services/analysis.py): `apps/api/app/services/analysis.py`
- [Financial planning](https://github.com/thiyan07/sih-26/blob/master/apps/api/app/api/financial.py): `apps/api/app/api/financial.py`
- [Market and business APIs](https://github.com/thiyan07/sih-26/blob/master/apps/api/app/api/businesses.py): `apps/api/app/api/businesses.py`

### Analysis engines

- [Deterministic engines](https://github.com/thiyan07/sih-26/tree/master/apps/api/app/engines): `apps/api/app/engines`
- [Business cost models](https://github.com/thiyan07/sih-26/blob/master/apps/api/app/engines/cost_templates.py): `apps/api/app/engines/cost_templates.py`

### Data and discovery

- [Business discovery](https://github.com/thiyan07/sih-26/blob/master/apps/api/app/discovery/orchestrator.py): `apps/api/app/discovery/orchestrator.py`
- [Discovery providers](https://github.com/thiyan07/sih-26/tree/master/apps/api/app/discovery/providers): `apps/api/app/discovery/providers`
- [Application database](https://github.com/thiyan07/sih-26/blob/master/apps/api/app/db/models.py): `apps/api/app/db/models.py`
- [Data source status](https://github.com/thiyan07/sih-26/blob/master/apps/api/app/api/data_sources.py): `apps/api/app/api/data_sources.py`

### AI explanations

- [Scheme document API](https://github.com/thiyan07/sih-26/blob/master/apps/api/app/api/rag.py): `apps/api/app/api/rag.py`
- [Grounded retrieval](https://github.com/thiyan07/sih-26/blob/master/apps/api/app/ai/rag.py): `apps/api/app/ai/rag.py`
- [Language model](https://github.com/thiyan07/sih-26/blob/master/apps/api/app/ai/llm.py): `apps/api/app/ai/llm.py`

### Other components

- **Entrepreneur**
- **Map and government data**

## Connections

- Entrepreneur → Business intake: submits inputs (evidence: `README.md`)
- Web application → Business intake: routes to (evidence: `apps/web/src/App.tsx`)
- Business intake → API client: requests analysis (evidence: `apps/web/src/pages/Analyze.tsx`)
- Business intake → Analysis state: updates state (evidence: `apps/web/src/pages/Analyze.tsx`)
- Analysis state → API client: persists drafts (evidence: `apps/web/src/lib/analysisStore.tsx`)
- Web application → Opportunity report: routes to (evidence: `apps/web/src/App.tsx`)
- Web application → Finance and scenarios: routes to (evidence: `apps/web/src/App.tsx`)
- API client → Analysis endpoint: calls endpoint
- FastAPI application → Analysis endpoint: registers router (evidence: `apps/api/app/main.py`)
- Analysis endpoint → Analysis workflow: invokes workflow (evidence: `apps/api/app/api/analysis.py`)
- Analysis workflow → Deterministic engines: computes assessment (evidence: `README.md`)
- Financial planning → Deterministic engines: computes financing (evidence: `README.md`)
- Market and business APIs → Business discovery: loads competitors (evidence: `apps/api/app/api/businesses.py`)
- Business discovery → Discovery providers: dispatches searches (evidence: `apps/api/app/discovery/orchestrator.py`)
- Business discovery → Application database: stores observations (evidence: `apps/api/app/discovery/orchestrator.py`)
- Discovery providers → Map and government data: queries sources
- Data source status → Application database: reports freshness
- Scheme document API → Grounded retrieval: retrieves answers (evidence: `apps/api/app/api/rag.py`)
- Grounded retrieval → Application database: reads document chunks (evidence: `apps/api/app/ai/rag.py`)
- Grounded retrieval → Language model: grounds responses (evidence: `apps/api/app/ai/rag.py`)
- Opportunity report → Analysis state: reads results (evidence: `apps/web/src/pages/Dashboard.tsx`)
- Finance and scenarios → Analysis state: reads analysis (evidence: `apps/web/src/pages/Finance.tsx`)
- Application database → Map and government data: stores sourced facts (evidence: `README.md`)
- Business cost models → Deterministic engines: supplies assumptions
