# asjayswal01/safai_setu architecture

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

- Interactive diagram: https://gitdiagram.com/asjayswal01/safai_setu
- Repository: https://github.com/asjayswal01/safai_setu

## Overview

Safai Setu is a Flutter waste-management app for citizens, sanitation workers, and department heads. A citizen reports a geolocated, photo-backed complaint; department heads review complaints and assign work; workers complete tasks and submit proof; heads oversee progress and citizens track status. The README documents these capabilities and the service/backend stack. Dart implementation excerpts were not provided, so app-level links below reflect documented workflows rather than inspected calls; the notification function’s Supabase and FCM interactions are directly visible in its source.

Main entry points: [`lib/screens/head`](https://github.com/asjayswal01/safai_setu/tree/main/lib/screens/head) (Head console), [`lib/screens/auth/auth_gate.dart`](https://github.com/asjayswal01/safai_setu/blob/main/lib/screens/auth/auth_gate.dart) (Role login), [`lib/main.dart`](https://github.com/asjayswal01/safai_setu/blob/main/lib/main.dart) (App entry), [`lib/screens`](https://github.com/asjayswal01/safai_setu/tree/main/lib/screens) (Citizen screens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App shell"]
  node_entry["App entry<br/>[main.dart]"]
  node_auth["Role login<br/>[auth_gate.dart]"]
  node_windows_host["Windows Flutter host<br/>[flutter_window.cpp]"]
  node_windows_window["Windows window<br/>[win32_window.cpp]"]
end

subgraph group_citizen["Citizen services"]
  node_citizen_ui["Citizen screens"]
  node_complaints["Complaint workflow"]
  node_hotspots["Hotspot map"]
  node_profiles["Profiles<br/>[profile_page.dart]"]
end

subgraph group_operations["Department operations"]
  node_head_ui["Head console"]
  node_worker_ui["Worker tasks"]
  node_complaint_service["Complaint service"]
  node_task_service["Task service<br/>[task_service.dart]"]
  node_routing["Route optimizer"]
  node_location["Location service"]
end

subgraph group_platform["Backend and integrations"]
  node_supabase[("Supabase backend")]
  node_notifications["Notification service"]
  node_push_function["Push dispatch<br/>[index.ts]"]
  node_fcm["Firebase messaging"]
  node_maps["Google Maps"]
end

node_user(("App users"))

node_user -->|"opens app"| node_entry
node_entry -.->|"starts role flow"| node_auth
node_auth -->|"routes citizens"| node_citizen_ui
node_auth -->|"routes heads"| node_head_ui
node_auth -->|"routes workers"| node_worker_ui
node_citizen_ui -->|"reports issues"| node_complaints
node_complaints -.->|"submits complaint"| node_complaint_service
node_complaint_service -->|"stores reports"| node_supabase
node_citizen_ui -->|"views hotspots"| node_hotspots
node_hotspots -.->|"loads complaints"| node_supabase
node_head_ui -->|"manages reports"| node_complaint_service
node_head_ui -->|"assigns tasks"| node_task_service
node_worker_ui -->|"updates tasks"| node_task_service
node_task_service -->|"stores tasks"| node_supabase
node_head_ui -->|"optimizes routes"| node_routing
node_head_ui -->|"tracks workers"| node_location
node_location -->|"provides map location"| node_maps
node_head_ui -->|"shows live map"| node_maps
node_profiles -->|"manages profile"| node_supabase
node_notifications -->|"requests push"| node_push_function
node_push_function -->|"reads tokens and records history"| node_supabase
node_push_function -->|"sends push"| node_fcm
node_windows_host -->|"inherits window"| node_windows_window
node_entry -.->|"runs in host"| node_windows_host

click node_entry "https://github.com/asjayswal01/safai_setu/blob/main/lib/main.dart"
click node_auth "https://github.com/asjayswal01/safai_setu/blob/main/lib/screens/auth/auth_gate.dart"
click node_citizen_ui "https://github.com/asjayswal01/safai_setu/tree/main/lib/screens"
click node_complaints "https://github.com/asjayswal01/safai_setu/tree/main/lib/screens/complaints"
click node_hotspots "https://github.com/asjayswal01/safai_setu/blob/main/lib/screens/hotspots/waste_hotspot_page.dart"
click node_profiles "https://github.com/asjayswal01/safai_setu/blob/main/lib/screens/profile/profile_page.dart"
click node_head_ui "https://github.com/asjayswal01/safai_setu/tree/main/lib/screens/head"
click node_worker_ui "https://github.com/asjayswal01/safai_setu/tree/main/lib/screens/worker"
click node_complaint_service "https://github.com/asjayswal01/safai_setu/blob/main/lib/services/complaint_service.dart"
click node_task_service "https://github.com/asjayswal01/safai_setu/blob/main/lib/services/task_service.dart"
click node_routing "https://github.com/asjayswal01/safai_setu/blob/main/lib/services/route_optimization_service.dart"
click node_location "https://github.com/asjayswal01/safai_setu/blob/main/lib/services/location_service.dart"
click node_notifications "https://github.com/asjayswal01/safai_setu/blob/main/lib/services/notification_service.dart"
click node_push_function "https://github.com/asjayswal01/safai_setu/blob/main/supabase/functions/send-notification/index.ts"
click node_windows_host "https://github.com/asjayswal01/safai_setu/blob/main/windows/runner/flutter_window.cpp"
click node_windows_window "https://github.com/asjayswal01/safai_setu/blob/main/windows/runner/win32_window.cpp"

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_entry,node_auth,node_windows_host,node_windows_window,node_user toneBlue
class node_citizen_ui,node_complaints,node_hotspots,node_profiles toneAmber
class node_head_ui,node_worker_ui,node_complaint_service,node_task_service,node_routing,node_location toneMint
class node_supabase,node_notifications,node_push_function,node_fcm,node_maps toneRose
```

## Components

### App shell

- [App entry](https://github.com/asjayswal01/safai_setu/blob/main/lib/main.dart): `lib/main.dart`
- [Role login](https://github.com/asjayswal01/safai_setu/blob/main/lib/screens/auth/auth_gate.dart): `lib/screens/auth/auth_gate.dart`
- [Windows Flutter host](https://github.com/asjayswal01/safai_setu/blob/main/windows/runner/flutter_window.cpp): `windows/runner/flutter_window.cpp`
- [Windows window](https://github.com/asjayswal01/safai_setu/blob/main/windows/runner/win32_window.cpp): `windows/runner/win32_window.cpp`

### Citizen services

- [Citizen screens](https://github.com/asjayswal01/safai_setu/tree/main/lib/screens): `lib/screens`
- [Complaint workflow](https://github.com/asjayswal01/safai_setu/tree/main/lib/screens/complaints): `lib/screens/complaints`
- [Hotspot map](https://github.com/asjayswal01/safai_setu/blob/main/lib/screens/hotspots/waste_hotspot_page.dart): `lib/screens/hotspots/waste_hotspot_page.dart`
- [Profiles](https://github.com/asjayswal01/safai_setu/blob/main/lib/screens/profile/profile_page.dart): `lib/screens/profile/profile_page.dart`

### Department operations

- [Head console](https://github.com/asjayswal01/safai_setu/tree/main/lib/screens/head): `lib/screens/head`
- [Worker tasks](https://github.com/asjayswal01/safai_setu/tree/main/lib/screens/worker): `lib/screens/worker`
- [Complaint service](https://github.com/asjayswal01/safai_setu/blob/main/lib/services/complaint_service.dart): `lib/services/complaint_service.dart`
- [Task service](https://github.com/asjayswal01/safai_setu/blob/main/lib/services/task_service.dart): `lib/services/task_service.dart`
- [Route optimizer](https://github.com/asjayswal01/safai_setu/blob/main/lib/services/route_optimization_service.dart): `lib/services/route_optimization_service.dart`
- [Location service](https://github.com/asjayswal01/safai_setu/blob/main/lib/services/location_service.dart): `lib/services/location_service.dart`

### Backend and integrations

- **Supabase backend**
- [Notification service](https://github.com/asjayswal01/safai_setu/blob/main/lib/services/notification_service.dart): `lib/services/notification_service.dart`
- [Push dispatch](https://github.com/asjayswal01/safai_setu/blob/main/supabase/functions/send-notification/index.ts): `supabase/functions/send-notification/index.ts`
- **Firebase messaging**
- **Google Maps**

### Other components

- **App users**

## Connections

- App users → App entry: opens app (evidence: `README.md`)
- App entry → Role login: starts role flow
- Role login → Citizen screens: routes citizens (evidence: `README.md`)
- Role login → Head console: routes heads (evidence: `README.md`)
- Role login → Worker tasks: routes workers (evidence: `README.md`)
- Citizen screens → Complaint workflow: reports issues (evidence: `README.md`)
- Complaint workflow → Complaint service: submits complaint
- Complaint service → Supabase backend: stores reports (evidence: `README.md`)
- Citizen screens → Hotspot map: views hotspots (evidence: `README.md`)
- Hotspot map → Supabase backend: loads complaints
- Head console → Complaint service: manages reports (evidence: `README.md`)
- Head console → Task service: assigns tasks (evidence: `README.md`)
- Worker tasks → Task service: updates tasks (evidence: `README.md`)
- Task service → Supabase backend: stores tasks (evidence: `README.md`)
- Head console → Route optimizer: optimizes routes (evidence: `README.md`)
- Head console → Location service: tracks workers (evidence: `README.md`)
- Location service → Google Maps: provides map location (evidence: `README.md`)
- Head console → Google Maps: shows live map (evidence: `README.md`)
- Profiles → Supabase backend: manages profile (evidence: `README.md`)
- Notification service → Push dispatch: requests push (evidence: `supabase/functions/send-notification/index.ts`)
- Push dispatch → Supabase backend: reads tokens and records history (evidence: `supabase/functions/send-notification/index.ts`)
- Push dispatch → Firebase messaging: sends push (evidence: `supabase/functions/send-notification/index.ts`)
- Windows Flutter host → Windows window: inherits window (evidence: `windows/runner/flutter_window.cpp`)
- App entry → Windows Flutter host: runs in host
