# sanketsawant72/civic-sense architecture

> Architecture diagram of the GitHub repository sanketsawant72/civic-sense, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sanketsawant72/civic-sense
- Repository: https://github.com/sanketsawant72/civic-sense

## Overview

CivicSense lets residents report and track civic issues while department staff and administrators manage them. The main workflow is photo/location-assisted reporting, duplicate-warning checks, optional AI photo verification, API persistence, and staff resolution. The graph uses the `src/` frontend tree and Express/MongoDB services; the duplicate `frontend/` tree is omitted. Some page and route internals were not sampled, so documented links are shown from the README and uncertain implementation details are left out.

Main entry points: [`src/App.jsx`](https://github.com/sanketsawant72/civic-sense/blob/main/src/App.jsx) (React application), [`server/routes/complaints.js`](https://github.com/sanketsawant72/civic-sense/blob/main/server/routes/complaints.js) (Complaint routes), [`server/index.js`](https://github.com/sanketsawant72/civic-sense/blob/main/server/index.js) (Express API), [`ai-service/main.py`](https://github.com/sanketsawant72/civic-sense/blob/main/ai-service/main.py) (AI verification API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Citizen and staff app"]
  node_app["React application<br/>[App.jsx]"]
  node_report["Issue reporting<br/>[ReportIssue.jsx]"]
  node_complaint_views["Complaint views"]
  node_staff_tools["Staff management"]
  node_department_tools["Department workspace"]
  node_auth_state["Auth state<br/>[useAuthStore.js]"]
  node_complaint_state["Complaint state<br/>[useStore.js]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_operations["Complaint operations"]
  node_express_api["Express API<br/>[index.js]"]
  node_complaint_routes["Complaint routes<br/>[complaints.js]"]
  node_similarity["Duplicate matching"]
  node_departments["Department routes<br/>[departments.js]"]
  node_complaint_model["Complaint model<br/>[Complaint.js]"]
  node_notification_model["Notification model<br/>[Notification.js]"]
  node_mongo[("MongoDB")]
end

subgraph group_identity["Identity and access"]
  node_auth_routes["Auth routes<br/>[auth.js]"]
  node_auth_middleware["JWT middleware<br/>[auth.js]"]
  node_user_model["User model<br/>[User.js]"]
end

subgraph group_verification["Photo verification"]
  node_python_ai["AI verification API<br/>[main.py]"]
  node_ai_model["Civic image model<br/>[civic_ml.py]"]
end

node_resident(("Resident or staff"))
node_gemini["Gemini service"]

node_resident -->|"uses"| node_app
node_app -->|"offers reporting"| node_report
node_app -->|"offers tracking"| node_complaint_views
node_app -->|"offers admin tools"| node_staff_tools
node_app -->|"offers department tools"| node_department_tools
node_complaint_state -->|"calls"| node_api_client
node_api_client -->|"sends requests"| node_express_api
node_express_api -.->|"routes requests"| node_complaint_routes
node_complaint_routes -->|"checks matches"| node_similarity
node_complaint_routes -->|"persists complaints"| node_complaint_model
node_complaint_model -->|"reads and writes"| node_mongo
node_departments -.->|"reads and writes"| node_mongo
node_auth_routes -->|"queries users"| node_user_model
node_auth_routes -->|"uses protection"| node_auth_middleware
node_auth_middleware -->|"loads user"| node_user_model
node_user_model -->|"stores accounts"| node_mongo
node_express_api -.->|"calls optional verifier"| node_python_ai
node_python_ai -.->|"may load model"| node_ai_model
node_python_ai -.->|"classifies images"| node_gemini
node_complaint_routes -.->|"may create notifications"| node_notification_model

click node_app "https://github.com/sanketsawant72/civic-sense/blob/main/src/App.jsx"
click node_report "https://github.com/sanketsawant72/civic-sense/blob/main/src/pages/ReportIssue.jsx"
click node_complaint_views "https://github.com/sanketsawant72/civic-sense/tree/main/src/pages"
click node_staff_tools "https://github.com/sanketsawant72/civic-sense/tree/main/src/pages/admin"
click node_department_tools "https://github.com/sanketsawant72/civic-sense/tree/main/src/pages/department"
click node_auth_state "https://github.com/sanketsawant72/civic-sense/blob/main/src/store/useAuthStore.js"
click node_complaint_state "https://github.com/sanketsawant72/civic-sense/blob/main/src/store/useStore.js"
click node_api_client "https://github.com/sanketsawant72/civic-sense/blob/main/src/utils/api.js"
click node_express_api "https://github.com/sanketsawant72/civic-sense/blob/main/server/index.js"
click node_complaint_routes "https://github.com/sanketsawant72/civic-sense/blob/main/server/routes/complaints.js"
click node_similarity "https://github.com/sanketsawant72/civic-sense/blob/main/server/utils/complaintSimilarity.js"
click node_departments "https://github.com/sanketsawant72/civic-sense/blob/main/server/routes/departments.js"
click node_complaint_model "https://github.com/sanketsawant72/civic-sense/blob/main/server/models/Complaint.js"
click node_notification_model "https://github.com/sanketsawant72/civic-sense/blob/main/server/models/Notification.js"
click node_auth_routes "https://github.com/sanketsawant72/civic-sense/blob/main/server/routes/auth.js"
click node_auth_middleware "https://github.com/sanketsawant72/civic-sense/blob/main/server/middleware/auth.js"
click node_user_model "https://github.com/sanketsawant72/civic-sense/blob/main/server/models/User.js"
click node_python_ai "https://github.com/sanketsawant72/civic-sense/blob/main/ai-service/main.py"
click node_ai_model "https://github.com/sanketsawant72/civic-sense/blob/main/ai-service/civic_ml.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_app,node_report,node_complaint_views,node_staff_tools,node_department_tools,node_auth_state,node_complaint_state,node_api_client toneBlue
class node_express_api,node_complaint_routes,node_similarity,node_departments,node_complaint_model,node_notification_model,node_mongo toneAmber
class node_auth_routes,node_auth_middleware,node_user_model toneMint
class node_python_ai,node_ai_model toneRose
class node_resident,node_gemini toneIndigo
```

## Components

### Citizen and staff app

- [React application](https://github.com/sanketsawant72/civic-sense/blob/main/src/App.jsx): `src/App.jsx`
- [Issue reporting](https://github.com/sanketsawant72/civic-sense/blob/main/src/pages/ReportIssue.jsx): `src/pages/ReportIssue.jsx`
- [Complaint views](https://github.com/sanketsawant72/civic-sense/tree/main/src/pages): `src/pages`
- [Staff management](https://github.com/sanketsawant72/civic-sense/tree/main/src/pages/admin): `src/pages/admin`
- [Department workspace](https://github.com/sanketsawant72/civic-sense/tree/main/src/pages/department): `src/pages/department`
- [Auth state](https://github.com/sanketsawant72/civic-sense/blob/main/src/store/useAuthStore.js): `src/store/useAuthStore.js`
- [Complaint state](https://github.com/sanketsawant72/civic-sense/blob/main/src/store/useStore.js): `src/store/useStore.js`
- [API client](https://github.com/sanketsawant72/civic-sense/blob/main/src/utils/api.js): `src/utils/api.js`

### Complaint operations

- [Express API](https://github.com/sanketsawant72/civic-sense/blob/main/server/index.js): `server/index.js`
- [Complaint routes](https://github.com/sanketsawant72/civic-sense/blob/main/server/routes/complaints.js): `server/routes/complaints.js`
- [Duplicate matching](https://github.com/sanketsawant72/civic-sense/blob/main/server/utils/complaintSimilarity.js): `server/utils/complaintSimilarity.js`
- [Department routes](https://github.com/sanketsawant72/civic-sense/blob/main/server/routes/departments.js): `server/routes/departments.js`
- [Complaint model](https://github.com/sanketsawant72/civic-sense/blob/main/server/models/Complaint.js): `server/models/Complaint.js`
- [Notification model](https://github.com/sanketsawant72/civic-sense/blob/main/server/models/Notification.js): `server/models/Notification.js`
- **MongoDB**

### Identity and access

- [Auth routes](https://github.com/sanketsawant72/civic-sense/blob/main/server/routes/auth.js): `server/routes/auth.js`
- [JWT middleware](https://github.com/sanketsawant72/civic-sense/blob/main/server/middleware/auth.js): `server/middleware/auth.js`
- [User model](https://github.com/sanketsawant72/civic-sense/blob/main/server/models/User.js): `server/models/User.js`

### Photo verification

- [AI verification API](https://github.com/sanketsawant72/civic-sense/blob/main/ai-service/main.py): `ai-service/main.py`
- [Civic image model](https://github.com/sanketsawant72/civic-sense/blob/main/ai-service/civic_ml.py): `ai-service/civic_ml.py`

### Other components

- **Resident or staff**
- **Gemini service**

## Connections

- Resident or staff → React application: uses (evidence: `README.md`)
- React application → Issue reporting: offers reporting (evidence: `README.md`)
- React application → Complaint views: offers tracking (evidence: `README.md`)
- React application → Staff management: offers admin tools (evidence: `README.md`)
- React application → Department workspace: offers department tools (evidence: `README.md`)
- Complaint state → API client: calls (evidence: `src/store/useStore.js`)
- API client → Express API: sends requests (evidence: `README.md`)
- Express API → Complaint routes: routes requests
- Complaint routes → Duplicate matching: checks matches (evidence: `README.md`)
- Complaint routes → Complaint model: persists complaints (evidence: `README.md`)
- Complaint model → MongoDB: reads and writes (evidence: `README.md`)
- Department routes → MongoDB: reads and writes
- Auth routes → User model: queries users (evidence: `server/routes/auth.js`)
- Auth routes → JWT middleware: uses protection (evidence: `server/routes/auth.js`)
- JWT middleware → User model: loads user (evidence: `server/middleware/auth.js`)
- User model → MongoDB: stores accounts (evidence: `README.md`)
- Express API → AI verification API: calls optional verifier (evidence: `README.md`)
- AI verification API → Civic image model: may load model (evidence: `README.md`)
- AI verification API → Gemini service: classifies images (evidence: `README.md`)
- Complaint routes → Notification model: may create notifications
