# nvaltryek-001/citypulse-ai architecture

> Architecture diagram of the GitHub repository nvaltryek-001/citypulse-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nvaltryek-001/citypulse-ai
- Repository: https://github.com/nvaltryek-001/citypulse-ai

## Overview

CityPulse AI lets citizens create evidence-backed civic reports, then supports geographic discovery, status tracking, historical context, analytics, sharing, and offline submission. The graph follows the documented reporting path through the frontend and backend, and preserves the product’s main exploration branches. The excerpts show some routing and report-service calls; several feature implementations were not sampled, so those connections are omitted rather than inferred.

Main entry points: [`frontend/src/components/ReportFlow.jsx`](https://github.com/nvaltryek-001/citypulse-ai/blob/main/frontend/src/components/ReportFlow.jsx) (Report flow), [`frontend/src/App.jsx`](https://github.com/nvaltryek-001/citypulse-ai/blob/main/frontend/src/App.jsx) (CityPulse app), [`backend/src/controllers/reportController.js`](https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/controllers/reportController.js) (Report controller), [`backend/server.js`](https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/server.js) (API server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_citizen["Citizen reporting"]
  node_app["CityPulse app<br/>[App.jsx]"]
  node_report_flow["Report flow<br/>[ReportFlow.jsx]"]
  node_report_pipeline["Report pipeline"]
  node_location["GPS capture<br/>[locationService.js]"]
end

subgraph group_backend["Civic API"]
  node_ai_analysis["Image analysis<br/>[aiRoutes.js]"]
  node_api["API server<br/>[server.js]"]
  node_report_routes["Report routes<br/>[reportRoutes.js]"]
  node_report_controller["Report controller"]
  node_report_service["Report service<br/>[reportService.js]"]
  node_geo_sync["Geo sync service"]
  node_report_store[("Report records<br/>[Report.js]")]
end

subgraph group_insights["Discovery and insights"]
  node_nearby_controller["Nearby issues"]
  node_nearby_service["Nearby search"]
  node_explore["Live Explore"]
  node_analytics["Civic analytics"]
  node_civic_data[("BBMP history")]
  node_maps["Leaflet maps<br/>[mapService.js]"]
end

subgraph group_support["Resilience and sharing"]
  node_offline[("Offline queue<br/>[offlineDb.js]")]
  node_offline_sync["Offline sync"]
  node_sharing["Report sharing<br/>[shareService.js]"]
end

node_citizen(("Citizen"))
node_gemini["Gemini AI"]

node_citizen -->|"uses"| node_app
node_app -->|"opens"| node_report_flow
node_report_flow -.->|"saves stages"| node_report_pipeline
node_report_flow -.->|"captures GPS"| node_location
node_report_flow -.->|"submits evidence"| node_ai_analysis
node_ai_analysis -->|"analyzes image"| node_gemini
node_report_flow -.->|"submits report"| node_api
node_api -->|"routes requests"| node_report_routes
node_report_routes -->|"dispatches"| node_report_controller
node_report_controller -->|"creates report"| node_report_service
node_report_controller -->|"syncs location"| node_geo_sync
node_report_controller -.->|"persists report"| node_report_store
node_api -->|"routes nearby"| node_nearby_controller
node_nearby_controller -->|"searches issues"| node_nearby_service
node_app -.->|"loads exploration"| node_explore
node_app -.->|"loads analytics"| node_analytics
node_app -.->|"loads history"| node_civic_data
node_nearby_service -.->|"queries nearby"| node_report_store
node_app -.->|"shows issues"| node_maps
node_report_flow -.->|"queues offline"| node_offline
node_offline_sync -->|"reads queue"| node_offline
node_offline_sync -.->|"submits queued"| node_api
node_report_flow -.->|"shares report"| node_sharing

click node_app "https://github.com/nvaltryek-001/citypulse-ai/blob/main/frontend/src/App.jsx"
click node_report_flow "https://github.com/nvaltryek-001/citypulse-ai/blob/main/frontend/src/components/ReportFlow.jsx"
click node_report_pipeline "https://github.com/nvaltryek-001/citypulse-ai/blob/main/frontend/src/services/reportPipelineService.js"
click node_location "https://github.com/nvaltryek-001/citypulse-ai/blob/main/frontend/src/services/locationService.js"
click node_ai_analysis "https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/routes/aiRoutes.js"
click node_api "https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/server.js"
click node_report_routes "https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/routes/reportRoutes.js"
click node_report_controller "https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/controllers/reportController.js"
click node_report_service "https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/services/reportService.js"
click node_geo_sync "https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/services/gpsReportService.js"
click node_report_store "https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/models/Report.js"
click node_nearby_controller "https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/controllers/nearbyIssueController.js"
click node_nearby_service "https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/services/nearbyIssueService.js"
click node_explore "https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/services/exploreDataService.js"
click node_analytics "https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/services/analyticsService.js"
click node_civic_data "https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/services/civicDatasetService.js"
click node_offline "https://github.com/nvaltryek-001/citypulse-ai/blob/main/frontend/src/services/offlineDb.js"
click node_offline_sync "https://github.com/nvaltryek-001/citypulse-ai/blob/main/frontend/src/services/offlineSyncService.js"
click node_sharing "https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/services/shareService.js"
click node_maps "https://github.com/nvaltryek-001/citypulse-ai/blob/main/frontend/src/services/mapService.js"

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_app,node_report_flow,node_report_pipeline,node_location toneBlue
class node_ai_analysis,node_api,node_report_routes,node_report_controller,node_report_service,node_geo_sync,node_report_store toneAmber
class node_nearby_controller,node_nearby_service,node_explore,node_analytics,node_civic_data,node_maps toneMint
class node_offline,node_offline_sync,node_sharing toneRose
class node_citizen,node_gemini toneIndigo
```

## Components

### Citizen reporting

- [CityPulse app](https://github.com/nvaltryek-001/citypulse-ai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Report flow](https://github.com/nvaltryek-001/citypulse-ai/blob/main/frontend/src/components/ReportFlow.jsx): `frontend/src/components/ReportFlow.jsx`
- [Report pipeline](https://github.com/nvaltryek-001/citypulse-ai/blob/main/frontend/src/services/reportPipelineService.js): `frontend/src/services/reportPipelineService.js`
- [GPS capture](https://github.com/nvaltryek-001/citypulse-ai/blob/main/frontend/src/services/locationService.js): `frontend/src/services/locationService.js`

### Civic API

- [Image analysis](https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/routes/aiRoutes.js): `backend/routes/aiRoutes.js`
- [API server](https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/server.js): `backend/server.js`
- [Report routes](https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/routes/reportRoutes.js): `backend/src/routes/reportRoutes.js`
- [Report controller](https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/controllers/reportController.js): `backend/src/controllers/reportController.js`
- [Report service](https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/services/reportService.js): `backend/src/services/reportService.js`
- [Geo sync service](https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/services/gpsReportService.js): `backend/src/services/gpsReportService.js`
- [Report records](https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/models/Report.js): `backend/src/models/Report.js`

### Discovery and insights

- [Nearby issues](https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/controllers/nearbyIssueController.js): `backend/src/controllers/nearbyIssueController.js`
- [Nearby search](https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/services/nearbyIssueService.js): `backend/src/services/nearbyIssueService.js`
- [Live Explore](https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/services/exploreDataService.js): `backend/src/services/exploreDataService.js`
- [Civic analytics](https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/services/analyticsService.js): `backend/src/services/analyticsService.js`
- [BBMP history](https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/services/civicDatasetService.js): `backend/src/services/civicDatasetService.js`
- [Leaflet maps](https://github.com/nvaltryek-001/citypulse-ai/blob/main/frontend/src/services/mapService.js): `frontend/src/services/mapService.js`

### Resilience and sharing

- [Offline queue](https://github.com/nvaltryek-001/citypulse-ai/blob/main/frontend/src/services/offlineDb.js): `frontend/src/services/offlineDb.js`
- [Offline sync](https://github.com/nvaltryek-001/citypulse-ai/blob/main/frontend/src/services/offlineSyncService.js): `frontend/src/services/offlineSyncService.js`
- [Report sharing](https://github.com/nvaltryek-001/citypulse-ai/blob/main/backend/src/services/shareService.js): `backend/src/services/shareService.js`

### Other components

- **Citizen**
- **Gemini AI**

## Connections

- Citizen → CityPulse app: uses (evidence: `README.md`)
- CityPulse app → Report flow: opens (evidence: `frontend/src/App.jsx`)
- Report flow → Report pipeline: saves stages
- Report flow → GPS capture: captures GPS
- Report flow → Image analysis: submits evidence (evidence: `README.md`)
- Image analysis → Gemini AI: analyzes image (evidence: `backend/routes/aiRoutes.js`)
- Report flow → API server: submits report (evidence: `README.md`)
- API server → Report routes: routes requests (evidence: `backend/server.js`)
- Report routes → Report controller: dispatches (evidence: `backend/src/routes/reportRoutes.js`)
- Report controller → Report service: creates report (evidence: `backend/src/controllers/reportController.js`)
- Report controller → Geo sync service: syncs location (evidence: `backend/src/controllers/reportController.js`)
- Report controller → Report records: persists report
- API server → Nearby issues: routes nearby (evidence: `backend/server.js`)
- Nearby issues → Nearby search: searches issues (evidence: `backend/src/controllers/nearbyIssueController.js`)
- CityPulse app → Live Explore: loads exploration
- CityPulse app → Civic analytics: loads analytics
- CityPulse app → BBMP history: loads history
- Nearby search → Report records: queries nearby
- CityPulse app → Leaflet maps: shows issues (evidence: `README.md`)
- Report flow → Offline queue: queues offline (evidence: `README.md`)
- Offline sync → Offline queue: reads queue (evidence: `frontend/src/hooks/useOfflineStatus.js`)
- Offline sync → API server: submits queued (evidence: `README.md`)
- Report flow → Report sharing: shares report (evidence: `README.md`)
