# rudra-7910/sih architecture

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

- Interactive diagram: https://gitdiagram.com/rudra-7910/sih
- Repository: https://github.com/rudra-7910/sih

## Overview

SHI is a Legal Metrology inspection assistant: an officer submits package views, the server processes text into statutory declaration findings, and the officer reviews and completes the inspection. The graph preserves the documented OCR choices, multi-view workflow, audit/history, demo scenarios, offline queue, and PDF dossier. Some frontend and route behavior is represented from README documentation and the SOURCE INDEX; unsampled links are omitted where their caller is not shown.

Main entry points: [`client/src/pages/InspectionDashboard.tsx`](https://github.com/rudra-7910/sih/blob/main/client/src/pages/InspectionDashboard.tsx) (Inspection Dashboard), [`server/src/routes/inspection.ts`](https://github.com/rudra-7910/sih/blob/main/server/src/routes/inspection.ts) (Inspection Routes), [`server/src/session/inspectionSession.ts`](https://github.com/rudra-7910/sih/blob/main/server/src/session/inspectionSession.ts) (Session and Audit Manager), [`server/src/server.ts`](https://github.com/rudra-7910/sih/blob/main/server/src/server.ts) (REST API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Inspection Interface"]
  node_dashboard["Inspection Dashboard"]
  node_upload["Image Upload<br/>[ImageUpload.tsx]"]
  node_viewtools["Multi-View Tracker"]
  node_findingsui["Findings Review UI"]
  node_resultsui["Rule Results Panel"]
  node_adjudication["Officer Review Panel"]
  node_historyui["Inspection History"]
  node_dossier["PDF Dossier<br/>[pdfGenerator.ts]"]
  node_offline["Offline Upload Queue"]
end

subgraph group_processing["Evidence Processing"]
  node_server["REST API<br/>[server.ts]"]
  node_inspectionapi["Inspection Routes<br/>[inspection.ts]"]
  node_preprocess["Image Preprocessing"]
  node_ocr["OCR Adapters<br/>[IOcrAdapter.ts]"]
  node_mockocr["Mock OCR<br/>[MockOcrAdapter.ts]"]
  node_tesseract["Tesseract OCR"]
  node_paddle["PaddleOCR"]
end

subgraph group_assessment["Compliance Assessment"]
  node_extractor["Field Extraction<br/>[fieldExtractor.ts]"]
  node_rules["Deterministic Rule Engine<br/>[ruleEngine.ts]"]
  node_repository["Rule Repository<br/>[ruleRepository.ts]"]
  node_demos["Demo Scenarios<br/>[demo.ts]"]
end

subgraph group_records["Inspection Records"]
  node_sessions["Session and Audit Manager"]
  node_database[("SQLite Inspection Store<br/>[sqliteDatabase.ts]")]
end

node_officer(("Inspection Officer"))

node_officer -->|"uses"| node_dashboard
node_dashboard -->|"renders"| node_upload
node_dashboard -->|"renders"| node_viewtools
node_dashboard -->|"renders"| node_findingsui
node_dashboard -->|"renders"| node_resultsui
node_dashboard -->|"renders"| node_adjudication
node_dashboard -->|"renders"| node_historyui
node_dashboard -->|"requests export"| node_dossier
node_dashboard -->|"queues uploads"| node_offline
node_dashboard -->|"calls API"| node_server
node_server -->|"mounts routes"| node_inspectionapi
node_server -->|"mounts routes"| node_demos
node_inspectionapi -->|"preprocesses images"| node_preprocess
node_inspectionapi -->|"selects adapter"| node_ocr
node_inspectionapi -->|"runs OCR"| node_mockocr
node_inspectionapi -->|"runs OCR"| node_tesseract
node_inspectionapi -->|"runs OCR"| node_paddle
node_inspectionapi -->|"extracts fields"| node_extractor
node_inspectionapi -->|"manages sessions"| node_sessions
node_sessions -->|"checks fields"| node_rules
node_rules -->|"loads rules"| node_repository
node_sessions -->|"reads and writes"| node_database
node_officer -->|"reviews findings"| node_adjudication
node_officer -->|"submits views"| node_upload
node_dashboard -.->|"selects scenario"| node_demos
node_sessions -.->|"provides history"| node_historyui

click node_dashboard "https://github.com/rudra-7910/sih/blob/main/client/src/pages/InspectionDashboard.tsx"
click node_upload "https://github.com/rudra-7910/sih/blob/main/client/src/components/ImageUpload.tsx"
click node_viewtools "https://github.com/rudra-7910/sih/blob/main/client/src/components/MultiViewTracker.tsx"
click node_findingsui "https://github.com/rudra-7910/sih/blob/main/client/src/components/DeclarationTable.tsx"
click node_resultsui "https://github.com/rudra-7910/sih/blob/main/client/src/components/RuleResultsPanel.tsx"
click node_adjudication "https://github.com/rudra-7910/sih/blob/main/client/src/components/OfficerReviewPanel.tsx"
click node_historyui "https://github.com/rudra-7910/sih/blob/main/client/src/components/InspectionHistory.tsx"
click node_dossier "https://github.com/rudra-7910/sih/blob/main/client/src/utils/pdfGenerator.ts"
click node_offline "https://github.com/rudra-7910/sih/blob/main/client/src/pages/InspectionDashboard.tsx"
click node_server "https://github.com/rudra-7910/sih/blob/main/server/src/server.ts"
click node_inspectionapi "https://github.com/rudra-7910/sih/blob/main/server/src/routes/inspection.ts"
click node_preprocess "https://github.com/rudra-7910/sih/blob/main/server/src/preprocessing/imagePreprocessor.ts"
click node_ocr "https://github.com/rudra-7910/sih/blob/main/server/src/ocr/IOcrAdapter.ts"
click node_mockocr "https://github.com/rudra-7910/sih/blob/main/server/src/ocr/MockOcrAdapter.ts"
click node_tesseract "https://github.com/rudra-7910/sih/blob/main/server/src/ocr/TesseractOcrAdapter.ts"
click node_paddle "https://github.com/rudra-7910/sih/blob/main/server/src/ocr/PaddleOcrAdapter.ts"
click node_extractor "https://github.com/rudra-7910/sih/blob/main/server/src/extraction/fieldExtractor.ts"
click node_rules "https://github.com/rudra-7910/sih/blob/main/server/src/rules/ruleEngine.ts"
click node_repository "https://github.com/rudra-7910/sih/blob/main/server/src/rules/ruleRepository.ts"
click node_demos "https://github.com/rudra-7910/sih/blob/main/server/src/routes/demo.ts"
click node_sessions "https://github.com/rudra-7910/sih/blob/main/server/src/session/inspectionSession.ts"
click node_database "https://github.com/rudra-7910/sih/blob/main/server/src/db/sqliteDatabase.ts"

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_upload,node_viewtools,node_findingsui,node_resultsui,node_adjudication,node_historyui,node_dossier,node_offline toneBlue
class node_server,node_inspectionapi,node_preprocess,node_ocr,node_mockocr,node_tesseract,node_paddle toneAmber
class node_extractor,node_rules,node_repository,node_demos toneMint
class node_sessions,node_database toneRose
class node_officer toneIndigo
```

## Components

### Inspection Interface

- [Inspection Dashboard](https://github.com/rudra-7910/sih/blob/main/client/src/pages/InspectionDashboard.tsx): `client/src/pages/InspectionDashboard.tsx`
- [Image Upload](https://github.com/rudra-7910/sih/blob/main/client/src/components/ImageUpload.tsx): `client/src/components/ImageUpload.tsx`
- [Multi-View Tracker](https://github.com/rudra-7910/sih/blob/main/client/src/components/MultiViewTracker.tsx): `client/src/components/MultiViewTracker.tsx`
- [Findings Review UI](https://github.com/rudra-7910/sih/blob/main/client/src/components/DeclarationTable.tsx): `client/src/components/DeclarationTable.tsx`
- [Rule Results Panel](https://github.com/rudra-7910/sih/blob/main/client/src/components/RuleResultsPanel.tsx): `client/src/components/RuleResultsPanel.tsx`
- [Officer Review Panel](https://github.com/rudra-7910/sih/blob/main/client/src/components/OfficerReviewPanel.tsx): `client/src/components/OfficerReviewPanel.tsx`
- [Inspection History](https://github.com/rudra-7910/sih/blob/main/client/src/components/InspectionHistory.tsx): `client/src/components/InspectionHistory.tsx`
- [PDF Dossier](https://github.com/rudra-7910/sih/blob/main/client/src/utils/pdfGenerator.ts): `client/src/utils/pdfGenerator.ts`
- [Offline Upload Queue](https://github.com/rudra-7910/sih/blob/main/client/src/pages/InspectionDashboard.tsx): `client/src/pages/InspectionDashboard.tsx`

### Evidence Processing

- [REST API](https://github.com/rudra-7910/sih/blob/main/server/src/server.ts): `server/src/server.ts`
- [Inspection Routes](https://github.com/rudra-7910/sih/blob/main/server/src/routes/inspection.ts): `server/src/routes/inspection.ts`
- [Image Preprocessing](https://github.com/rudra-7910/sih/blob/main/server/src/preprocessing/imagePreprocessor.ts): `server/src/preprocessing/imagePreprocessor.ts`
- [OCR Adapters](https://github.com/rudra-7910/sih/blob/main/server/src/ocr/IOcrAdapter.ts): `server/src/ocr/IOcrAdapter.ts`
- [Mock OCR](https://github.com/rudra-7910/sih/blob/main/server/src/ocr/MockOcrAdapter.ts): `server/src/ocr/MockOcrAdapter.ts`
- [Tesseract OCR](https://github.com/rudra-7910/sih/blob/main/server/src/ocr/TesseractOcrAdapter.ts): `server/src/ocr/TesseractOcrAdapter.ts`
- [PaddleOCR](https://github.com/rudra-7910/sih/blob/main/server/src/ocr/PaddleOcrAdapter.ts): `server/src/ocr/PaddleOcrAdapter.ts`

### Compliance Assessment

- [Field Extraction](https://github.com/rudra-7910/sih/blob/main/server/src/extraction/fieldExtractor.ts): `server/src/extraction/fieldExtractor.ts`
- [Deterministic Rule Engine](https://github.com/rudra-7910/sih/blob/main/server/src/rules/ruleEngine.ts): `server/src/rules/ruleEngine.ts`
- [Rule Repository](https://github.com/rudra-7910/sih/blob/main/server/src/rules/ruleRepository.ts): `server/src/rules/ruleRepository.ts`
- [Demo Scenarios](https://github.com/rudra-7910/sih/blob/main/server/src/routes/demo.ts): `server/src/routes/demo.ts`

### Inspection Records

- [Session and Audit Manager](https://github.com/rudra-7910/sih/blob/main/server/src/session/inspectionSession.ts): `server/src/session/inspectionSession.ts`
- [SQLite Inspection Store](https://github.com/rudra-7910/sih/blob/main/server/src/db/sqliteDatabase.ts): `server/src/db/sqliteDatabase.ts`

### Other components

- **Inspection Officer**

## Connections

- Inspection Officer → Inspection Dashboard: uses (evidence: `README.md`)
- Inspection Dashboard → Image Upload: renders (evidence: `client/src/pages/InspectionDashboard.tsx`)
- Inspection Dashboard → Multi-View Tracker: renders (evidence: `client/src/pages/InspectionDashboard.tsx`)
- Inspection Dashboard → Findings Review UI: renders (evidence: `client/src/pages/InspectionDashboard.tsx`)
- Inspection Dashboard → Rule Results Panel: renders (evidence: `client/src/pages/InspectionDashboard.tsx`)
- Inspection Dashboard → Officer Review Panel: renders (evidence: `client/src/pages/InspectionDashboard.tsx`)
- Inspection Dashboard → Inspection History: renders (evidence: `client/src/pages/InspectionDashboard.tsx`)
- Inspection Dashboard → PDF Dossier: requests export
- Inspection Dashboard → Offline Upload Queue: queues uploads (evidence: `client/src/pages/InspectionDashboard.tsx`)
- Inspection Dashboard → REST API: calls API (evidence: `client/src/pages/InspectionDashboard.tsx`)
- REST API → Inspection Routes: mounts routes (evidence: `server/src/server.ts`)
- REST API → Demo Scenarios: mounts routes (evidence: `server/src/server.ts`)
- Inspection Routes → Image Preprocessing: preprocesses images (evidence: `server/src/routes/inspection.ts`)
- Inspection Routes → OCR Adapters: selects adapter (evidence: `server/src/routes/inspection.ts`)
- Inspection Routes → Mock OCR: runs OCR (evidence: `server/src/routes/inspection.ts`)
- Inspection Routes → Tesseract OCR: runs OCR (evidence: `server/src/routes/inspection.ts`)
- Inspection Routes → PaddleOCR: runs OCR (evidence: `server/src/routes/inspection.ts`)
- Inspection Routes → Field Extraction: extracts fields (evidence: `server/src/routes/inspection.ts`)
- Inspection Routes → Session and Audit Manager: manages sessions (evidence: `server/src/routes/inspection.ts`)
- Session and Audit Manager → Deterministic Rule Engine: checks fields (evidence: `server/src/session/inspectionSession.ts`)
- Deterministic Rule Engine → Rule Repository: loads rules (evidence: `server/src/rules/ruleEngine.ts`)
- Session and Audit Manager → SQLite Inspection Store: reads and writes (evidence: `server/src/session/inspectionSession.ts`)
- Inspection Officer → Officer Review Panel: reviews findings (evidence: `README.md`)
- Inspection Officer → Image Upload: submits views (evidence: `README.md`)
- Inspection Dashboard → Demo Scenarios: selects scenario (evidence: `README.md`)
- Session and Audit Manager → Inspection History: provides history (evidence: `README.md`)
