# wilfredo-domanico-jr/flood-escape-mobile-app architecture

> Architecture diagram of the GitHub repository wilfredo-domanico-jr/flood-escape-mobile-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wilfredo-domanico-jr/flood-escape-mobile-app
- Repository: https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app

## Overview

Flood Escape is a Metro Manila flood-awareness mobile app. Users browse nearby, live flood reports, submit and verify reports, and check a route against recent flooding; saved routes can trigger alerts. Offline report writes use a SQLite outbox, while cached reads remain available. The README documents the broader backend capabilities, including centers, confidence and report lifecycle, and push notifications. Source excerpts confirm route-risk classification, location handling, Supabase realtime updates, and app state; other links below rely on README architecture statements rather than sampled implementation.

Main entry points: [`src/app`](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/app) (Expo app routes), [`src/features/reports`](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/features/reports) (Report flooding), [`src/features/routes/RouteScreen.tsx`](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/features/routes/RouteScreen.tsx) (Route check screen), [`src/features/map`](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/features/map) (Live flood map)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile experience"]
  node_app["Expo app routes"]
  node_location["Device location<br/>[useLocation.ts]"]
  node_centers["Evacuation centers"]
  node_notifications["Route and push alerts"]
end

subgraph group_reports["Flood reports"]
  node_map["Live flood map"]
  node_reporting["Report flooding"]
  node_verification["Verify reports<br/>[useVerify.ts]"]
  node_confidence["Confidence and lifecycle"]
  node_activity["My report activity"]
end

subgraph group_routes["Route safety"]
  node_routeui["Route check screen<br/>[RouteScreen.tsx]"]
  node_routehooks["Route safety queries<br/>[useRouteSafety.ts]"]
  node_risk["Risk classification<br/>[routeRisk.ts]"]
  node_routefunction["Routing edge function<br/>[index.ts]"]
end

subgraph group_offline["Offline and sync"]
  node_outbox[("SQLite report outbox<br/>[outbox.ts]")]
  node_sync["Outbox sync runner<br/>[OutboxRunner.tsx]"]
  node_cache[("SQLite query cache<br/>[sqlite.ts]")]
end

subgraph group_services["Backend services"]
  node_supabase["Supabase backend"]
  node_database[("Postgres and PostGIS")]
  node_storage[("Report photo storage")]
  node_pushfn["Push delivery function<br/>[index.ts]"]
end

node_person(("App user"))
node_routingprovider["OpenRouteService"]

node_person -->|"uses"| node_app
node_app -->|"opens"| node_map
node_app -->|"opens"| node_reporting
node_app -->|"opens"| node_routeui
node_location -->|"provides position"| node_map
node_map -->|"queries reports"| node_supabase
node_supabase -->|"streams report changes"| node_map
node_reporting -->|"queues offline writes"| node_outbox
node_sync -->|"drains"| node_outbox
node_sync -->|"syncs reports"| node_supabase
node_reporting -->|"uploads photos"| node_storage
node_verification -->|"submits verification"| node_supabase
node_supabase -->|"runs RPCs"| node_database
node_database -->|"computes authoritative score"| node_confidence
node_reporting -->|"uses score mirror"| node_confidence
node_activity -->|"shows pending reports"| node_outbox
node_routeui -->|"gets origin"| node_location
node_routeui -->|"requests route check"| node_routehooks
node_routehooks -->|"requests route"| node_routefunction
node_routefunction -->|"gets directions"| node_routingprovider
node_routefunction -->|"queries route reports"| node_supabase
node_routehooks -->|"classifies hits"| node_risk
node_routeui -->|"prompts route alerts"| node_notifications
node_notifications -->|"stores preferences"| node_supabase
node_supabase -.->|"invokes delivery"| node_pushfn
node_centers -->|"queries nearby centers"| node_supabase
node_supabase -->|"persists query cache"| node_cache

