# bobords12/smart-complaint01 architecture

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

- Interactive diagram: https://gitdiagram.com/bobords12/smart-complaint01
- Repository: https://github.com/bobords12/smart-complaint01

## Overview

This is a Next.js/Supabase barangay complaint and blotter system with resident, public-kiosk, and staff workflows, plus complaint classification and document generation. The graph emphasizes kiosk filing and its server path, while preserving the major complaint-management, hearing, PNP referral, and reporting capabilities visible in the app tree and README. Edges are limited to relationships shown in excerpts, SOURCE INDEX references, or README statements; many page-to-data connections are not shown in the supplied evidence.

Main entry points: [`lib/supabase/admin.ts`](https://github.com/bobords12/smart-complaint01/blob/main/lib/supabase/admin.ts) (Supabase), [`app/kiosk/KioskClient.jsx`](https://github.com/bobords12/smart-complaint01/blob/main/app/kiosk/KioskClient.jsx) (Kiosk Wizard), [`lib/kiosk/serverApi.js`](https://github.com/bobords12/smart-complaint01/blob/main/lib/kiosk/serverApi.js) (Kiosk Server), [`app/api/kiosk/submit/route.js`](https://github.com/bobords12/smart-complaint01/blob/main/app/api/kiosk/submit/route.js) (Kiosk Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_filing["Public Filing"]
  node_kiosk["Kiosk Wizard<br/>[KioskClient.jsx]"]
  node_kiosk_steps["Kiosk Steps<br/>[KioskWelcome.jsx]"]
  node_kiosk_api["Kiosk API<br/>[api.js]"]
  node_offline[("Offline Sync<br/>[offlineStore.js]")]
  node_kiosk_routes["Kiosk Routes<br/>[route.js]"]
  node_kiosk_server["Kiosk Server<br/>[serverApi.js]"]
  node_reklamo["Reklamo Documents<br/>[route.js]"]
end

subgraph group_casework["Case Management"]
  node_resident["Resident Portal"]
  node_staff["Captain Casework<br/>[RoutingTab.jsx]"]
  node_routing["Routing Rules"]
  node_lupon["Lupon Hearings<br/>[LuponSchedule.jsx]"]
  node_pnp["PNP Referrals"]
  node_reports["Staff Reporting"]
end

subgraph group_services["Shared Services"]
  node_auth["Authentication<br/>[authService.ts]"]
  node_supabase[("Supabase<br/>[admin.ts]")]
  node_sms["Kiosk SMS<br/>[kioskSms.js]"]
end

subgraph group_classification["Classification"]
  node_classify_api["Classification API<br/>[route.js]"]
  node_ml_prediction["Prediction Adapter<br/>[mlPrediction.js]"]
  node_classifier["JS Classifier<br/>[index.js]"]
  node_ml_service["Python Classifier<br/>[main.py]"]
end

node_citizen(("Citizen"))

node_citizen -.->|"files through"| node_kiosk
node_kiosk -->|"renders"| node_kiosk_steps
node_kiosk -->|"submits via"| node_kiosk_api
node_kiosk -->|"queues offline"| node_offline
node_kiosk -->|"requests sync"| node_offline
node_kiosk_routes -->|"dispatches to"| node_kiosk_server
node_kiosk_routes -->|"uses"| node_sms
node_kiosk_routes -.->|"accesses through"| node_supabase
node_kiosk_server -->|"uses admin client"| node_supabase
node_kiosk_server -->|"requests prediction"| node_ml_prediction
node_kiosk_server -->|"imports"| node_classifier
node_classify_api -->|"predicts with"| node_ml_prediction
node_classify_api -->|"authenticates with"| node_supabase
node_ml_prediction -->|"uses admin client"| node_supabase
node_classifier -.->|"also available as"| node_ml_service
node_auth -->|"uses client"| node_supabase
node_staff -->|"evaluates routing"| node_routing
node_reklamo -->|"verifies ownership"| node_supabase
node_reklamo -->|"uses request helpers"| node_kiosk_server

click node_kiosk "https://github.com/bobords12/smart-complaint01/blob/main/app/kiosk/KioskClient.jsx"
click node_kiosk_steps "https://github.com/bobords12/smart-complaint01/blob/main/components/kiosk/KioskWelcome.jsx"
click node_kiosk_api "https://github.com/bobords12/smart-complaint01/blob/main/lib/kiosk/api.js"
click node_offline "https://github.com/bobords12/smart-complaint01/blob/main/lib/kiosk/offlineStore.js"
click node_kiosk_routes "https://github.com/bobords12/smart-complaint01/blob/main/app/api/kiosk/submit/route.js"
click node_kiosk_server "https://github.com/bobords12/smart-complaint01/blob/main/lib/kiosk/serverApi.js"
click node_reklamo "https://github.com/bobords12/smart-complaint01/blob/main/app/api/reklamo/generate/route.js"
click node_resident "https://github.com/bobords12/smart-complaint01/blob/main/components/resident/NewComplaintForm.jsx"
click node_staff "https://github.com/bobords12/smart-complaint01/blob/main/components/captain/complaints/RoutingTab.jsx"
click node_routing "https://github.com/bobords12/smart-complaint01/blob/main/lib/captainComplaintRouting.js"
click node_lupon "https://github.com/bobords12/smart-complaint01/blob/main/components/lupon/LuponSchedule.jsx"
click node_pnp "https://github.com/bobords12/smart-complaint01/blob/main/repositories/pnpReferralRepository.ts"
click node_reports "https://github.com/bobords12/smart-complaint01/blob/main/components/official/OfficialReports.jsx"
click node_auth "https://github.com/bobords12/smart-complaint01/blob/main/services/authService.ts"
click node_supabase "https://github.com/bobords12/smart-complaint01/blob/main/lib/supabase/admin.ts"
click node_classify_api "https://github.com/bobords12/smart-complaint01/blob/main/app/api/classify/route.js"
click node_ml_prediction "https://github.com/bobords12/smart-complaint01/blob/main/lib/mlPrediction.js"
click node_classifier "https://github.com/bobords12/smart-complaint01/blob/main/lib/classifier/index.js"
click node_ml_service "https://github.com/bobords12/smart-complaint01/blob/main/ml-backend/app/main.py"
click node_sms "https://github.com/bobords12/smart-complaint01/blob/main/lib/sms/kioskSms.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_kiosk,node_kiosk_steps,node_kiosk_api,node_offline,node_kiosk_routes,node_kiosk_server,node_reklamo toneBlue
class node_resident,node_staff,node_routing,node_lupon,node_pnp,node_reports toneAmber
class node_auth,node_supabase,node_sms toneMint
class node_classify_api,node_ml_prediction,node_classifier,node_ml_service toneRose
class node_citizen toneIndigo
```

## Components

### Public Filing

- [Kiosk Wizard](https://github.com/bobords12/smart-complaint01/blob/main/app/kiosk/KioskClient.jsx): `app/kiosk/KioskClient.jsx`
- [Kiosk Steps](https://github.com/bobords12/smart-complaint01/blob/main/components/kiosk/KioskWelcome.jsx): `components/kiosk/KioskWelcome.jsx`
- [Kiosk API](https://github.com/bobords12/smart-complaint01/blob/main/lib/kiosk/api.js): `lib/kiosk/api.js`
- [Offline Sync](https://github.com/bobords12/smart-complaint01/blob/main/lib/kiosk/offlineStore.js): `lib/kiosk/offlineStore.js`
- [Kiosk Routes](https://github.com/bobords12/smart-complaint01/blob/main/app/api/kiosk/submit/route.js): `app/api/kiosk/submit/route.js`
- [Kiosk Server](https://github.com/bobords12/smart-complaint01/blob/main/lib/kiosk/serverApi.js): `lib/kiosk/serverApi.js`
- [Reklamo Documents](https://github.com/bobords12/smart-complaint01/blob/main/app/api/reklamo/generate/route.js): `app/api/reklamo/generate/route.js`

### Case Management

- [Resident Portal](https://github.com/bobords12/smart-complaint01/blob/main/components/resident/NewComplaintForm.jsx): `components/resident/NewComplaintForm.jsx`
- [Captain Casework](https://github.com/bobords12/smart-complaint01/blob/main/components/captain/complaints/RoutingTab.jsx): `components/captain/complaints/RoutingTab.jsx`
- [Routing Rules](https://github.com/bobords12/smart-complaint01/blob/main/lib/captainComplaintRouting.js): `lib/captainComplaintRouting.js`
- [Lupon Hearings](https://github.com/bobords12/smart-complaint01/blob/main/components/lupon/LuponSchedule.jsx): `components/lupon/LuponSchedule.jsx`
- [PNP Referrals](https://github.com/bobords12/smart-complaint01/blob/main/repositories/pnpReferralRepository.ts): `repositories/pnpReferralRepository.ts`
- [Staff Reporting](https://github.com/bobords12/smart-complaint01/blob/main/components/official/OfficialReports.jsx): `components/official/OfficialReports.jsx`

### Shared Services

- [Authentication](https://github.com/bobords12/smart-complaint01/blob/main/services/authService.ts): `services/authService.ts`
- [Supabase](https://github.com/bobords12/smart-complaint01/blob/main/lib/supabase/admin.ts): `lib/supabase/admin.ts`
- [Kiosk SMS](https://github.com/bobords12/smart-complaint01/blob/main/lib/sms/kioskSms.js): `lib/sms/kioskSms.js`

### Classification

- [Classification API](https://github.com/bobords12/smart-complaint01/blob/main/app/api/classify/route.js): `app/api/classify/route.js`
- [Prediction Adapter](https://github.com/bobords12/smart-complaint01/blob/main/lib/mlPrediction.js): `lib/mlPrediction.js`
- [JS Classifier](https://github.com/bobords12/smart-complaint01/blob/main/lib/classifier/index.js): `lib/classifier/index.js`
- [Python Classifier](https://github.com/bobords12/smart-complaint01/blob/main/ml-backend/app/main.py): `ml-backend/app/main.py`

### Other components

- **Citizen**

## Connections

- Citizen → Kiosk Wizard: files through
- Kiosk Wizard → Kiosk Steps: renders (evidence: `app/kiosk/KioskClient.jsx`)
- Kiosk Wizard → Kiosk API: submits via (evidence: `app/kiosk/KioskClient.jsx`)
- Kiosk Wizard → Offline Sync: queues offline (evidence: `app/kiosk/KioskClient.jsx`)
- Kiosk Wizard → Offline Sync: requests sync (evidence: `app/kiosk/KioskClient.jsx`)
- Kiosk Routes → Kiosk Server: dispatches to (evidence: `app/api/kiosk/submit/route.js`)
- Kiosk Routes → Kiosk SMS: uses (evidence: `app/api/kiosk/submit/route.js`)
- Kiosk Routes → Supabase: accesses through
- Kiosk Server → Supabase: uses admin client (evidence: `lib/kiosk/serverApi.js`)
- Kiosk Server → Prediction Adapter: requests prediction (evidence: `lib/kiosk/serverApi.js`)
- Kiosk Server → JS Classifier: imports (evidence: `lib/kiosk/serverApi.js`)
- Classification API → Prediction Adapter: predicts with (evidence: `app/api/classify/route.js`)
- Classification API → Supabase: authenticates with (evidence: `app/api/classify/route.js`)
- Prediction Adapter → Supabase: uses admin client (evidence: `lib/mlPrediction.js`)
- JS Classifier → Python Classifier: also available as
- Authentication → Supabase: uses client (evidence: `services/authService.ts`)
- Captain Casework → Routing Rules: evaluates routing (evidence: `components/captain/complaints/RoutingTab.jsx`)
- Reklamo Documents → Supabase: verifies ownership (evidence: `app/api/reklamo/generate/route.js`)
- Reklamo Documents → Kiosk Server: uses request helpers (evidence: `app/api/reklamo/generate/route.js`)
