# triyanshag777/jalmarg architecture

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

## Overview

JalMarg combines a municipal operations dashboard with a FastAPI service for citizen flood reports, hotspot risk assessment, flood-aware routing, and human-reviewed dispatch plans. The main path is a citizen submitting an image report, the report orchestrator coordinating verification and analysis, and resulting data informing hotspot risk and authority decisions. Separate dashboard functions expose map, weather, routing, and approval workflows. The graph reflects documented endpoints and the sampled backend relationships; frontend-to-API calls and several unsampled integrations are not asserted where their wiring is not shown.

Main entry points: [`backend/app/services/agent_tools.py`](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/agent_tools.py) (Agent tools), [`backend/app/db/crud.py`](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/db/crud.py) (Persistence operations), [`backend/app/main.py`](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/main.py) (API application), [`backend/app/services/route_service.py`](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/route_service.py) (Route exposure scoring)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Operations dashboard"]
  node_report_ui["Report submission<br/>[page.tsx]"]
  node_map_ui["Flood map<br/>[FloodMap.tsx]"]
  node_hotspot_panel["Hotspot details"]
  node_route_ui["Route comparison<br/>[page.tsx]"]
  node_authority_ui["Authority console<br/>[page.tsx]"]
end

subgraph group_api["Backend API"]
  node_app["API application<br/>[main.py]"]
  node_reports_api["Report endpoints<br/>[reports.py]"]
  node_hotspots_api["Hotspot endpoints<br/>[hotspots.py]"]
  node_weather_api["Weather and risk API<br/>[weather.py]"]
  node_routing_api["Routing endpoint<br/>[routing.py]"]
  node_admin_api["Dispatch approval API<br/>[admin.py]"]
end

subgraph group_analysis["Report and risk analysis"]
  node_orchestrator["Report orchestrator<br/>[orchestrator.py]"]
  node_workflow["Report workflow<br/>[workflow.py]"]
  node_verification["Image verification"]
  node_vision["Vision analysis<br/>[gemini_vision.py]"]
  node_agent_tools["Agent tools<br/>[agent_tools.py]"]
  node_weather_service["Weather retrieval<br/>[weather_service.py]"]
  node_risk_service["Risk scoring<br/>[risk_service.py]"]
end

subgraph group_routing["Routing and dispatch"]
  node_route_service["Route exposure scoring<br/>[route_service.py]"]
  node_tinyfish["Civic information retrieval"]
end

subgraph group_persistence["Data persistence"]
  node_sqlite[("SQLite database<br/>[models.py]")]
  node_crud["Persistence operations<br/>[crud.py]"]
  node_seed["Demo data initialization<br/>[seed_data.py]"]
end

node_citizen(("Citizen"))
node_authority(("Authority operator"))
node_osrm["OSRM routing"]
node_open_meteo["Open-Meteo"]
node_gemini["Gemini"]

node_citizen -.->|"submits report"| node_report_ui
node_authority -.->|"reviews plans"| node_authority_ui
node_app -->|"mounts routes"| node_reports_api
node_app -->|"mounts routes"| node_hotspots_api
node_app -->|"mounts routes"| node_weather_api
node_app -->|"mounts routes"| node_routing_api
node_app -->|"mounts routes"| node_admin_api
node_reports_api -->|"invokes"| node_orchestrator
node_orchestrator -->|"uses tools"| node_agent_tools
node_workflow -->|"uses"| node_verification
node_workflow -->|"uses"| node_vision
node_agent_tools -->|"uses"| node_verification
node_agent_tools -->|"uses"| node_vision
node_agent_tools -->|"uses"| node_weather_service
node_agent_tools -->|"uses"| node_risk_service
node_agent_tools -->|"uses"| node_route_service
node_agent_tools -->|"uses"| node_tinyfish
node_vision -.->|"analyzes images"| node_gemini
node_weather_service -->|"fetches forecast"| node_open_meteo
node_weather_api -->|"refreshes weather"| node_weather_service
node_weather_api -->|"recalculates risk"| node_risk_service
node_risk_service -->|"reads reports"| node_crud
node_routing_api -->|"requests candidates"| node_route_service
node_route_service -->|"fetches routes"| node_osrm
node_route_service -->|"loads hotspots"| node_crud
node_reports_api -->|"persists reports"| node_crud
node_hotspots_api -.->|"queries hotspots"| node_crud
node_admin_api -->|"updates plans"| node_crud
node_crud -->|"reads and writes"| node_sqlite
node_seed -->|"seeds records"| node_sqlite
node_seed -->|"calculates initial risk"| node_risk_service

