# samarjeetbisen-22/sih-26035 architecture

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

- Interactive diagram: https://gitdiagram.com/samarjeetbisen-22/sih-26035
- Repository: https://github.com/samarjeetbisen-22/sih-26035

## Overview

Metrolab is a web-based NAWI testing and verification platform. Inspectors enter instrument details, test conditions, and readings; the system calculates OIML compliance, supports reviewer approval, and generates official reports. Owners and administrators also use fleet, dashboard, and audit capabilities. The README documents these backend workflows, while the sampled source confirms parts of the frontend, API bridge, authentication, and browser-side computation; unsampled backend wiring is not shown where it cannot be established.

Main entry points: [`frontend/src/App.tsx`](https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/App.tsx) (Web application), [`frontend/src/utils/apiClient.ts`](https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/utils/apiClient.ts) (API client), [`server.py`](https://github.com/samarjeetbisen-22/sih-26035/blob/main/server.py) (HTTP API server), [`frontend/src/utils/oimlEngine.ts`](https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/utils/oimlEngine.ts) (OIML calculations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workbench["Testing Workbench"]
  node_app["Web application<br/>[App.tsx]"]
  node_intake["Instrument intake"]
  node_ledger["Testing dashboard"]
  node_compute["OIML calculations<br/>[oimlEngine.ts]"]
  node_preview["Results preview"]
end

subgraph group_services["Application Services"]
  node_api["API client<br/>[apiClient.ts]"]
  node_server["HTTP API server<br/>[server.py]"]
  node_security["Authentication security<br/>[auth_security.py]"]
  node_oiml_backend["Backend validation<br/>[backend_oiml.py]"]
end

subgraph group_governance["Review and Oversight"]
  node_review["Review queue"]
  node_portal["Owner fleet portal"]
  node_session["Role switcher"]
end

subgraph group_records["Records and Reporting"]
  node_database[("Application database<br/>[db.py]")]
  node_attachments["Evidence attachments"]
  node_audit["Audit history"]
  node_report["Official report"]
end

node_inspector(("Inspector"))
node_reviewer(("Reviewer"))
node_owner(("Fleet owner"))

node_inspector -->|"uses"| node_app
node_app -->|"presents"| node_intake
node_app -->|"presents"| node_ledger
node_app -->|"calculates"| node_compute
node_compute -->|"supplies results"| node_preview
node_app -->|"requests data"| node_api
node_api -->|"calls API"| node_server
node_server -->|"authenticates"| node_security
node_server -->|"reads and writes"| node_database
node_server -->|"validates readings"| node_oiml_backend
node_reviewer -->|"uses"| node_review
node_review -->|"requests reviews"| node_api
node_owner -->|"uses"| node_portal
node_portal -->|"requests fleet data"| node_api
node_app -->|"opens"| node_attachments
node_attachments -->|"uploads evidence"| node_api
node_app -->|"opens"| node_audit
node_audit -->|"requests history"| node_api
node_preview -->|"renders document"| node_report
node_session -->|"logs in"| node_api
node_app -->|"requests PDF"| node_report

click node_app "https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/App.tsx"
click node_intake "https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/InstrumentIntakeForm.tsx"
click node_ledger "https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/DataEntryDashboard.tsx"
click node_compute "https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/utils/oimlEngine.ts"
click node_preview "https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/ComputationPreview.tsx"
click node_api "https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/utils/apiClient.ts"
click node_server "https://github.com/samarjeetbisen-22/sih-26035/blob/main/server.py"
click node_security "https://github.com/samarjeetbisen-22/sih-26035/blob/main/auth_security.py"
click node_database "https://github.com/samarjeetbisen-22/sih-26035/blob/main/db.py"
click node_review "https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/ReviewerQueueModal.tsx"
click node_portal "https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/OwnerPortalModal.tsx"
click node_attachments "https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/AttachmentUploadModal.tsx"
click node_audit "https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/AuditHistoryModal.tsx"
click node_report "https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/OfficialReportDocument.tsx"
click node_oiml_backend "https://github.com/samarjeetbisen-22/sih-26035/blob/main/backend_oiml.py"
click node_session "https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/AuthRoleSwitcher.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_app,node_intake,node_ledger,node_compute,node_preview,node_reviewer toneBlue
class node_api,node_server,node_security,node_oiml_backend toneAmber
class node_review,node_portal,node_session toneMint
class node_database,node_attachments,node_audit,node_report toneRose
class node_inspector,node_owner toneIndigo
```

## Components

### Testing Workbench

- [Web application](https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Instrument intake](https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/InstrumentIntakeForm.tsx): `frontend/src/components/InstrumentIntakeForm.tsx`
- [Testing dashboard](https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/DataEntryDashboard.tsx): `frontend/src/components/DataEntryDashboard.tsx`
- [OIML calculations](https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/utils/oimlEngine.ts): `frontend/src/utils/oimlEngine.ts`
- [Results preview](https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/ComputationPreview.tsx): `frontend/src/components/ComputationPreview.tsx`

### Application Services

- [API client](https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/utils/apiClient.ts): `frontend/src/utils/apiClient.ts`
- [HTTP API server](https://github.com/samarjeetbisen-22/sih-26035/blob/main/server.py): `server.py`
- [Authentication security](https://github.com/samarjeetbisen-22/sih-26035/blob/main/auth_security.py): `auth_security.py`
- [Backend validation](https://github.com/samarjeetbisen-22/sih-26035/blob/main/backend_oiml.py): `backend_oiml.py`

### Review and Oversight

- [Review queue](https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/ReviewerQueueModal.tsx): `frontend/src/components/ReviewerQueueModal.tsx`
- [Owner fleet portal](https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/OwnerPortalModal.tsx): `frontend/src/components/OwnerPortalModal.tsx`
- [Role switcher](https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/AuthRoleSwitcher.tsx): `frontend/src/components/AuthRoleSwitcher.tsx`

### Records and Reporting

- [Application database](https://github.com/samarjeetbisen-22/sih-26035/blob/main/db.py): `db.py`
- [Evidence attachments](https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/AttachmentUploadModal.tsx): `frontend/src/components/AttachmentUploadModal.tsx`
- [Audit history](https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/AuditHistoryModal.tsx): `frontend/src/components/AuditHistoryModal.tsx`
- [Official report](https://github.com/samarjeetbisen-22/sih-26035/blob/main/frontend/src/components/OfficialReportDocument.tsx): `frontend/src/components/OfficialReportDocument.tsx`

### Other components

- **Inspector**
- **Reviewer**
- **Fleet owner**

## Connections

- Inspector → Web application: uses
- Web application → Instrument intake: presents
- Web application → Testing dashboard: presents
- Web application → OIML calculations: calculates
- OIML calculations → Results preview: supplies results
- Web application → API client: requests data
- API client → HTTP API server: calls API
- HTTP API server → Authentication security: authenticates
- HTTP API server → Application database: reads and writes
- HTTP API server → Backend validation: validates readings
- Reviewer → Review queue: uses
- Review queue → API client: requests reviews
- Fleet owner → Owner fleet portal: uses
- Owner fleet portal → API client: requests fleet data
- Web application → Evidence attachments: opens
- Evidence attachments → API client: uploads evidence
- Web application → Audit history: opens
- Audit history → API client: requests history
- Results preview → Official report: renders document
- Role switcher → API client: logs in
- Web application → Official report: requests PDF