click node_app "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/app"
click node_location "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/hooks/useLocation.ts"
click node_map "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/features/map"
click node_reporting "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/features/reports"
click node_verification "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/features/verification/useVerify.ts"
click node_confidence "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/lib/confidence"
click node_activity "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/features/activity"
click node_routeui "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/features/routes/RouteScreen.tsx"
click node_routehooks "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/features/routes/useRouteSafety.ts"
click node_risk "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/lib/geo/routeRisk.ts"
click node_routefunction "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/supabase/functions/route-safety/index.ts"
click node_centers "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/features/centers"
click node_notifications "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/features/notifications"
click node_outbox "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/features/offline/outbox.ts"
click node_sync "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/features/offline/OutboxRunner.tsx"
click node_cache "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/db/sqlite.ts"
click node_pushfn "https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/supabase/functions/send-push/index.ts"

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_location,node_centers,node_notifications,node_person toneBlue
class node_map,node_reporting,node_verification,node_confidence,node_activity toneAmber
class node_routeui,node_routehooks,node_risk,node_routefunction,node_routingprovider toneMint
class node_outbox,node_sync,node_cache toneRose
class node_supabase,node_database,node_storage,node_pushfn toneIndigo
```

## Components

### Mobile experience

- [Expo app routes](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/app): `src/app`
- [Device location](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/hooks/useLocation.ts): `src/hooks/useLocation.ts`
- [Evacuation centers](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/features/centers): `src/features/centers`
- [Route and push alerts](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/features/notifications): `src/features/notifications`

### Flood reports

- [Live flood map](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/features/map): `src/features/map`
- [Report flooding](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/features/reports): `src/features/reports`
- [Verify reports](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/features/verification/useVerify.ts): `src/features/verification/useVerify.ts`
- [Confidence and lifecycle](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/lib/confidence): `src/lib/confidence`
- [My report activity](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/tree/main/src/features/activity): `src/features/activity`

### Route safety

- [Route check screen](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/features/routes/RouteScreen.tsx): `src/features/routes/RouteScreen.tsx`
- [Route safety queries](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/features/routes/useRouteSafety.ts): `src/features/routes/useRouteSafety.ts`
- [Risk classification](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/lib/geo/routeRisk.ts): `src/lib/geo/routeRisk.ts`
- [Routing edge function](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/supabase/functions/route-safety/index.ts): `supabase/functions/route-safety/index.ts`

### Offline and sync

- [SQLite report outbox](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/features/offline/outbox.ts): `src/features/offline/outbox.ts`
- [Outbox sync runner](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/features/offline/OutboxRunner.tsx): `src/features/offline/OutboxRunner.tsx`
- [SQLite query cache](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/src/db/sqlite.ts): `src/db/sqlite.ts`

### Backend services

- **Supabase backend**
- **Postgres and PostGIS**
- **Report photo storage**
- [Push delivery function](https://github.com/wilfredo-domanico-jr/flood-escape-mobile-app/blob/main/supabase/functions/send-push/index.ts): `supabase/functions/send-push/index.ts`

### Other components

- **App user**
- **OpenRouteService**

## Connections

- App user → Expo app routes: uses (evidence: `README.md`)
- Expo app routes → Live flood map: opens (evidence: `README.md`)
- Expo app routes → Report flooding: opens (evidence: `README.md`)
- Expo app routes → Route check screen: opens (evidence: `src/app/(tabs)/route.tsx`)
- Device location → Live flood map: provides position (evidence: `README.md`)
- Live flood map → Supabase backend: queries reports (evidence: `README.md`)
- Supabase backend → Live flood map: streams report changes (evidence: `src/features/map/useReportsRealtime.ts`)
- Report flooding → SQLite report outbox: queues offline writes (evidence: `README.md`)
- Outbox sync runner → SQLite report outbox: drains (evidence: `README.md`)
- Outbox sync runner → Supabase backend: syncs reports (evidence: `README.md`)
- Report flooding → Report photo storage: uploads photos (evidence: `README.md`)
- Verify reports → Supabase backend: submits verification (evidence: `README.md`)
- Supabase backend → Postgres and PostGIS: runs RPCs (evidence: `README.md`)
- Postgres and PostGIS → Confidence and lifecycle: computes authoritative score (evidence: `README.md`)
- Report flooding → Confidence and lifecycle: uses score mirror (evidence: `README.md`)
- My report activity → SQLite report outbox: shows pending reports (evidence: `README.md`)
- Route check screen → Device location: gets origin (evidence: `src/features/routes/RouteScreen.tsx`)
- Route check screen → Route safety queries: requests route check (evidence: `src/features/routes/RouteScreen.tsx`)
- Route safety queries → Routing edge function: requests route (evidence: `README.md`)
- Routing edge function → OpenRouteService: gets directions (evidence: `README.md`)
- Routing edge function → Supabase backend: queries route reports (evidence: `README.md`)
- Route safety queries → Risk classification: classifies hits (evidence: `src/features/routes/useRouteSafety.ts`)
- Route check screen → Route and push alerts: prompts route alerts (evidence: `src/features/routes/RouteScreen.tsx`)
- Route and push alerts → Supabase backend: stores preferences (evidence: `README.md`)
- Supabase backend → Push delivery function: invokes delivery
- Evacuation centers → Supabase backend: queries nearby centers (evidence: `README.md`)
- Supabase backend → SQLite query cache: persists query cache (evidence: `README.md`)
