How rscence-2026-uptac/project-pia-waterback works
PIA Waterback supports residents and local water-response teams during water disruptions. Its workflow moves from rainfall and utility signals through disruption prediction, affected-area assessment, and backup-source ranking to LGU allocation, resident notification, and restoration confirmation. The web app presents resident, captain, operator, and LGU views, with sample-data and offline modes alongside live Supabase access. The graph preserves documented product branches, including planning and the predictor’s synthetic-training pipeline. Some Edge Function internals and unsampled screens are represented only at their documented boundaries.
Main entry points: endpoints.ts Function API · lgu LGU response views · main.tsx App routing · resident Resident views
Components 33
Web app
- App routing
apps/web/src/main.tsx - Resident views
apps/web/src/screens/resident - Captain view
apps/web/src/screens/captain/CaptainScreen.tsx - Operator view
apps/web/src/screens/operator/OperatorScreen.tsx - LGU response views
apps/web/src/screens/lgu - Status retrieval
apps/web/src/api/status.ts - Cached status
apps/web/src/offline/useBarangayStatus.ts - Realtime dashboard
apps/web/src/realtime/useDashboard.ts - Function API
apps/web/src/api/endpoints.ts - Sample data
apps/web/src/data/mock.ts - Language and copy
apps/web/src/copy/i18n.ts
Disruption response
- Disruption monitor
supabase/functions/disruption-monitor/index.ts - Disruption prediction
supabase/functions/disruption-predictor/index.ts - Prediction handler
supabase/functions/_shared/handler.ts - Forecast and prediction
supabase/functions/_shared/predict.ts - Affected areas
supabase/functions/affected-areas/index.ts - Backup-source ranking
supabase/functions/rank-chain/index.ts - Allocation decisions
supabase/functions/confirm-allocation/index.ts - Response deployment
supabase/functions/deploy-response/index.ts - Resident notification
supabase/functions/notify-residents/index.ts - SMS replies
supabase/functions/sms-webhook/index.ts - Restoration confirmation
supabase/functions/resident-confirmation/index.ts - Dashboard snapshot
supabase/functions/dashboard-snapshot/index.ts
Contracts and data
- Shared schemas
packages/shared-types/src/schemas - Seeded sources
apps/web/src/data/seedSources.ts - Water-access planning
apps/web/src/screens/lgu/PlanScreen.tsx
Predictor development
- Synthetic trajectories
ml/synthetic.py - July simulation
ml/simulate_july.py - Model training
ml/train_predictor.py - Model utilities
ml/v3_lib.py
Other components
- Residents
- Response staff
- Supabase
Connections 34
- App routing → Resident views: routes to
apps/web/src/main.tsx - App routing → Captain view: routes to
apps/web/src/main.tsx - App routing → Operator view: routes to
apps/web/src/main.tsx - App routing → LGU response views: routes to
apps/web/src/main.tsx - Residents → Resident views: views status
- Response staff → Operator view: reviews readings
- Response staff → LGU response views: plans response
- Resident views → Cached status: loads status
apps/web/src/screens/resident/StatusScreen.tsx - Captain view → Cached status: loads status
apps/web/src/screens/captain/CaptainScreen.tsx - Cached status → Status retrieval: fetches live
apps/web/src/offline/useBarangayStatus.ts - Cached status → Sample data: uses fallback
apps/web/src/offline/useBarangayStatus.ts - Status retrieval → Supabase: reads live data
- Operator view → Function API: calls API
apps/web/src/screens/operator/OperatorScreen.tsx - LGU response views → Function API: calls API
apps/web/src/screens/lgu/AllocationScreen.tsx - Function API → Disruption prediction: calls function
apps/web/src/api/endpoints.ts - Function API → Affected areas: calls function
apps/web/src/api/endpoints.ts - Function API → Backup-source ranking: calls function
apps/web/src/api/endpoints.ts - Function API → Disruption monitor: calls function
apps/web/src/api/endpoints.ts - Function API → Dashboard snapshot: calls function
apps/web/src/api/endpoints.ts - Disruption prediction → Prediction handler: delegates to
supabase/functions/disruption-predictor/index.ts - Prediction handler → Forecast and prediction: calls prediction
supabase/functions/_shared/handler.ts - LGU response views → Water-access planning: presents plan
- LGU response views → Seeded sources: uses source data
apps/web/src/screens/lgu/AllocationScreen.tsx - Resident views → Language and copy: uses translations
apps/web/src/screens/resident/StatusScreen.tsx - Operator view → Realtime dashboard: shows live updates
- SMS replies → Restoration confirmation: confirms restoration
- SMS replies → Supabase: records messages
- Resident notification → Supabase: writes notifications
- Dashboard snapshot → Supabase: reads snapshot data
- Shared schemas → Function API: defines contracts
- Synthetic trajectories → July simulation: reuses simulation
ml/synthetic.py - Model training → Synthetic trajectories: builds training data
ml/train_predictor.py - Model training → July simulation: uses simulated data
ml/train_predictor.py - Model training → Model utilities: uses utilities
ml/train_predictor.py