# parts345/metrologyguard-v2-sih2026 architecture

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

- Interactive diagram: https://gitdiagram.com/parts345/metrologyguard-v2-sih2026
- Repository: https://github.com/parts345/metrologyguard-v2-sih2026

## Overview

MetrologyGuard is a packaged-commodities compliance platform for enforcement and review teams. An officer creates an inspection, supplies product details and package-image evidence, then starts analysis; the API persists the record and image, calls the internal OCR/model service, and applies compliance rules. The resulting evidence and violations can be reviewed by an authorised user and exported as traceable PDF or editable DOCX reports. The web app also supports dashboards, calendars, comparison, and product, violation, report, and rules repositories. Unsampled routes and pages are included only where the README or tree establishes their role.

Main entry points: [`apps/web/src/App.tsx`](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/App.tsx) (React application), [`apps/api/src/server.ts`](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/api/src/server.ts) (HTTP orchestration), [`apps/web/src/services/api.ts`](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/services/api.ts) (API client), [`services/ml-service/main.py`](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/services/ml-service/main.py) (Inference gateway)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Operations interface"]
  node_webapp["React application<br/>[App.tsx]"]
  node_inspection_ui["Inspection workflow"]
  node_detail_ui["Inspection evidence"]
  node_ops_views["Operational views<br/>[DashboardPage.tsx]"]
  node_repositories_ui["Compliance repositories"]
  node_calendar_compare["Calendar and comparison<br/>[CalendarPage.tsx]"]
  node_shell["Navigation and search<br/>[AppShell.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["Compliance API"]
  node_api_server["HTTP orchestration<br/>[server.ts]"]
  node_rule_engine["Compliance rules<br/>[rules.ts]"]
end

subgraph group_analysis["Image assessment"]
  node_ml_service["Inference gateway<br/>[main.py]"]
  node_predictor["OCR and field extraction<br/>[predictor.py]"]
end

subgraph group_records["Records and outputs"]
  node_api_db[("SQLite records<br/>[db.ts]")]
  node_uploads[("Image evidence files")]
  node_reporting["Report generation<br/>[reporting.ts]"]
  node_report_files[("Generated reports")]
end

node_officer(("Officer or reviewer"))

node_officer -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_inspection_ui
node_webapp -->|"routes to"| node_detail_ui
node_webapp -->|"routes to"| node_ops_views
node_webapp -->|"routes to"| node_repositories_ui
node_webapp -->|"routes to"| node_calendar_compare
node_webapp -->|"renders"| node_shell
node_inspection_ui -->|"submits requests"| node_api_client
node_detail_ui -->|"loads records"| node_api_client
node_repositories_ui -->|"loads records"| node_api_client
node_shell -->|"searches records"| node_api_client
node_api_client -->|"sends HTTP requests"| node_api_server
node_api_server -->|"reads and writes"| node_api_db
node_api_server -->|"stores and reads images"| node_uploads
node_api_server -->|"sends image for analysis"| node_ml_service
node_ml_service -->|"runs prediction"| node_predictor
node_ml_service -->|"returns inference result"| node_api_server
node_api_server -->|"evaluates results"| node_rule_engine
node_api_server -->|"requests reports"| node_reporting
node_reporting -->|"reads report data"| node_api_db
node_reporting -->|"writes documents"| node_report_files

click node_webapp "https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/App.tsx"
click node_inspection_ui "https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/pages/NewInspectionPage.tsx"
click node_detail_ui "https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/pages/InspectionDetailPage.tsx"
click node_ops_views "https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/pages/DashboardPage.tsx"
click node_repositories_ui "https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/pages/RepositoryPages.tsx"
click node_calendar_compare "https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/pages/CalendarPage.tsx"
click node_shell "https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/components/AppShell.tsx"
click node_api_client "https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/services/api.ts"
click node_api_server "https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/api/src/server.ts"
click node_rule_engine "https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/api/src/rules.ts"
click node_api_db "https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/api/src/db.ts"
click node_uploads "https://github.com/parts345/metrologyguard-v2-sih2026/tree/main/storage/uploads"
click node_ml_service "https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/services/ml-service/main.py"
click node_predictor "https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/services/ml-service/model_bundle/predictor.py"
click node_reporting "https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/api/src/reporting.ts"
click node_report_files "https://github.com/parts345/metrologyguard-v2-sih2026/tree/main/storage/reports"

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_webapp,node_inspection_ui,node_detail_ui,node_ops_views,node_repositories_ui,node_calendar_compare,node_shell,node_api_client,node_officer toneBlue
class node_api_server,node_rule_engine toneAmber
class node_ml_service,node_predictor toneMint
class node_api_db,node_uploads,node_reporting,node_report_files toneRose
```

## Components

### Operations interface

- [React application](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [Inspection workflow](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/pages/NewInspectionPage.tsx): `apps/web/src/pages/NewInspectionPage.tsx`
- [Inspection evidence](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/pages/InspectionDetailPage.tsx): `apps/web/src/pages/InspectionDetailPage.tsx`
- [Operational views](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/pages/DashboardPage.tsx): `apps/web/src/pages/DashboardPage.tsx`
- [Compliance repositories](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/pages/RepositoryPages.tsx): `apps/web/src/pages/RepositoryPages.tsx`
- [Calendar and comparison](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/pages/CalendarPage.tsx): `apps/web/src/pages/CalendarPage.tsx`
- [Navigation and search](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/components/AppShell.tsx): `apps/web/src/components/AppShell.tsx`
- [API client](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/web/src/services/api.ts): `apps/web/src/services/api.ts`

### Compliance API

- [HTTP orchestration](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/api/src/server.ts): `apps/api/src/server.ts`
- [Compliance rules](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/api/src/rules.ts): `apps/api/src/rules.ts`

### Image assessment

- [Inference gateway](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/services/ml-service/main.py): `services/ml-service/main.py`
- [OCR and field extraction](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/services/ml-service/model_bundle/predictor.py): `services/ml-service/model_bundle/predictor.py`

### Records and outputs

- [SQLite records](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/api/src/db.ts): `apps/api/src/db.ts`
- [Image evidence files](https://github.com/parts345/metrologyguard-v2-sih2026/tree/main/storage/uploads): `storage/uploads`
- [Report generation](https://github.com/parts345/metrologyguard-v2-sih2026/blob/main/apps/api/src/reporting.ts): `apps/api/src/reporting.ts`
- [Generated reports](https://github.com/parts345/metrologyguard-v2-sih2026/tree/main/storage/reports): `storage/reports`

### Other components

- **Officer or reviewer**

## Connections

- Officer or reviewer → React application: uses
- React application → Inspection workflow: routes to
- React application → Inspection evidence: routes to
- React application → Operational views: routes to
- React application → Compliance repositories: routes to
- React application → Calendar and comparison: routes to
- React application → Navigation and search: renders
- Inspection workflow → API client: submits requests
- Inspection evidence → API client: loads records
- Compliance repositories → API client: loads records
- Navigation and search → API client: searches records
- API client → HTTP orchestration: sends HTTP requests
- HTTP orchestration → SQLite records: reads and writes
- HTTP orchestration → Image evidence files: stores and reads images
- HTTP orchestration → Inference gateway: sends image for analysis
- Inference gateway → OCR and field extraction: runs prediction
- Inference gateway → HTTP orchestration: returns inference result
- HTTP orchestration → Compliance rules: evaluates results
- HTTP orchestration → Report generation: requests reports
- Report generation → SQLite records: reads report data
- Report generation → Generated reports: writes documents
