# vishalyadav-08/sih26036 architecture

> Architecture diagram of the GitHub repository vishalyadav-08/sih26036, 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/vishalyadav-08/sih26036
- Repository: https://github.com/vishalyadav-08/sih26036

## Overview

MapanSetu is a prototype lifecycle-management system for regulated weighing and measuring instruments, with a Next.js portal, Django API, and separate AI service. The principal workflow runs from instrument registration and a business verification application through officer assignment, scheduling, field inspection and evidence capture, certificate issuance, and public certificate lookup. Offline field work is also supported. The README documents the backend’s views-to-services structure and PostgreSQL system of record; some subsystem links below reflect that documented structure rather than sampled implementation. The AI service is described as bootstrap-stage, so its integration is shown as optional.

Main entry points: [`backend/root/urls.py`](https://github.com/vishalyadav-08/sih26036/blob/master/backend/root/urls.py) (Django API), [`frontend/src/app`](https://github.com/vishalyadav-08/sih26036/tree/master/frontend/src/app) (Business and admin routes), [`frontend/src/app/field`](https://github.com/vishalyadav-08/sih26036/tree/master/frontend/src/app/field) (Field routes), [`backend/certificates/views.py`](https://github.com/vishalyadav-08/sih26036/blob/master/backend/certificates/views.py) (Certificates)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portal["Web portal"]
  node_portal_routes["Business and admin routes"]
  node_field_routes["Field routes"]
  node_verify_route["Certificate lookup"]
  node_auth_service["Authentication<br/>[auth.service.ts]"]
  node_application_client["Application client"]
  node_inspection_client["Inspection client"]
  node_sync_client["Sync client<br/>[sync.service.ts]"]
  node_ai_widget["Assistant widget"]
  node_ai_client["AI client<br/>[ai.service.ts]"]
end

subgraph group_api["Lifecycle API"]
  node_backend["Django API<br/>[urls.py]"]
  node_applications["Applications<br/>[views.py]"]
  node_instruments["Instrument registry<br/>[views.py]"]
  node_scheduling["Officer assignment and scheduling<br/>[views.py]"]
  node_certificates["Certificates<br/>[views.py]"]
end

subgraph group_field["Field operations"]
  node_offline_store[("Offline drafts and queue<br/>[offline-storage.ts]")]
  node_inspections["Inspections and evidence<br/>[views.py]"]
  node_sync["Offline batch processing<br/>[services.py]"]
end

subgraph group_trust["Trust and support"]
  node_notifications["Notifications<br/>[services.py]"]
  node_audit["Audit records<br/>[services.py]"]
  node_database[("PostgreSQL system of record")]
  node_ai_api["AI chat API<br/>[chat.py]"]
end

node_business(("Business user"))
node_officer(("Field officer"))
node_public(("Public verifier"))

node_business -->|"uses"| node_portal_routes
node_officer -->|"uses"| node_field_routes
node_public -->|"looks up"| node_verify_route
node_portal_routes -->|"authenticates via"| node_auth_service
node_portal_routes -->|"submits requests"| node_application_client
node_application_client -->|"HTTP requests"| node_backend
node_field_routes -->|"records inspections"| node_inspection_client
node_inspection_client -->|"HTTP requests"| node_backend
node_field_routes -->|"saves drafts"| node_offline_store
node_offline_store -->|"provides queued work"| node_sync_client
node_sync_client -->|"posts batches"| node_backend
node_backend -->|"routes requests"| node_applications
node_backend -->|"routes requests"| node_instruments
node_backend -->|"routes requests"| node_scheduling
node_backend -->|"routes requests"| node_inspections
node_backend -->|"routes requests"| node_certificates
node_applications -->|"reads and writes"| node_database
node_instruments -->|"reads and writes"| node_database
node_scheduling -->|"reads and writes"| node_database
node_inspections -->|"reads and writes"| node_database
node_certificates -->|"reads and writes"| node_database
node_sync -->|"applies operations via"| node_inspections
node_sync -->|"records sync state"| node_database
node_verify_route -->|"requests verification"| node_certificates
node_ai_widget -.->|"sends chat"| node_ai_client
node_ai_client -.->|"optional request"| node_ai_api

click node_portal_routes "https://github.com/vishalyadav-08/sih26036/tree/master/frontend/src/app"
click node_field_routes "https://github.com/vishalyadav-08/sih26036/tree/master/frontend/src/app/field"
click node_verify_route "https://github.com/vishalyadav-08/sih26036/tree/master/frontend/src/app/verify"
click node_auth_service "https://github.com/vishalyadav-08/sih26036/blob/master/frontend/src/services/auth/auth.service.ts"
click node_application_client "https://github.com/vishalyadav-08/sih26036/blob/master/frontend/src/services/applications/applications.service.ts"
click node_inspection_client "https://github.com/vishalyadav-08/sih26036/blob/master/frontend/src/services/inspections/inspections.service.ts"
click node_sync_client "https://github.com/vishalyadav-08/sih26036/blob/master/frontend/src/services/sync/sync.service.ts"
click node_offline_store "https://github.com/vishalyadav-08/sih26036/blob/master/frontend/src/lib/offline-storage.ts"
click node_backend "https://github.com/vishalyadav-08/sih26036/blob/master/backend/root/urls.py"
click node_applications "https://github.com/vishalyadav-08/sih26036/blob/master/backend/applications/views.py"
click node_instruments "https://github.com/vishalyadav-08/sih26036/blob/master/backend/instruments/views.py"
click node_scheduling "https://github.com/vishalyadav-08/sih26036/blob/master/backend/scheduling/views.py"
click node_inspections "https://github.com/vishalyadav-08/sih26036/blob/master/backend/inspections/views.py"
click node_certificates "https://github.com/vishalyadav-08/sih26036/blob/master/backend/certificates/views.py"
click node_sync "https://github.com/vishalyadav-08/sih26036/blob/master/backend/sync/services.py"
click node_notifications "https://github.com/vishalyadav-08/sih26036/blob/master/backend/notifications/services.py"
click node_audit "https://github.com/vishalyadav-08/sih26036/blob/master/backend/audit/services.py"
click node_ai_widget "https://github.com/vishalyadav-08/sih26036/blob/master/frontend/src/components/assistant/AssistantWidget.tsx"
click node_ai_client "https://github.com/vishalyadav-08/sih26036/blob/master/frontend/src/services/ai/ai.service.ts"
click node_ai_api "https://github.com/vishalyadav-08/sih26036/blob/master/ai-service/app/api/chat.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_portal_routes,node_field_routes,node_verify_route,node_auth_service,node_application_client,node_inspection_client,node_sync_client,node_ai_widget,node_ai_client,node_business toneBlue
class node_backend,node_applications,node_instruments,node_scheduling,node_certificates toneAmber
class node_offline_store,node_inspections,node_sync toneMint
class node_notifications,node_audit,node_database,node_ai_api toneRose
class node_officer,node_public toneIndigo
```

## Components

### Web portal

- [Business and admin routes](https://github.com/vishalyadav-08/sih26036/tree/master/frontend/src/app): `frontend/src/app`
- [Field routes](https://github.com/vishalyadav-08/sih26036/tree/master/frontend/src/app/field): `frontend/src/app/field`
- [Certificate lookup](https://github.com/vishalyadav-08/sih26036/tree/master/frontend/src/app/verify): `frontend/src/app/verify`
- [Authentication](https://github.com/vishalyadav-08/sih26036/blob/master/frontend/src/services/auth/auth.service.ts): `frontend/src/services/auth/auth.service.ts`
- [Application client](https://github.com/vishalyadav-08/sih26036/blob/master/frontend/src/services/applications/applications.service.ts): `frontend/src/services/applications/applications.service.ts`
- [Inspection client](https://github.com/vishalyadav-08/sih26036/blob/master/frontend/src/services/inspections/inspections.service.ts): `frontend/src/services/inspections/inspections.service.ts`
- [Sync client](https://github.com/vishalyadav-08/sih26036/blob/master/frontend/src/services/sync/sync.service.ts): `frontend/src/services/sync/sync.service.ts`
- [Assistant widget](https://github.com/vishalyadav-08/sih26036/blob/master/frontend/src/components/assistant/AssistantWidget.tsx): `frontend/src/components/assistant/AssistantWidget.tsx`
- [AI client](https://github.com/vishalyadav-08/sih26036/blob/master/frontend/src/services/ai/ai.service.ts): `frontend/src/services/ai/ai.service.ts`

### Lifecycle API

- [Django API](https://github.com/vishalyadav-08/sih26036/blob/master/backend/root/urls.py): `backend/root/urls.py`
- [Applications](https://github.com/vishalyadav-08/sih26036/blob/master/backend/applications/views.py): `backend/applications/views.py`
- [Instrument registry](https://github.com/vishalyadav-08/sih26036/blob/master/backend/instruments/views.py): `backend/instruments/views.py`
- [Officer assignment and scheduling](https://github.com/vishalyadav-08/sih26036/blob/master/backend/scheduling/views.py): `backend/scheduling/views.py`
- [Certificates](https://github.com/vishalyadav-08/sih26036/blob/master/backend/certificates/views.py): `backend/certificates/views.py`

### Field operations

- [Offline drafts and queue](https://github.com/vishalyadav-08/sih26036/blob/master/frontend/src/lib/offline-storage.ts): `frontend/src/lib/offline-storage.ts`
- [Inspections and evidence](https://github.com/vishalyadav-08/sih26036/blob/master/backend/inspections/views.py): `backend/inspections/views.py`
- [Offline batch processing](https://github.com/vishalyadav-08/sih26036/blob/master/backend/sync/services.py): `backend/sync/services.py`

### Trust and support

- [Notifications](https://github.com/vishalyadav-08/sih26036/blob/master/backend/notifications/services.py): `backend/notifications/services.py`
- [Audit records](https://github.com/vishalyadav-08/sih26036/blob/master/backend/audit/services.py): `backend/audit/services.py`
- **PostgreSQL system of record**
- [AI chat API](https://github.com/vishalyadav-08/sih26036/blob/master/ai-service/app/api/chat.py): `ai-service/app/api/chat.py`

### Other components

- **Business user**
- **Field officer**
- **Public verifier**

## Connections

- Business user → Business and admin routes: uses
- Field officer → Field routes: uses
- Public verifier → Certificate lookup: looks up
- Business and admin routes → Authentication: authenticates via
- Business and admin routes → Application client: submits requests
- Application client → Django API: HTTP requests
- Field routes → Inspection client: records inspections
- Inspection client → Django API: HTTP requests
- Field routes → Offline drafts and queue: saves drafts
- Offline drafts and queue → Sync client: provides queued work
- Sync client → Django API: posts batches
- Django API → Applications: routes requests
- Django API → Instrument registry: routes requests
- Django API → Officer assignment and scheduling: routes requests
- Django API → Inspections and evidence: routes requests
- Django API → Certificates: routes requests
- Applications → PostgreSQL system of record: reads and writes
- Instrument registry → PostgreSQL system of record: reads and writes
- Officer assignment and scheduling → PostgreSQL system of record: reads and writes
- Inspections and evidence → PostgreSQL system of record: reads and writes
- Certificates → PostgreSQL system of record: reads and writes
- Offline batch processing → Inspections and evidence: applies operations via
- Offline batch processing → PostgreSQL system of record: records sync state
- Certificate lookup → Certificates: requests verification
- Assistant widget → AI client: sends chat
- AI client → AI chat API: optional request
