# fbivinay/sih-hackathon architecture

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

- Interactive diagram: https://gitdiagram.com/fbivinay/sih-hackathon
- Repository: https://github.com/fbivinay/sih-hackathon

## Overview

Kasauti is an MPLADS verification and monitoring product: it turns published works and payment records into comparable risk scores, compliance findings, agency/member signals, and a ranked review queue, then presents those results to public-sector users. The main user workflow is to filter the queue, inspect a work’s evidence, and record a review decision with history. The README documents major capabilities beyond the sampled excerpts; their exact endpoint wiring is not fully visible, so the graph represents them at the API service boundary and omits uncertain internal links.

Main entry points: [`web/lib/api.ts`](https://github.com/fbivinay/sih-hackathon/blob/main/web/lib/api.ts) (Web API client), [`api/main.py`](https://github.com/fbivinay/sih-hackathon/blob/main/api/main.py) (API service), [`data/load_real_data.py`](https://github.com/fbivinay/sih-hackathon/blob/main/data/load_real_data.py) (Record loaders), [`web/app/projects/page.tsx`](https://github.com/fbivinay/sih-hackathon/blob/main/web/app/projects/page.tsx) (Project review queue)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Data and classification"]
  node_loaders["Record loaders<br/>[load_real_data.py]"]
  node_sector_rules["Sector rules<br/>[sectors.py]"]
  node_sector_llm["LLM sector labels<br/>[llm_sectors.py]"]
end

subgraph group_analysis["Risk analysis"]
  node_scoring["Work scoring<br/>[scoring.py]"]
  node_detectors["Agency/member detectors<br/>[detectors.py]"]
  node_compliance["Compliance checks<br/>[scoring.py]"]
end

subgraph group_service["API and state"]
  node_api["API service<br/>[main.py]"]
  node_db_access["Database access<br/>[db.py]"]
  node_review_state[("Review state and history<br/>[main.py]")]
end

subgraph group_web["User experience"]
  node_review_action["Review decisions<br/>[actions.ts]"]
  node_api_client["Web API client<br/>[api.ts]"]
  node_overview["National overview<br/>[page.tsx]"]
  node_queue["Project review queue<br/>[page.tsx]"]
  node_work_detail["Work evidence<br/>[page.tsx]"]
  node_member_views["Member dashboards<br/>[page.tsx]"]
  node_regional_views["State and district desks<br/>[page.tsx]"]
  node_trends_view["Trends and alerts<br/>[page.tsx]"]
  node_search["Site search<br/>[SiteSearch.tsx]"]
end

node_users(("Public-sector users"))
node_mplads["Published MPLADS records"]
node_gemini{{"Gemini API"}}
node_database[("PostgreSQL")]

node_mplads -->|"loads records"| node_loaders
node_loaders -->|"writes records"| node_database
node_sector_rules -->|"fallback labels"| node_sector_llm
node_sector_llm -.->|"classifies descriptions"| node_gemini
node_loaders -->|"supplies works"| node_scoring
node_sector_rules -->|"provides sectors"| node_scoring
node_scoring -->|"stores scores"| node_database
node_detectors -->|"stores findings"| node_database
node_compliance -->|"stores breaches"| node_database
node_users -->|"views"| node_overview
node_users -->|"filters queue"| node_queue
node_users -->|"views"| node_member_views
node_users -->|"views"| node_regional_views
node_queue -->|"requests queue data"| node_api_client
node_overview -->|"requests summary"| node_api_client
node_member_views -->|"requests member data"| node_api_client
node_regional_views -->|"requests regional data"| node_api_client
node_work_detail -->|"requests work evidence"| node_api_client
node_trends_view -->|"requests trends"| node_api_client
node_search -->|"fetches search data"| node_api
node_api_client -->|"calls endpoints"| node_api
node_api -->|"queries and updates"| node_db_access
node_db_access -->|"reads and writes"| node_database
node_queue -->|"submits decision"| node_review_action
node_review_action -->|"posts review"| node_api
node_api -->|"records decisions"| node_review_state
node_api -->|"reads history"| node_review_state
node_trends_view -->|"presents findings"| node_detectors

click node_loaders "https://github.com/fbivinay/sih-hackathon/blob/main/data/load_real_data.py"
click node_sector_rules "https://github.com/fbivinay/sih-hackathon/blob/main/data/sectors.py"
click node_sector_llm "https://github.com/fbivinay/sih-hackathon/blob/main/data/llm_sectors.py"
click node_scoring "https://github.com/fbivinay/sih-hackathon/blob/main/data/scoring.py"
click node_detectors "https://github.com/fbivinay/sih-hackathon/blob/main/data/detectors.py"
click node_compliance "https://github.com/fbivinay/sih-hackathon/blob/main/data/scoring.py"
click node_api "https://github.com/fbivinay/sih-hackathon/blob/main/api/main.py"
click node_db_access "https://github.com/fbivinay/sih-hackathon/blob/main/api/db.py"
click node_review_action "https://github.com/fbivinay/sih-hackathon/blob/main/web/app/projects/actions.ts"
click node_review_state "https://github.com/fbivinay/sih-hackathon/blob/main/api/main.py"
click node_api_client "https://github.com/fbivinay/sih-hackathon/blob/main/web/lib/api.ts"
click node_overview "https://github.com/fbivinay/sih-hackathon/blob/main/web/app/page.tsx"
click node_queue "https://github.com/fbivinay/sih-hackathon/blob/main/web/app/projects/page.tsx"
click node_work_detail "https://github.com/fbivinay/sih-hackathon/blob/main/web/app/projects/%5Bid%5D/page.tsx"
click node_member_views "https://github.com/fbivinay/sih-hackathon/blob/main/web/app/mp/%5Bid%5D/page.tsx"
click node_regional_views "https://github.com/fbivinay/sih-hackathon/blob/main/web/app/state/%5Bstate%5D/page.tsx"
click node_trends_view "https://github.com/fbivinay/sih-hackathon/blob/main/web/app/page.tsx"
click node_search "https://github.com/fbivinay/sih-hackathon/blob/main/web/components/SiteSearch.tsx"

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_loaders,node_sector_rules,node_sector_llm,node_users toneBlue
class node_scoring,node_detectors,node_compliance,node_database toneAmber
class node_api,node_db_access,node_review_state,node_gemini toneMint
class node_review_action,node_api_client,node_overview,node_queue,node_work_detail,node_member_views,node_regional_views,node_trends_view,node_search toneRose
class node_mplads toneIndigo
```

## Components

### Data and classification

- [Record loaders](https://github.com/fbivinay/sih-hackathon/blob/main/data/load_real_data.py): `data/load_real_data.py`
- [Sector rules](https://github.com/fbivinay/sih-hackathon/blob/main/data/sectors.py): `data/sectors.py`
- [LLM sector labels](https://github.com/fbivinay/sih-hackathon/blob/main/data/llm_sectors.py): `data/llm_sectors.py`

### Risk analysis

- [Work scoring](https://github.com/fbivinay/sih-hackathon/blob/main/data/scoring.py): `data/scoring.py`
- [Agency/member detectors](https://github.com/fbivinay/sih-hackathon/blob/main/data/detectors.py): `data/detectors.py`
- [Compliance checks](https://github.com/fbivinay/sih-hackathon/blob/main/data/scoring.py): `data/scoring.py`

### API and state

- [API service](https://github.com/fbivinay/sih-hackathon/blob/main/api/main.py): `api/main.py`
- [Database access](https://github.com/fbivinay/sih-hackathon/blob/main/api/db.py): `api/db.py`
- [Review state and history](https://github.com/fbivinay/sih-hackathon/blob/main/api/main.py): `api/main.py`

### User experience

- [Review decisions](https://github.com/fbivinay/sih-hackathon/blob/main/web/app/projects/actions.ts): `web/app/projects/actions.ts`
- [Web API client](https://github.com/fbivinay/sih-hackathon/blob/main/web/lib/api.ts): `web/lib/api.ts`
- [National overview](https://github.com/fbivinay/sih-hackathon/blob/main/web/app/page.tsx): `web/app/page.tsx`
- [Project review queue](https://github.com/fbivinay/sih-hackathon/blob/main/web/app/projects/page.tsx): `web/app/projects/page.tsx`
- [Work evidence](https://github.com/fbivinay/sih-hackathon/blob/main/web/app/projects/%5Bid%5D/page.tsx): `web/app/projects/[id]/page.tsx`
- [Member dashboards](https://github.com/fbivinay/sih-hackathon/blob/main/web/app/mp/%5Bid%5D/page.tsx): `web/app/mp/[id]/page.tsx`
- [State and district desks](https://github.com/fbivinay/sih-hackathon/blob/main/web/app/state/%5Bstate%5D/page.tsx): `web/app/state/[state]/page.tsx`
- [Trends and alerts](https://github.com/fbivinay/sih-hackathon/blob/main/web/app/page.tsx): `web/app/page.tsx`
- [Site search](https://github.com/fbivinay/sih-hackathon/blob/main/web/components/SiteSearch.tsx): `web/components/SiteSearch.tsx`

### Other components

- **Public-sector users**
- **Published MPLADS records**
- **Gemini API**
- **PostgreSQL**

## Connections

- Published MPLADS records → Record loaders: loads records
- Record loaders → PostgreSQL: writes records
- Sector rules → LLM sector labels: fallback labels
- LLM sector labels → Gemini API: classifies descriptions
- Record loaders → Work scoring: supplies works
- Sector rules → Work scoring: provides sectors
- Work scoring → PostgreSQL: stores scores
- Agency/member detectors → PostgreSQL: stores findings
- Compliance checks → PostgreSQL: stores breaches
- Public-sector users → National overview: views
- Public-sector users → Project review queue: filters queue
- Public-sector users → Member dashboards: views
- Public-sector users → State and district desks: views
- Project review queue → Web API client: requests queue data
- National overview → Web API client: requests summary
- Member dashboards → Web API client: requests member data
- State and district desks → Web API client: requests regional data
- Work evidence → Web API client: requests work evidence
- Trends and alerts → Web API client: requests trends
- Site search → API service: fetches search data
- Web API client → API service: calls endpoints
- API service → Database access: queries and updates
- Database access → PostgreSQL: reads and writes
- Project review queue → Review decisions: submits decision
- Review decisions → API service: posts review
- API service → Review state and history: records decisions
- API service → Review state and history: reads history
- Trends and alerts → Agency/member detectors: presents findings
