# anand-cpp/sih_2026 architecture

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

- Interactive diagram: https://gitdiagram.com/anand-cpp/sih_2026
- Repository: https://github.com/anand-cpp/sih_2026

## Overview

MAAP-NAWI is an offline Electron desktop application for producing and verifying regulated OIML R 76 evaluation reports. Its principal workflow captures instrument details, records guided bench observations, computes clause-traceable verdicts, then seals and exports a report that can later be reproduced. Separate governance capabilities manage versioned rulebooks, regression checks, permissions and audit integrity. The graph combines README-documented workflow with source-index references; unsampled implementation details are represented only where their subsystem is clear.

Main entry points: [`src/application/report.service.ts`](https://github.com/anand-cpp/sih_2026/blob/main/src/application/report.service.ts) (Report finalization), [`src/domain/metrology/evaluation.ts`](https://github.com/anand-cpp/sih_2026/blob/main/src/domain/metrology/evaluation.ts) (Metrology evaluation), [`src/renderer/App.tsx`](https://github.com/anand-cpp/sih_2026/blob/main/src/renderer/App.tsx) (Application shell), [`src/application/observation.service.ts`](https://github.com/anand-cpp/sih_2026/blob/main/src/application/observation.service.ts) (Observation capture)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop experience"]
  node_electron["Electron main<br/>[main.ts]"]
  node_preload["Preload bridge<br/>[index.ts]"]
  node_ipc["IPC contracts<br/>[ipc.ts]"]
  node_app["Application shell<br/>[App.tsx]"]
  node_intakeui["Intake screen<br/>[IntakeScreen.tsx]"]
  node_benchui["Bench screen<br/>[BenchScreen.tsx]"]
  node_traceui["Verification trace<br/>[TraceScreen.tsx]"]
  node_repo_ui["Report repository UI"]
end

subgraph group_workflow["Evaluation workflow"]
  node_intake["Instrument intake<br/>[intake.service.ts]"]
  node_observations["Observation capture"]
  node_reports["Report finalization<br/>[report.service.ts]"]
end

subgraph group_engines["Domain engines"]
  node_evaluation["Metrology evaluation<br/>[evaluation.ts]"]
  node_decimal["Exact decimals<br/>[decimal.ts]"]
  node_changeover["Changeover derivation<br/>[changeover.ts]"]
  node_rule_engine["Rulebook engine<br/>[engine.ts]"]
  node_report_document["Canonical report document<br/>[document.ts]"]
  node_canonical["Canonical hash<br/>[index.ts]"]
end

subgraph group_governance["Governance and records"]
  node_rule_service["Rulebook governance"]
  node_audit["Audit service<br/>[audit.service.ts]"]
  node_policy["Role permissions<br/>[policy.ts]"]
end

subgraph group_storage["Local persistence and exports"]
  node_sessions[("Dossier storage")]
  node_report_store[("Report storage")]
  node_rule_store[("Rulebook storage")]
  node_exports["PDF and DOCX export"]
end

node_operator(("Lab operator"))

node_operator -->|"enters instrument"| node_intakeui
node_intakeui -.->|"submits intake"| node_intake
node_intake -->|"opens bench"| node_observations
node_benchui -.->|"records readings"| node_observations
node_observations -->|"evaluates observations"| node_evaluation
node_evaluation -->|"uses exact arithmetic"| node_decimal
node_evaluation -->|"derives changeover"| node_changeover
node_evaluation -->|"looks up rules"| node_rule_engine
node_evaluation -->|"feeds finalization"| node_reports
node_rule_service -->|"validates candidates"| node_rule_engine
node_rule_service -->|"manages versions"| node_rule_store
node_reports -->|"builds report"| node_report_document
node_reports -->|"seals canonical data"| node_canonical
node_reports -->|"generates documents"| node_exports
node_reports -->|"seals report"| node_report_store
node_reports -->|"appends audit event"| node_audit
node_intake -->|"creates dossier"| node_sessions
node_observations -->|"stores readings"| node_sessions
node_traceui -->|"requests reproduction"| node_reports
node_repo_ui -->|"finalizes or reproduces"| node_reports
node_app -->|"routes to intake"| node_intakeui
node_app -->|"routes to bench"| node_benchui
node_app -->|"routes to trace"| node_traceui
node_app -->|"routes to repository"| node_repo_ui
node_electron -.->|"exposes bridge"| node_preload
node_preload -->|"uses contracts"| node_ipc
node_audit -->|"checks permissions"| node_policy

click node_electron "https://github.com/anand-cpp/sih_2026/blob/main/src/electron/main.ts"
click node_preload "https://github.com/anand-cpp/sih_2026/blob/main/src/preload/index.ts"
click node_ipc "https://github.com/anand-cpp/sih_2026/blob/main/src/shared/ipc.ts"
click node_app "https://github.com/anand-cpp/sih_2026/blob/main/src/renderer/App.tsx"
click node_intakeui "https://github.com/anand-cpp/sih_2026/blob/main/src/renderer/screens/IntakeScreen.tsx"
click node_benchui "https://github.com/anand-cpp/sih_2026/blob/main/src/renderer/screens/BenchScreen.tsx"
click node_traceui "https://github.com/anand-cpp/sih_2026/blob/main/src/renderer/screens/TraceScreen.tsx"
click node_repo_ui "https://github.com/anand-cpp/sih_2026/blob/main/src/renderer/screens/RepositoryScreen.tsx"
click node_intake "https://github.com/anand-cpp/sih_2026/blob/main/src/application/intake.service.ts"
click node_observations "https://github.com/anand-cpp/sih_2026/blob/main/src/application/observation.service.ts"
click node_evaluation "https://github.com/anand-cpp/sih_2026/blob/main/src/domain/metrology/evaluation.ts"
click node_decimal "https://github.com/anand-cpp/sih_2026/blob/main/src/domain/metrology/decimal.ts"
click node_changeover "https://github.com/anand-cpp/sih_2026/blob/main/src/domain/metrology/changeover.ts"
click node_rule_engine "https://github.com/anand-cpp/sih_2026/blob/main/src/domain/rulebook/engine.ts"
click node_rule_service "https://github.com/anand-cpp/sih_2026/blob/main/src/application/rulebook.service.ts"
click node_reports "https://github.com/anand-cpp/sih_2026/blob/main/src/application/report.service.ts"
click node_report_document "https://github.com/anand-cpp/sih_2026/blob/main/src/domain/reports/document.ts"
click node_canonical "https://github.com/anand-cpp/sih_2026/blob/main/src/domain/canonical/index.ts"
click node_audit "https://github.com/anand-cpp/sih_2026/blob/main/src/application/audit.service.ts"
click node_policy "https://github.com/anand-cpp/sih_2026/blob/main/src/domain/access/policy.ts"
click node_sessions "https://github.com/anand-cpp/sih_2026/blob/main/src/infrastructure/db/repositories/session.repository.ts"
click node_report_store "https://github.com/anand-cpp/sih_2026/blob/main/src/infrastructure/db/repositories/report.repository.ts"
click node_rule_store "https://github.com/anand-cpp/sih_2026/blob/main/src/infrastructure/db/repositories/rulebook.repository.ts"
click node_exports "https://github.com/anand-cpp/sih_2026/tree/main/src/infrastructure/export"

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_electron,node_preload,node_ipc,node_app,node_intakeui,node_benchui,node_traceui,node_repo_ui toneBlue
class node_intake,node_observations,node_reports toneAmber
class node_evaluation,node_decimal,node_changeover,node_rule_engine,node_report_document,node_canonical toneMint
class node_rule_service,node_audit,node_policy toneRose
class node_sessions,node_report_store,node_rule_store,node_exports,node_operator toneIndigo
```

## Components

### Desktop experience

- [Electron main](https://github.com/anand-cpp/sih_2026/blob/main/src/electron/main.ts): `src/electron/main.ts`
- [Preload bridge](https://github.com/anand-cpp/sih_2026/blob/main/src/preload/index.ts): `src/preload/index.ts`
- [IPC contracts](https://github.com/anand-cpp/sih_2026/blob/main/src/shared/ipc.ts): `src/shared/ipc.ts`
- [Application shell](https://github.com/anand-cpp/sih_2026/blob/main/src/renderer/App.tsx): `src/renderer/App.tsx`
- [Intake screen](https://github.com/anand-cpp/sih_2026/blob/main/src/renderer/screens/IntakeScreen.tsx): `src/renderer/screens/IntakeScreen.tsx`
- [Bench screen](https://github.com/anand-cpp/sih_2026/blob/main/src/renderer/screens/BenchScreen.tsx): `src/renderer/screens/BenchScreen.tsx`
- [Verification trace](https://github.com/anand-cpp/sih_2026/blob/main/src/renderer/screens/TraceScreen.tsx): `src/renderer/screens/TraceScreen.tsx`
- [Report repository UI](https://github.com/anand-cpp/sih_2026/blob/main/src/renderer/screens/RepositoryScreen.tsx): `src/renderer/screens/RepositoryScreen.tsx`

### Evaluation workflow

- [Instrument intake](https://github.com/anand-cpp/sih_2026/blob/main/src/application/intake.service.ts): `src/application/intake.service.ts`
- [Observation capture](https://github.com/anand-cpp/sih_2026/blob/main/src/application/observation.service.ts): `src/application/observation.service.ts`
- [Report finalization](https://github.com/anand-cpp/sih_2026/blob/main/src/application/report.service.ts): `src/application/report.service.ts`

### Domain engines

- [Metrology evaluation](https://github.com/anand-cpp/sih_2026/blob/main/src/domain/metrology/evaluation.ts): `src/domain/metrology/evaluation.ts`
- [Exact decimals](https://github.com/anand-cpp/sih_2026/blob/main/src/domain/metrology/decimal.ts): `src/domain/metrology/decimal.ts`
- [Changeover derivation](https://github.com/anand-cpp/sih_2026/blob/main/src/domain/metrology/changeover.ts): `src/domain/metrology/changeover.ts`
- [Rulebook engine](https://github.com/anand-cpp/sih_2026/blob/main/src/domain/rulebook/engine.ts): `src/domain/rulebook/engine.ts`
- [Canonical report document](https://github.com/anand-cpp/sih_2026/blob/main/src/domain/reports/document.ts): `src/domain/reports/document.ts`
- [Canonical hash](https://github.com/anand-cpp/sih_2026/blob/main/src/domain/canonical/index.ts): `src/domain/canonical/index.ts`

### Governance and records

- [Rulebook governance](https://github.com/anand-cpp/sih_2026/blob/main/src/application/rulebook.service.ts): `src/application/rulebook.service.ts`
- [Audit service](https://github.com/anand-cpp/sih_2026/blob/main/src/application/audit.service.ts): `src/application/audit.service.ts`
- [Role permissions](https://github.com/anand-cpp/sih_2026/blob/main/src/domain/access/policy.ts): `src/domain/access/policy.ts`

### Local persistence and exports

- [Dossier storage](https://github.com/anand-cpp/sih_2026/blob/main/src/infrastructure/db/repositories/session.repository.ts): `src/infrastructure/db/repositories/session.repository.ts`
- [Report storage](https://github.com/anand-cpp/sih_2026/blob/main/src/infrastructure/db/repositories/report.repository.ts): `src/infrastructure/db/repositories/report.repository.ts`
- [Rulebook storage](https://github.com/anand-cpp/sih_2026/blob/main/src/infrastructure/db/repositories/rulebook.repository.ts): `src/infrastructure/db/repositories/rulebook.repository.ts`
- [PDF and DOCX export](https://github.com/anand-cpp/sih_2026/tree/main/src/infrastructure/export): `src/infrastructure/export`

### Other components

- **Lab operator**

## Connections

- Lab operator → Intake screen: enters instrument (evidence: `README.md`)
- Intake screen → Instrument intake: submits intake
- Instrument intake → Observation capture: opens bench (evidence: `README.md`)
- Bench screen → Observation capture: records readings
- Observation capture → Metrology evaluation: evaluates observations (evidence: `src/application/observation.service.ts`)
- Metrology evaluation → Exact decimals: uses exact arithmetic (evidence: `src/domain/metrology/evaluation.ts`)
- Metrology evaluation → Changeover derivation: derives changeover (evidence: `src/domain/metrology/evaluation.ts`)
- Metrology evaluation → Rulebook engine: looks up rules (evidence: `src/domain/metrology/evaluation.ts`)
- Metrology evaluation → Report finalization: feeds finalization (evidence: `README.md`)
- Rulebook governance → Rulebook engine: validates candidates (evidence: `src/application/rulebook.service.ts`)
- Rulebook governance → Rulebook storage: manages versions (evidence: `src/application/rulebook.service.ts`)
- Report finalization → Canonical report document: builds report (evidence: `src/application/report.service.ts`)
- Report finalization → Canonical hash: seals canonical data (evidence: `README.md`)
- Report finalization → PDF and DOCX export: generates documents (evidence: `src/application/report.service.ts`)
- Report finalization → Report storage: seals report (evidence: `src/application/report.service.ts`)
- Report finalization → Audit service: appends audit event (evidence: `src/application/report.service.ts`)
- Instrument intake → Dossier storage: creates dossier (evidence: `src/application/intake.service.ts`)
- Observation capture → Dossier storage: stores readings (evidence: `src/application/observation.service.ts`)
- Verification trace → Report finalization: requests reproduction (evidence: `README.md`)
- Report repository UI → Report finalization: finalizes or reproduces (evidence: `README.md`)
- Application shell → Intake screen: routes to intake (evidence: `src/renderer/App.tsx`)
- Application shell → Bench screen: routes to bench (evidence: `src/renderer/App.tsx`)
- Application shell → Verification trace: routes to trace (evidence: `src/renderer/App.tsx`)
- Application shell → Report repository UI: routes to repository (evidence: `src/renderer/App.tsx`)
- Electron main → Preload bridge: exposes bridge
- Preload bridge → IPC contracts: uses contracts (evidence: `src/preload/index.ts`)
- Audit service → Role permissions: checks permissions (evidence: `src/application/audit.service.ts`)
