# sanskarbawniya/sih2026 architecture

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

- Interactive diagram: https://gitdiagram.com/sanskarbawniya/sih2026
- Repository: https://github.com/sanskarbawniya/sih2026

## Overview

This is a border-checkpoint/eKYC identity-screening application. An operator supplies an identity document and selfie; the dashboard submits them to the scan API, whose orchestrator runs extraction, validation and tamper analysis, then optional liveness, face matching and identity-graph checks, producing a composite risk result shown with graph alerts. The graph highlights those domain stages and the API/UI boundary. Some service implementations and UI components are unsampled, so links to them are limited to relationships explicitly shown in the route/orchestrator excerpts or README.

Main entry points: [`backend/app/services/orchestrator.py`](https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/orchestrator.py) (Scan orchestrator), [`backend/app/routes/scan.py`](https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/routes/scan.py) (Scan and graph routes), [`frontend/src/pages/Dashboard.tsx`](https://github.com/sanskarbawniya/sih2026/blob/master/frontend/src/pages/Dashboard.tsx) (Screening dashboard), [`frontend/src/api.ts`](https://github.com/sanskarbawniya/sih2026/blob/master/frontend/src/api.ts) (Frontend API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Screening UI"]
  node_dashboard["Screening dashboard<br/>[Dashboard.tsx]"]
  node_capture["Document and selfie capture<br/>[UploadPanel.tsx]"]
  node_api_client["Frontend API client<br/>[api.ts]"]
  node_results["Scan results and panels"]
  node_graph_panel["Graph fraud panel"]
end

subgraph group_api["API and contracts"]
  node_app["FastAPI application<br/>[main.py]"]
  node_scan_routes["Scan and graph routes<br/>[scan.py]"]
  node_contracts["Scan result contracts<br/>[scan_result.py]"]
end

subgraph group_analysis["Document and biometric analysis"]
  node_orchestrator["Scan orchestrator<br/>[orchestrator.py]"]
  node_ocr["Document OCR<br/>[ocr.py]"]
  node_validation["Identity validation<br/>[validation.py]"]
  node_forensics["ELA forensics<br/>[forensics.py]"]
  node_liveness["Selfie liveness<br/>[liveness.py]"]
  node_biometrics["Face verification<br/>[biometrics.py]"]
end

subgraph group_risk["Risk and identity graph"]
  node_risk_engine["Composite risk scoring<br/>[risk_engine.py]"]
  node_identity_graph["Identity graph analysis<br/>[graph.py]"]
end

subgraph group_state["Runtime state"]
  node_scan_cache[("Scan result cache<br/>[scan_cache.py]")]
  node_uploads[("Uploaded scan files<br/>[config.py]")]
end

node_operator(("Checkpoint operator"))

node_operator -->|"provides files"| node_capture
node_capture -->|"supplies inputs"| node_dashboard
node_dashboard -->|"requests liveness scan"| node_api_client
node_api_client -->|"posts scan request"| node_scan_routes
node_scan_routes -->|"runs scan"| node_orchestrator
node_app -->|"registers routes"| node_scan_routes
node_scan_routes -->|"saves uploads"| node_uploads
node_orchestrator -->|"extracts fields"| node_ocr
node_orchestrator -->|"validates fields"| node_validation
node_orchestrator -->|"analyzes tampering"| node_forensics
node_orchestrator -->|"checks liveness"| node_liveness
node_orchestrator -->|"verifies face"| node_biometrics
node_orchestrator -->|"evaluates identity links"| node_identity_graph
node_orchestrator -->|"computes risk"| node_risk_engine
node_orchestrator -->|"reuses scan data"| node_scan_cache
node_scan_routes -->|"reads graph status"| node_identity_graph
node_scan_routes -->|"clears cache"| node_scan_cache
node_scan_routes -->|"returns scan result"| node_contracts
node_api_client -->|"returns scan result"| node_dashboard
node_dashboard -->|"renders result"| node_results
node_results -->|"renders graph details"| node_graph_panel
node_dashboard -->|"requests graph metadata"| node_api_client

click node_dashboard "https://github.com/sanskarbawniya/sih2026/blob/master/frontend/src/pages/Dashboard.tsx"
click node_capture "https://github.com/sanskarbawniya/sih2026/blob/master/frontend/src/components/UploadPanel.tsx"
click node_api_client "https://github.com/sanskarbawniya/sih2026/blob/master/frontend/src/api.ts"
click node_results "https://github.com/sanskarbawniya/sih2026/blob/master/frontend/src/components/FullScanResults.tsx"
click node_graph_panel "https://github.com/sanskarbawniya/sih2026/blob/master/frontend/src/components/GraphFraudPanel.tsx"
click node_app "https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/main.py"
click node_scan_routes "https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/routes/scan.py"
click node_contracts "https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/schemas/scan_result.py"
click node_orchestrator "https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/orchestrator.py"
click node_ocr "https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/ocr.py"
click node_validation "https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/validation.py"
click node_forensics "https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/forensics.py"
click node_liveness "https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/liveness.py"
click node_biometrics "https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/biometrics.py"
click node_risk_engine "https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/risk_engine.py"
click node_identity_graph "https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/graph.py"
click node_scan_cache "https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/scan_cache.py"
click node_uploads "https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/config.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_capture,node_api_client,node_results,node_graph_panel toneBlue
class node_app,node_scan_routes,node_contracts toneAmber
class node_orchestrator,node_ocr,node_validation,node_forensics,node_liveness,node_biometrics toneMint
class node_risk_engine,node_identity_graph toneRose
class node_scan_cache,node_uploads,node_operator toneIndigo
```

## Components

### Screening UI

- [Screening dashboard](https://github.com/sanskarbawniya/sih2026/blob/master/frontend/src/pages/Dashboard.tsx): `frontend/src/pages/Dashboard.tsx`
- [Document and selfie capture](https://github.com/sanskarbawniya/sih2026/blob/master/frontend/src/components/UploadPanel.tsx): `frontend/src/components/UploadPanel.tsx`
- [Frontend API client](https://github.com/sanskarbawniya/sih2026/blob/master/frontend/src/api.ts): `frontend/src/api.ts`
- [Scan results and panels](https://github.com/sanskarbawniya/sih2026/blob/master/frontend/src/components/FullScanResults.tsx): `frontend/src/components/FullScanResults.tsx`
- [Graph fraud panel](https://github.com/sanskarbawniya/sih2026/blob/master/frontend/src/components/GraphFraudPanel.tsx): `frontend/src/components/GraphFraudPanel.tsx`

### API and contracts

- [FastAPI application](https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/main.py): `backend/app/main.py`
- [Scan and graph routes](https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/routes/scan.py): `backend/app/routes/scan.py`
- [Scan result contracts](https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/schemas/scan_result.py): `backend/app/schemas/scan_result.py`

### Document and biometric analysis

- [Scan orchestrator](https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/orchestrator.py): `backend/app/services/orchestrator.py`
- [Document OCR](https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/ocr.py): `backend/app/services/ocr.py`
- [Identity validation](https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/validation.py): `backend/app/services/validation.py`
- [ELA forensics](https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/forensics.py): `backend/app/services/forensics.py`
- [Selfie liveness](https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/liveness.py): `backend/app/services/liveness.py`
- [Face verification](https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/biometrics.py): `backend/app/services/biometrics.py`

### Risk and identity graph

- [Composite risk scoring](https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/risk_engine.py): `backend/app/services/risk_engine.py`
- [Identity graph analysis](https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/graph.py): `backend/app/services/graph.py`

### Runtime state

- [Scan result cache](https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/services/scan_cache.py): `backend/app/services/scan_cache.py`
- [Uploaded scan files](https://github.com/sanskarbawniya/sih2026/blob/master/backend/app/config.py): `backend/app/config.py`

### Other components

- **Checkpoint operator**

## Connections

- Checkpoint operator → Document and selfie capture: provides files
- Document and selfie capture → Screening dashboard: supplies inputs (evidence: `frontend/src/pages/Dashboard.tsx`)
- Screening dashboard → Frontend API client: requests liveness scan (evidence: `frontend/src/pages/Dashboard.tsx`)
- Frontend API client → Scan and graph routes: posts scan request (evidence: `frontend/src/api.ts`)
- Scan and graph routes → Scan orchestrator: runs scan (evidence: `backend/app/routes/scan.py`)
- FastAPI application → Scan and graph routes: registers routes (evidence: `backend/app/main.py`)
- Scan and graph routes → Uploaded scan files: saves uploads (evidence: `backend/app/routes/scan.py`)
- Scan orchestrator → Document OCR: extracts fields (evidence: `backend/app/services/orchestrator.py`)
- Scan orchestrator → Identity validation: validates fields (evidence: `backend/app/services/orchestrator.py`)
- Scan orchestrator → ELA forensics: analyzes tampering (evidence: `backend/app/services/orchestrator.py`)
- Scan orchestrator → Selfie liveness: checks liveness (evidence: `backend/app/services/orchestrator.py`)
- Scan orchestrator → Face verification: verifies face (evidence: `backend/app/services/orchestrator.py`)
- Scan orchestrator → Identity graph analysis: evaluates identity links (evidence: `backend/app/services/orchestrator.py`)
- Scan orchestrator → Composite risk scoring: computes risk (evidence: `backend/app/services/orchestrator.py`)
- Scan orchestrator → Scan result cache: reuses scan data (evidence: `backend/app/services/orchestrator.py`)
- Scan and graph routes → Identity graph analysis: reads graph status (evidence: `backend/app/routes/scan.py`)
- Scan and graph routes → Scan result cache: clears cache (evidence: `backend/app/routes/scan.py`)
- Scan and graph routes → Scan result contracts: returns scan result (evidence: `backend/app/routes/scan.py`)
- Frontend API client → Screening dashboard: returns scan result (evidence: `frontend/src/pages/Dashboard.tsx`)
- Screening dashboard → Scan results and panels: renders result (evidence: `frontend/src/pages/Dashboard.tsx`)
- Scan results and panels → Graph fraud panel: renders graph details (evidence: `frontend/src/components/FullScanResults.tsx`)
- Screening dashboard → Frontend API client: requests graph metadata (evidence: `frontend/src/pages/Dashboard.tsx`)
