# shivam-dev30/road-saathi architecture

> Architecture diagram of the GitHub repository shivam-dev30/road-saathi, 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/shivam-dev30/road-saathi
- Repository: https://github.com/shivam-dev30/road-saathi

## Overview

Road Saathi lets citizens report road hazards, receive AI-assisted damage assessments, and submit geotagged complaints; departmental staff then triage reports and track progress. The frontend also presents complaint statistics and a geographic heatmap. The backend routes authentication, complaint, statistics, and analysis requests to Django views, which use serializers and complaint records or invoke the vision pipeline. That pipeline combines local computer vision with Groq and Gemini analysis. Several frontend and view details are unsampled, so the graph uses documented capabilities and only evidenced or explicitly documented connections.

Main entry points: [`frontend/app.js`](https://github.com/shivam-dev30/road-saathi/blob/main/frontend/app.js) (Reporting interface), [`backend/api/views.py`](https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/views.py) (Request handlers), [`backend/api/services/ai_service.py`](https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/services/ai_service.py) (Analysis orchestrator), [`backend/api/models.py`](https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/models.py) (Complaint records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_citizen["Citizen reporting"]
  node_frontend["Reporting interface<br/>[app.js]"]
  node_geotag["Photo geotagging<br/>[app.js]"]
  node_ticket["Ticket autofill<br/>[app.js]"]
end

subgraph group_api["API and complaints"]
  node_routes["API routes<br/>[urls.py]"]
  node_views["Request handlers<br/>[views.py]"]
  node_serializers["API serializers<br/>[serializers.py]"]
  node_complaints["Complaint records<br/>[models.py]"]
  node_database[("Application database")]
end

subgraph group_vision["Damage analysis"]
  node_ai["Analysis orchestrator<br/>[ai_service.py]"]
  node_localcv["Local vision scanner<br/>[road_damage.py]"]
  node_groq["Groq vision service<br/>[groq_service.py]"]
  node_gemini["Gemini vision service<br/>[gemini_service.py]"]
end

subgraph group_operations["Department operations"]
  node_timeline["Status timeline<br/>[models.py]"]
  node_departments["Department dashboards<br/>[app.js]"]
  node_heatmap["Hazard heatmap<br/>[app.js]"]
end

node_citizen(("Citizen"))
node_groqapi{{"Groq API"}}
node_geminiai{{"Gemini API"}}

node_citizen -->|"submits report"| node_frontend
node_frontend -->|"validates photo"| node_geotag
node_frontend -->|"accepts analysis"| node_ticket
node_frontend -->|"calls analysis API"| node_routes
node_frontend -->|"submits complaint"| node_routes
node_routes -->|"routes requests"| node_views
node_views -->|"invokes analysis"| node_ai
node_ai -->|"scans image"| node_localcv
node_ai -->|"requests assessment"| node_groq
node_ai -->|"falls back"| node_gemini
node_groq -->|"calls model API"| node_groqapi
node_gemini -->|"calls model API"| node_geminiai
node_views -->|"serializes responses"| node_serializers
node_serializers -->|"serializes records"| node_complaints
node_views -->|"creates and queries"| node_complaints
node_complaints -.->|"persists records"| node_database
node_frontend -->|"renders dashboards"| node_departments
node_frontend -->|"renders locations"| node_heatmap
node_departments -.->|"requests complaint data"| node_routes
node_complaints -->|"tracks status stages"| node_timeline

click node_frontend "https://github.com/shivam-dev30/road-saathi/blob/main/frontend/app.js"
click node_geotag "https://github.com/shivam-dev30/road-saathi/blob/main/frontend/app.js"
click node_ticket "https://github.com/shivam-dev30/road-saathi/blob/main/frontend/app.js"
click node_routes "https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/urls.py"
click node_views "https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/views.py"
click node_serializers "https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/serializers.py"
click node_complaints "https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/models.py"
click node_timeline "https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/models.py"
click node_departments "https://github.com/shivam-dev30/road-saathi/blob/main/frontend/app.js"
click node_heatmap "https://github.com/shivam-dev30/road-saathi/blob/main/frontend/app.js"
click node_ai "https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/services/ai_service.py"
click node_localcv "https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/services/road_damage.py"
click node_groq "https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/services/groq_service.py"
click node_gemini "https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/services/gemini_service.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_frontend,node_geotag,node_ticket toneBlue
class node_routes,node_views,node_serializers,node_complaints,node_database toneAmber
class node_ai,node_localcv,node_groq,node_gemini,node_groqapi,node_geminiai toneMint
class node_timeline,node_departments,node_heatmap toneRose
class node_citizen toneIndigo
```

## Components

### Citizen reporting

- [Reporting interface](https://github.com/shivam-dev30/road-saathi/blob/main/frontend/app.js): `frontend/app.js`
- [Photo geotagging](https://github.com/shivam-dev30/road-saathi/blob/main/frontend/app.js): `frontend/app.js`
- [Ticket autofill](https://github.com/shivam-dev30/road-saathi/blob/main/frontend/app.js): `frontend/app.js`

### API and complaints

- [API routes](https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/urls.py): `backend/api/urls.py`
- [Request handlers](https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/views.py): `backend/api/views.py`
- [API serializers](https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/serializers.py): `backend/api/serializers.py`
- [Complaint records](https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/models.py): `backend/api/models.py`
- **Application database**

### Damage analysis

- [Analysis orchestrator](https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/services/ai_service.py): `backend/api/services/ai_service.py`
- [Local vision scanner](https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/services/road_damage.py): `backend/api/services/road_damage.py`
- [Groq vision service](https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/services/groq_service.py): `backend/api/services/groq_service.py`
- [Gemini vision service](https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/services/gemini_service.py): `backend/api/services/gemini_service.py`

### Department operations

- [Status timeline](https://github.com/shivam-dev30/road-saathi/blob/main/backend/api/models.py): `backend/api/models.py`
- [Department dashboards](https://github.com/shivam-dev30/road-saathi/blob/main/frontend/app.js): `frontend/app.js`
- [Hazard heatmap](https://github.com/shivam-dev30/road-saathi/blob/main/frontend/app.js): `frontend/app.js`

### Other components

- **Citizen**
- **Groq API**
- **Gemini API**

## Connections

- Citizen → Reporting interface: submits report (evidence: `README.md`)
- Reporting interface → Photo geotagging: validates photo (evidence: `README.md`)
- Reporting interface → Ticket autofill: accepts analysis (evidence: `README.md`)
- Reporting interface → API routes: calls analysis API (evidence: `frontend/app.js`)
- Reporting interface → API routes: submits complaint (evidence: `README.md`)
- API routes → Request handlers: routes requests (evidence: `backend/api/urls.py`)
- Request handlers → Analysis orchestrator: invokes analysis (evidence: `backend/api/views.py`)
- Analysis orchestrator → Local vision scanner: scans image (evidence: `backend/api/services/ai_service.py`)
- Analysis orchestrator → Groq vision service: requests assessment (evidence: `backend/api/services/ai_service.py`)
- Analysis orchestrator → Gemini vision service: falls back (evidence: `backend/api/services/ai_service.py`)
- Groq vision service → Groq API: calls model API (evidence: `backend/api/services/groq_service.py`)
- Gemini vision service → Gemini API: calls model API (evidence: `backend/api/services/gemini_service.py`)
- Request handlers → API serializers: serializes responses (evidence: `backend/api/views.py`)
- API serializers → Complaint records: serializes records (evidence: `backend/api/serializers.py`)
- Request handlers → Complaint records: creates and queries (evidence: `backend/api/views.py`)
- Complaint records → Application database: persists records
- Reporting interface → Department dashboards: renders dashboards (evidence: `README.md`)
- Reporting interface → Hazard heatmap: renders locations (evidence: `README.md`)
- Department dashboards → API routes: requests complaint data
- Complaint records → Status timeline: tracks status stages (evidence: `backend/api/models.py`)
