# urveebettadapur/grievai architecture

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

- Interactive diagram: https://gitdiagram.com/urveebettadapur/grievai
- Repository: https://github.com/urveebettadapur/grievai

## Overview

GrievAI is a civic grievance intake and officer-review prototype. Citizens submit reports through the web portal; the API validates and stores them, produces an explainable rule-based analysis, and supports staff review, status history, and citizen feedback. Officers can inspect related-incident hypotheses, recurrence, and dashboard analytics. The README documents offline queuing and synchronization; sampled frontend code confirms the browser queue and API requests. The repository contains root-level and GrievAI_Thanmay copies of the backend and frontend; both are represented. Other feature links rely on README documentation because their source excerpts are incomplete.

Main entry points: [`backend/app.py`](https://github.com/urveebettadapur/grievai/blob/main/backend/app.py) (Grievance API), [`GrievAI_Thanmay/backend/app.py`](https://github.com/urveebettadapur/grievai/blob/main/GrievAI_Thanmay/backend/app.py) (API copy), [`frontend/app.js`](https://github.com/urveebettadapur/grievai/blob/main/frontend/app.js) (Citizen and staff portal), [`GrievAI_Thanmay/frontend/app.js`](https://github.com/urveebettadapur/grievai/blob/main/GrievAI_Thanmay/frontend/app.js) (Portal copy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_citizen["Citizen intake"]
  node_portal_root["Citizen and staff portal<br/>[app.js]"]
  node_portal_copy["Portal copy<br/>[app.js]"]
  node_offline_queue[("Offline queue<br/>[app.js]")]
end

subgraph group_casework["Grievance casework"]
  node_analysis["Explainable analysis<br/>[app.py]"]
  node_analysis_copy["Analysis copy<br/>[app.py]"]
  node_case_records[("Grievance records<br/>[app.py]")]
  node_status_feedback["Status and feedback<br/>[app.py]"]
  node_staff_auth["Staff authentication<br/>[app.py]"]
end

subgraph group_intelligence["Incident intelligence"]
  node_incident_groups["Incident grouping<br/>[app.py]"]
  node_recurrence["Recurrence view<br/>[app.py]"]
  node_analytics["Dashboard analytics<br/>[app.py]"]
end

subgraph group_platform["Application platform"]
  node_api_root["Grievance API<br/>[app.py]"]
  node_api_copy["API copy<br/>[app.py]"]
  node_service_worker["Offline app shell<br/>[sw.js]"]
end

node_citizen_actor(("Citizen"))
node_staff_actor(("Officer"))

node_citizen_actor -->|"submits report"| node_portal_root
node_citizen_actor -->|"submits report"| node_portal_copy
node_portal_root -->|"queues offline"| node_offline_queue
node_portal_copy -->|"queues offline"| node_offline_queue
node_offline_queue -->|"syncs reports"| node_api_root
node_offline_queue -->|"syncs reports"| node_api_copy
node_portal_root -->|"requests data"| node_api_root
node_portal_copy -->|"requests data"| node_api_copy
node_api_root -->|"analyzes reports"| node_analysis
node_api_copy -->|"analyzes reports"| node_analysis_copy
node_api_root -->|"persists reports"| node_case_records
node_api_copy -->|"persists reports"| node_case_records
node_staff_actor -->|"reviews cases"| node_portal_root
node_staff_actor -->|"reviews cases"| node_portal_copy
node_portal_root -->|"updates status"| node_api_root
node_portal_copy -->|"updates status"| node_api_copy
node_api_root -->|"records feedback"| node_status_feedback
node_api_copy -->|"records feedback"| node_status_feedback
node_portal_root -->|"authenticates staff"| node_api_root
node_portal_copy -->|"authenticates staff"| node_api_copy
node_api_root -->|"serves groupings"| node_incident_groups
node_api_copy -->|"serves groupings"| node_incident_groups
node_portal_root -->|"reviews incidents"| node_api_root
node_portal_copy -->|"reviews incidents"| node_api_copy
node_api_root -->|"aggregates recurrence"| node_recurrence
node_api_copy -->|"aggregates recurrence"| node_recurrence
node_api_root -->|"aggregates metrics"| node_analytics
node_api_copy -->|"aggregates metrics"| node_analytics
node_portal_root -->|"uses app shell"| node_service_worker
node_portal_copy -->|"uses app shell"| node_service_worker

click node_portal_root "https://github.com/urveebettadapur/grievai/blob/main/frontend/app.js"
click node_portal_copy "https://github.com/urveebettadapur/grievai/blob/main/GrievAI_Thanmay/frontend/app.js"
click node_offline_queue "https://github.com/urveebettadapur/grievai/blob/main/frontend/app.js"
click node_api_root "https://github.com/urveebettadapur/grievai/blob/main/backend/app.py"
click node_api_copy "https://github.com/urveebettadapur/grievai/blob/main/GrievAI_Thanmay/backend/app.py"
click node_analysis "https://github.com/urveebettadapur/grievai/blob/main/backend/app.py"
click node_analysis_copy "https://github.com/urveebettadapur/grievai/blob/main/GrievAI_Thanmay/backend/app.py"
click node_case_records "https://github.com/urveebettadapur/grievai/blob/main/backend/app.py"
click node_status_feedback "https://github.com/urveebettadapur/grievai/blob/main/backend/app.py"
click node_staff_auth "https://github.com/urveebettadapur/grievai/blob/main/backend/app.py"
click node_incident_groups "https://github.com/urveebettadapur/grievai/blob/main/backend/app.py"
click node_recurrence "https://github.com/urveebettadapur/grievai/blob/main/backend/app.py"
click node_analytics "https://github.com/urveebettadapur/grievai/blob/main/backend/app.py"
click node_service_worker "https://github.com/urveebettadapur/grievai/blob/main/frontend/sw.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_portal_root,node_portal_copy,node_offline_queue toneBlue
class node_analysis,node_analysis_copy,node_case_records,node_status_feedback,node_staff_auth toneAmber
class node_incident_groups,node_recurrence,node_analytics toneMint
class node_api_root,node_api_copy,node_service_worker toneRose
class node_citizen_actor,node_staff_actor toneIndigo
```

## Components

### Citizen intake

- [Citizen and staff portal](https://github.com/urveebettadapur/grievai/blob/main/frontend/app.js): `frontend/app.js`
- [Portal copy](https://github.com/urveebettadapur/grievai/blob/main/GrievAI_Thanmay/frontend/app.js): `GrievAI_Thanmay/frontend/app.js`
- [Offline queue](https://github.com/urveebettadapur/grievai/blob/main/frontend/app.js): `frontend/app.js`

### Grievance casework

- [Explainable analysis](https://github.com/urveebettadapur/grievai/blob/main/backend/app.py): `backend/app.py`
- [Analysis copy](https://github.com/urveebettadapur/grievai/blob/main/GrievAI_Thanmay/backend/app.py): `GrievAI_Thanmay/backend/app.py`
- [Grievance records](https://github.com/urveebettadapur/grievai/blob/main/backend/app.py): `backend/app.py`
- [Status and feedback](https://github.com/urveebettadapur/grievai/blob/main/backend/app.py): `backend/app.py`
- [Staff authentication](https://github.com/urveebettadapur/grievai/blob/main/backend/app.py): `backend/app.py`

### Incident intelligence

- [Incident grouping](https://github.com/urveebettadapur/grievai/blob/main/backend/app.py): `backend/app.py`
- [Recurrence view](https://github.com/urveebettadapur/grievai/blob/main/backend/app.py): `backend/app.py`
- [Dashboard analytics](https://github.com/urveebettadapur/grievai/blob/main/backend/app.py): `backend/app.py`

### Application platform

- [Grievance API](https://github.com/urveebettadapur/grievai/blob/main/backend/app.py): `backend/app.py`
- [API copy](https://github.com/urveebettadapur/grievai/blob/main/GrievAI_Thanmay/backend/app.py): `GrievAI_Thanmay/backend/app.py`
- [Offline app shell](https://github.com/urveebettadapur/grievai/blob/main/frontend/sw.js): `frontend/sw.js`

### Other components

- **Citizen**
- **Officer**

## Connections

- Citizen → Citizen and staff portal: submits report (evidence: `README.md`)
- Citizen → Portal copy: submits report (evidence: `README.md`)
- Citizen and staff portal → Offline queue: queues offline (evidence: `frontend/app.js`)
- Portal copy → Offline queue: queues offline (evidence: `GrievAI_Thanmay/frontend/app.js`)
- Offline queue → Grievance API: syncs reports (evidence: `README.md`)
- Offline queue → API copy: syncs reports (evidence: `README.md`)
- Citizen and staff portal → Grievance API: requests data (evidence: `frontend/app.js`)
- Portal copy → API copy: requests data (evidence: `GrievAI_Thanmay/frontend/app.js`)
- Grievance API → Explainable analysis: analyzes reports (evidence: `README.md`)
- API copy → Analysis copy: analyzes reports (evidence: `README.md`)
- Grievance API → Grievance records: persists reports (evidence: `README.md`)
- API copy → Grievance records: persists reports (evidence: `README.md`)
- Officer → Citizen and staff portal: reviews cases (evidence: `README.md`)
- Officer → Portal copy: reviews cases (evidence: `README.md`)
- Citizen and staff portal → Grievance API: updates status (evidence: `README.md`)
- Portal copy → API copy: updates status (evidence: `README.md`)
- Grievance API → Status and feedback: records feedback (evidence: `README.md`)
- API copy → Status and feedback: records feedback (evidence: `README.md`)
- Citizen and staff portal → Grievance API: authenticates staff (evidence: `README.md`)
- Portal copy → API copy: authenticates staff (evidence: `README.md`)
- Grievance API → Incident grouping: serves groupings (evidence: `README.md`)
- API copy → Incident grouping: serves groupings (evidence: `README.md`)
- Citizen and staff portal → Grievance API: reviews incidents (evidence: `frontend/app.js`)
- Portal copy → API copy: reviews incidents (evidence: `GrievAI_Thanmay/frontend/app.js`)
- Grievance API → Recurrence view: aggregates recurrence (evidence: `README.md`)
- API copy → Recurrence view: aggregates recurrence (evidence: `README.md`)
- Grievance API → Dashboard analytics: aggregates metrics (evidence: `README.md`)
- API copy → Dashboard analytics: aggregates metrics (evidence: `README.md`)
- Citizen and staff portal → Offline app shell: uses app shell (evidence: `README.md`)
- Portal copy → Offline app shell: uses app shell (evidence: `README.md`)
