# swayam-was-here/chitragupta-ai architecture

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

- Interactive diagram: https://gitdiagram.com/swayam-was-here/chitragupta-ai
- Repository: https://github.com/swayam-was-here/chitragupta-ai

## Overview

Chitragupta AI monitors MPLADS-funded works: users upload CSV records, the backend validates and stores the file, requests row-level ML scoring, and returns risk results for dashboard triage and reporting. The dashboard also provides role-scoped overview, alerts, works, reports, and locally persisted compliance settings. The README documents both Isolation Forest and LOF signals; the sampled ML service implements Isolation Forest, so LOF is represented only as a documented capability. Dashboard-to-backend and backend-to-service links follow the README and shown calls; unsampled page internals are not inferred.

Main entry points: [`apps/dashboard/src/App.tsx`](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/App.tsx) (Dashboard routes), [`apps/backend/routes/analysis.py`](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/backend/routes/analysis.py) (CSV validation and scoring orchestration), [`ChitraGupta_Ai_api/app.py`](https://github.com/swayam-was-here/chitragupta-ai/blob/main/ChitraGupta_Ai_api/app.py) (ML inference API), [`apps/backend/app.py`](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/backend/app.py) (Flask API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_web_app["Dashboard routes<br/>[App.tsx]"]
  node_home["Public home<br/>[Home.tsx]"]
  node_login["Login<br/>[Login.tsx]"]
  node_dashboard_shell["Dashboard shell"]
end

subgraph group_ingestion["Upload and API"]
  node_works["Works and upload<br/>[Works.tsx]"]
  node_backend["Flask API<br/>[app.py]"]
  node_upload_analysis["CSV validation and scoring orchestration<br/>[analysis.py]"]
  node_storage[("Supabase Storage")]
  node_supabase[("Supabase records")]
end

subgraph group_scoring["Anomaly scoring"]
  node_ml_api["ML inference API<br/>[app.py]"]
  node_feature_engineering["Feature engineering<br/>[app.py]"]
  node_isolation_forest["Isolation Forest<br/>[app.py]"]
  node_lof_signal["LOF signal"]
end

subgraph group_triage["Review and reporting"]
  node_overview["Overview<br/>[Overview.tsx]"]
  node_alerts["Alerts triage<br/>[Alerts.tsx]"]
  node_reports["Reports<br/>[Reports.tsx]"]
end

subgraph group_state["Role and settings"]
  node_settings["Compliance settings<br/>[Settings.tsx]"]
  node_role_scope["Role scoping<br/>[roleFilter.ts]"]
  node_role_store["Active role<br/>[useRoleStore.ts]"]
  node_settings_store["Persisted thresholds"]
end

node_reviewer(("MP / DM / Auditor"))

node_reviewer -->|"uses"| node_web_app
node_web_app -->|"routes to"| node_home
node_web_app -->|"routes to"| node_login
node_web_app -->|"protects and routes"| node_dashboard_shell
node_web_app -->|"routes to"| node_overview
node_web_app -->|"routes to"| node_alerts
node_web_app -->|"routes to"| node_works
node_web_app -->|"routes to"| node_reports
node_web_app -->|"routes to"| node_settings
node_works -->|"POSTs CSV"| node_backend
node_backend -->|"registers routes"| node_upload_analysis
node_upload_analysis -->|"uploads file"| node_storage
node_upload_analysis -->|"requests row scores"| node_ml_api
node_ml_api -->|"engineers features"| node_feature_engineering
node_ml_api -->|"predicts anomaly"| node_isolation_forest
node_upload_analysis -->|"returns scores"| node_works
node_reviewer -->|"reviews metrics"| node_overview
node_reviewer -->|"triages alerts"| node_alerts
node_reviewer -->|"reviews reports"| node_reports
node_role_store -->|"selects scope"| node_role_scope
node_role_scope -->|"filters data"| node_overview
node_role_scope -->|"filters data"| node_reports
node_settings -->|"updates thresholds"| node_settings_store
node_reviewer -->|"configures thresholds"| node_settings
node_ml_api -.->|"pairs with"| node_lof_signal
node_backend -->|"tests connection"| node_supabase

click node_web_app "https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/App.tsx"
click node_home "https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/pages/Home.tsx"
click node_login "https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/pages/Login.tsx"
click node_dashboard_shell "https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/components/dashboard/DashboardLayout.tsx"
click node_overview "https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/pages/dashboard/Overview.tsx"
click node_alerts "https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/pages/dashboard/Alerts.tsx"
click node_works "https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/pages/dashboard/Works.tsx"
click node_reports "https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/pages/dashboard/Reports.tsx"
click node_settings "https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/pages/dashboard/Settings.tsx"
click node_role_scope "https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/lib/roleFilter.ts"
click node_role_store "https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/stores/useRoleStore.ts"
click node_settings_store "https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/stores/useSettingsStore.ts"
click node_backend "https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/backend/app.py"
click node_upload_analysis "https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/backend/routes/analysis.py"
click node_ml_api "https://github.com/swayam-was-here/chitragupta-ai/blob/main/ChitraGupta_Ai_api/app.py"
click node_feature_engineering "https://github.com/swayam-was-here/chitragupta-ai/blob/main/ChitraGupta_Ai_api/app.py"
click node_isolation_forest "https://github.com/swayam-was-here/chitragupta-ai/blob/main/ChitraGupta_Ai_api/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_web_app,node_home,node_login,node_dashboard_shell toneBlue
class node_works,node_backend,node_upload_analysis,node_storage,node_supabase toneAmber
class node_ml_api,node_feature_engineering,node_isolation_forest,node_lof_signal toneMint
class node_overview,node_alerts,node_reports toneRose
class node_settings,node_role_scope,node_role_store,node_settings_store,node_reviewer toneIndigo
```

## Components

### Dashboard

- [Dashboard routes](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/App.tsx): `apps/dashboard/src/App.tsx`
- [Public home](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/pages/Home.tsx): `apps/dashboard/src/pages/Home.tsx`
- [Login](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/pages/Login.tsx): `apps/dashboard/src/pages/Login.tsx`
- [Dashboard shell](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/components/dashboard/DashboardLayout.tsx): `apps/dashboard/src/components/dashboard/DashboardLayout.tsx`

### Upload and API

- [Works and upload](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/pages/dashboard/Works.tsx): `apps/dashboard/src/pages/dashboard/Works.tsx`
- [Flask API](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/backend/app.py): `apps/backend/app.py`
- [CSV validation and scoring orchestration](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/backend/routes/analysis.py): `apps/backend/routes/analysis.py`
- **Supabase Storage**
- **Supabase records**

### Anomaly scoring

- [ML inference API](https://github.com/swayam-was-here/chitragupta-ai/blob/main/ChitraGupta_Ai_api/app.py): `ChitraGupta_Ai_api/app.py`
- [Feature engineering](https://github.com/swayam-was-here/chitragupta-ai/blob/main/ChitraGupta_Ai_api/app.py): `ChitraGupta_Ai_api/app.py`
- [Isolation Forest](https://github.com/swayam-was-here/chitragupta-ai/blob/main/ChitraGupta_Ai_api/app.py): `ChitraGupta_Ai_api/app.py`
- **LOF signal**

### Review and reporting

- [Overview](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/pages/dashboard/Overview.tsx): `apps/dashboard/src/pages/dashboard/Overview.tsx`
- [Alerts triage](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/pages/dashboard/Alerts.tsx): `apps/dashboard/src/pages/dashboard/Alerts.tsx`
- [Reports](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/pages/dashboard/Reports.tsx): `apps/dashboard/src/pages/dashboard/Reports.tsx`

### Role and settings

- [Compliance settings](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/pages/dashboard/Settings.tsx): `apps/dashboard/src/pages/dashboard/Settings.tsx`
- [Role scoping](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/lib/roleFilter.ts): `apps/dashboard/src/lib/roleFilter.ts`
- [Active role](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/stores/useRoleStore.ts): `apps/dashboard/src/stores/useRoleStore.ts`
- [Persisted thresholds](https://github.com/swayam-was-here/chitragupta-ai/blob/main/apps/dashboard/src/stores/useSettingsStore.ts): `apps/dashboard/src/stores/useSettingsStore.ts`

### Other components

- **MP / DM / Auditor**

## Connections

- MP / DM / Auditor → Dashboard routes: uses (evidence: `README.md`)
- Dashboard routes → Public home: routes to (evidence: `apps/dashboard/src/App.tsx`)
- Dashboard routes → Login: routes to (evidence: `apps/dashboard/src/App.tsx`)
- Dashboard routes → Dashboard shell: protects and routes (evidence: `apps/dashboard/src/App.tsx`)
- Dashboard routes → Overview: routes to (evidence: `apps/dashboard/src/App.tsx`)
- Dashboard routes → Alerts triage: routes to (evidence: `apps/dashboard/src/App.tsx`)
- Dashboard routes → Works and upload: routes to (evidence: `apps/dashboard/src/App.tsx`)
- Dashboard routes → Reports: routes to (evidence: `apps/dashboard/src/App.tsx`)
- Dashboard routes → Compliance settings: routes to (evidence: `apps/dashboard/src/App.tsx`)
- Works and upload → Flask API: POSTs CSV (evidence: `README.md`)
- Flask API → CSV validation and scoring orchestration: registers routes (evidence: `apps/backend/app.py`)
- CSV validation and scoring orchestration → Supabase Storage: uploads file (evidence: `apps/backend/routes/analysis.py`)
- CSV validation and scoring orchestration → ML inference API: requests row scores (evidence: `apps/backend/routes/analysis.py`)
- ML inference API → Feature engineering: engineers features (evidence: `ChitraGupta_Ai_api/app.py`)
- ML inference API → Isolation Forest: predicts anomaly (evidence: `ChitraGupta_Ai_api/app.py`)
- CSV validation and scoring orchestration → Works and upload: returns scores (evidence: `README.md`)
- MP / DM / Auditor → Overview: reviews metrics (evidence: `README.md`)
- MP / DM / Auditor → Alerts triage: triages alerts (evidence: `README.md`)
- MP / DM / Auditor → Reports: reviews reports (evidence: `README.md`)
- Active role → Role scoping: selects scope (evidence: `README.md`)
- Role scoping → Overview: filters data (evidence: `README.md`)
- Role scoping → Reports: filters data (evidence: `README.md`)
- Compliance settings → Persisted thresholds: updates thresholds (evidence: `README.md`)
- MP / DM / Auditor → Compliance settings: configures thresholds (evidence: `README.md`)
- ML inference API → LOF signal: pairs with (evidence: `README.md`)
- Flask API → Supabase records: tests connection (evidence: `apps/backend/app.py`)