click node_report_ui "https://github.com/triyanshag777/jalmarg/blob/main/frontend/src/app/report/page.tsx"
click node_map_ui "https://github.com/triyanshag777/jalmarg/blob/main/frontend/src/components/map/FloodMap.tsx"
click node_hotspot_panel "https://github.com/triyanshag777/jalmarg/blob/main/frontend/src/components/HotspotDetailPanel.tsx"
click node_route_ui "https://github.com/triyanshag777/jalmarg/blob/main/frontend/src/app/routes/page.tsx"
click node_authority_ui "https://github.com/triyanshag777/jalmarg/blob/main/frontend/src/app/authority/page.tsx"
click node_app "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/main.py"
click node_reports_api "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/api/reports.py"
click node_hotspots_api "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/api/hotspots.py"
click node_weather_api "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/api/weather.py"
click node_routing_api "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/api/routing.py"
click node_admin_api "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/api/admin.py"
click node_orchestrator "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/orchestrator.py"
click node_workflow "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/workflow.py"
click node_verification "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/image_verification.py"
click node_vision "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/gemini_vision.py"
click node_agent_tools "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/agent_tools.py"
click node_weather_service "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/weather_service.py"
click node_risk_service "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/risk_service.py"
click node_route_service "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/route_service.py"
click node_tinyfish "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/tinyfish_service.py"
click node_sqlite "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/db/models.py"
click node_crud "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/db/crud.py"
click node_seed "https://github.com/triyanshag777/jalmarg/blob/main/backend/app/seed/seed_data.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_report_ui,node_map_ui,node_hotspot_panel,node_route_ui,node_authority_ui toneBlue
class node_app,node_reports_api,node_hotspots_api,node_weather_api,node_routing_api,node_admin_api toneAmber
class node_orchestrator,node_workflow,node_verification,node_vision,node_agent_tools,node_weather_service,node_risk_service toneMint
class node_route_service,node_tinyfish toneRose
class node_sqlite,node_crud,node_seed,node_citizen,node_authority,node_osrm,node_open_meteo,node_gemini toneIndigo
```

## Components

### Operations dashboard

- [Report submission](https://github.com/triyanshag777/jalmarg/blob/main/frontend/src/app/report/page.tsx): `frontend/src/app/report/page.tsx`
- [Flood map](https://github.com/triyanshag777/jalmarg/blob/main/frontend/src/components/map/FloodMap.tsx): `frontend/src/components/map/FloodMap.tsx`
- [Hotspot details](https://github.com/triyanshag777/jalmarg/blob/main/frontend/src/components/HotspotDetailPanel.tsx): `frontend/src/components/HotspotDetailPanel.tsx`
- [Route comparison](https://github.com/triyanshag777/jalmarg/blob/main/frontend/src/app/routes/page.tsx): `frontend/src/app/routes/page.tsx`
- [Authority console](https://github.com/triyanshag777/jalmarg/blob/main/frontend/src/app/authority/page.tsx): `frontend/src/app/authority/page.tsx`

### Backend API

- [API application](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/main.py): `backend/app/main.py`
- [Report endpoints](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/api/reports.py): `backend/app/api/reports.py`
- [Hotspot endpoints](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/api/hotspots.py): `backend/app/api/hotspots.py`
- [Weather and risk API](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/api/weather.py): `backend/app/api/weather.py`
- [Routing endpoint](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/api/routing.py): `backend/app/api/routing.py`
- [Dispatch approval API](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/api/admin.py): `backend/app/api/admin.py`

### Report and risk analysis

- [Report orchestrator](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/orchestrator.py): `backend/app/services/orchestrator.py`
- [Report workflow](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/workflow.py): `backend/app/services/workflow.py`
- [Image verification](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/image_verification.py): `backend/app/services/image_verification.py`
- [Vision analysis](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/gemini_vision.py): `backend/app/services/gemini_vision.py`
- [Agent tools](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/agent_tools.py): `backend/app/services/agent_tools.py`
- [Weather retrieval](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/weather_service.py): `backend/app/services/weather_service.py`
- [Risk scoring](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/risk_service.py): `backend/app/services/risk_service.py`

### Routing and dispatch

- [Route exposure scoring](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/route_service.py): `backend/app/services/route_service.py`
- [Civic information retrieval](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/services/tinyfish_service.py): `backend/app/services/tinyfish_service.py`

### Data persistence

- [SQLite database](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/db/models.py): `backend/app/db/models.py`
- [Persistence operations](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/db/crud.py): `backend/app/db/crud.py`
- [Demo data initialization](https://github.com/triyanshag777/jalmarg/blob/main/backend/app/seed/seed_data.py): `backend/app/seed/seed_data.py`

### Other components

- **Citizen**
- **Authority operator**
- **OSRM routing**
- **Open-Meteo**
- **Gemini**

## Connections

- Citizen → Report submission: submits report
- Authority operator → Authority console: reviews plans
- API application → Report endpoints: mounts routes (evidence: `backend/app/main.py`)
- API application → Hotspot endpoints: mounts routes (evidence: `backend/app/main.py`)
- API application → Weather and risk API: mounts routes (evidence: `backend/app/main.py`)
- API application → Routing endpoint: mounts routes (evidence: `backend/app/main.py`)
- API application → Dispatch approval API: mounts routes (evidence: `backend/app/main.py`)
- Report endpoints → Report orchestrator: invokes (evidence: `backend/app/api/reports.py`)
- Report orchestrator → Agent tools: uses tools (evidence: `backend/app/services/orchestrator.py`)
- Report workflow → Image verification: uses (evidence: `backend/app/services/workflow.py`)
- Report workflow → Vision analysis: uses (evidence: `backend/app/services/workflow.py`)
- Agent tools → Image verification: uses (evidence: `backend/app/services/agent_tools.py`)
- Agent tools → Vision analysis: uses (evidence: `backend/app/services/agent_tools.py`)
- Agent tools → Weather retrieval: uses (evidence: `backend/app/services/agent_tools.py`)
- Agent tools → Risk scoring: uses (evidence: `backend/app/services/agent_tools.py`)
- Agent tools → Route exposure scoring: uses (evidence: `backend/app/services/agent_tools.py`)
- Agent tools → Civic information retrieval: uses (evidence: `backend/app/services/agent_tools.py`)
- Vision analysis → Gemini: analyzes images
- Weather retrieval → Open-Meteo: fetches forecast (evidence: `backend/app/services/weather_service.py`)
- Weather and risk API → Weather retrieval: refreshes weather (evidence: `backend/app/api/weather.py`)
- Weather and risk API → Risk scoring: recalculates risk (evidence: `backend/app/api/weather.py`)
- Risk scoring → Persistence operations: reads reports (evidence: `backend/app/services/risk_service.py`)
- Routing endpoint → Route exposure scoring: requests candidates (evidence: `backend/app/api/routing.py`)
- Route exposure scoring → OSRM routing: fetches routes (evidence: `backend/app/services/route_service.py`)
- Route exposure scoring → Persistence operations: loads hotspots (evidence: `backend/app/services/route_service.py`)
- Report endpoints → Persistence operations: persists reports (evidence: `backend/app/api/reports.py`)
- Hotspot endpoints → Persistence operations: queries hotspots (evidence: `backend/app/api/hotspots.py`)
- Dispatch approval API → Persistence operations: updates plans (evidence: `backend/app/api/admin.py`)
- Persistence operations → SQLite database: reads and writes (evidence: `backend/app/db/crud.py`)
- Demo data initialization → SQLite database: seeds records (evidence: `backend/app/seed/seed_data.py`)
- Demo data initialization → Risk scoring: calculates initial risk (evidence: `backend/app/seed/seed_data.py`)
