# flamingdemon1/lakaz architecture

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

- Interactive diagram: https://gitdiagram.com/flamingdemon1/lakaz
- Repository: https://github.com/flamingdemon1/lakaz

## Overview

Lakaz is a caregiver-support prototype for receiving and acknowledging help requests, with wearer/band status, incident history, and a Mauritius facility directory. Its primary workflow is a band event sent through an authenticated Supabase function, persisted in Supabase, shown in the caregiver app, and acknowledged with a receipt that can be checked after refresh. The README also documents sample-mode and phone-GPS/demo capabilities. Source excerpts show the device intake implementation; app-to-data relationships and several listed product branches are documented at a higher level, so those links cite the README rather than implying inspected call paths.

Main entry points: [`backend/supabase/functions/device-event/index.ts`](https://github.com/flamingdemon1/lakaz/blob/main/backend/supabase/functions/device-event/index.ts) (Event endpoint), [`mobile/src/app/(tabs)/index.tsx`](https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/app/(tabs)/index.tsx) (Caregiver home), [`mobile/src/data/alertsLive.ts`](https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/data/alertsLive.ts) (Alert services), [`mobile/src/app/alert/[id]/index.tsx`](https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/app/alert/%5Bid%5D/index.tsx) (Incident view)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device["Device intake"]
  node_intake["Event endpoint<br/>[index.ts]"]
  node_request["Request validation<br/>[request.ts]"]
end

subgraph group_care["Caregiver app"]
  node_alerts["Alerts tab<br/>[alerts.tsx]"]
  node_home["Caregiver home<br/>[index.tsx]"]
  node_incident["Incident view<br/>[index.tsx]"]
  node_report["Incident report<br/>[report.tsx]"]
  node_alert_data["Alert services<br/>[alertsLive.ts]"]
  node_help_data["Help alert data<br/>[helpAlert.ts]"]
  node_timeline["Incident timeline"]
  node_auth["Carer accounts<br/>[auth.tsx]"]
end

subgraph group_support["Care support"]
  node_people["Wearer profiles<br/>[people.tsx]"]
  node_zones["Safe zones<br/>[zones.tsx]"]
  node_tracking["Location tracking<br/>[tracking.tsx]"]
  node_facilities["Facility lookup<br/>[facilities.tsx]"]
  node_escalation["Escalation settings<br/>[escalation.tsx]"]
end

subgraph group_demo["Demo integrations"]
  node_simserver["Demo event server<br/>[server.js]"]
  node_gps["Phone GPS demo<br/>[phone-gps.js]"]
end

node_band(("Wearable band"))
node_supabase[("Supabase")]

node_band -->|"sends event"| node_intake
node_intake -->|"validates through"| node_request
node_intake -->|"submits RPC"| node_supabase
node_supabase -->|"provides live alerts"| node_alerts
node_alerts -->|"loads alerts"| node_alert_data
node_alert_data -->|"reads and acknowledges"| node_supabase
node_home -->|"shows alert state"| node_alert_data
node_incident -->|"acknowledges alert"| node_help_data
node_incident -->|"shows timeline"| node_timeline
node_report -->|"shows incident history"| node_timeline
node_auth -->|"authenticates carers"| node_supabase
node_people -->|"stores wearer details"| node_supabase
node_facilities -->|"looks up facilities"| node_supabase
node_zones -.->|"can use demo GPS"| node_gps
node_tracking -.->|"uses phone GPS stand-in"| node_gps
node_band -.->|"sends demo events"| node_simserver
node_simserver -.->|"serves demo status"| node_home
node_escalation -.->|"supports sample escalation"| node_home

click node_intake "https://github.com/flamingdemon1/lakaz/blob/main/backend/supabase/functions/device-event/index.ts"
click node_request "https://github.com/flamingdemon1/lakaz/blob/main/backend/supabase/functions/device-event/request.ts"
click node_alerts "https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/app/(tabs)/alerts.tsx"
click node_home "https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/app/(tabs)/index.tsx"
click node_incident "https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/app/alert/%5Bid%5D/index.tsx"
click node_report "https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/app/alert/%5Bid%5D/report.tsx"
click node_alert_data "https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/data/alertsLive.ts"
click node_help_data "https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/data/helpAlert.ts"
click node_timeline "https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/lib/useAlertTimeline.ts"
click node_auth "https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/data/auth.tsx"
click node_people "https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/data/people.tsx"
click node_zones "https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/data/zones.tsx"
click node_tracking "https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/data/tracking.tsx"
click node_facilities "https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/app/facilities.tsx"
click node_escalation "https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/data/escalation.tsx"
click node_simserver "https://github.com/flamingdemon1/lakaz/blob/main/simulator/server.js"
click node_gps "https://github.com/flamingdemon1/lakaz/blob/main/simulator/phone-gps.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_intake,node_request toneBlue
class node_alerts,node_home,node_incident,node_report,node_alert_data,node_help_data,node_timeline,node_auth,node_supabase toneAmber
class node_people,node_zones,node_tracking,node_facilities,node_escalation toneMint
class node_simserver,node_gps toneRose
class node_band toneIndigo
```

## Components

### Device intake

- [Event endpoint](https://github.com/flamingdemon1/lakaz/blob/main/backend/supabase/functions/device-event/index.ts): `backend/supabase/functions/device-event/index.ts`
- [Request validation](https://github.com/flamingdemon1/lakaz/blob/main/backend/supabase/functions/device-event/request.ts): `backend/supabase/functions/device-event/request.ts`

### Caregiver app

- [Alerts tab](https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/app/(tabs)/alerts.tsx): `mobile/src/app/(tabs)/alerts.tsx`
- [Caregiver home](https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/app/(tabs)/index.tsx): `mobile/src/app/(tabs)/index.tsx`
- [Incident view](https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/app/alert/%5Bid%5D/index.tsx): `mobile/src/app/alert/[id]/index.tsx`
- [Incident report](https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/app/alert/%5Bid%5D/report.tsx): `mobile/src/app/alert/[id]/report.tsx`
- [Alert services](https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/data/alertsLive.ts): `mobile/src/data/alertsLive.ts`
- [Help alert data](https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/data/helpAlert.ts): `mobile/src/data/helpAlert.ts`
- [Incident timeline](https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/lib/useAlertTimeline.ts): `mobile/src/lib/useAlertTimeline.ts`
- [Carer accounts](https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/data/auth.tsx): `mobile/src/data/auth.tsx`

### Care support

- [Wearer profiles](https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/data/people.tsx): `mobile/src/data/people.tsx`
- [Safe zones](https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/data/zones.tsx): `mobile/src/data/zones.tsx`
- [Location tracking](https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/data/tracking.tsx): `mobile/src/data/tracking.tsx`
- [Facility lookup](https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/app/facilities.tsx): `mobile/src/app/facilities.tsx`
- [Escalation settings](https://github.com/flamingdemon1/lakaz/blob/main/mobile/src/data/escalation.tsx): `mobile/src/data/escalation.tsx`

### Demo integrations

- [Demo event server](https://github.com/flamingdemon1/lakaz/blob/main/simulator/server.js): `simulator/server.js`
- [Phone GPS demo](https://github.com/flamingdemon1/lakaz/blob/main/simulator/phone-gps.js): `simulator/phone-gps.js`

### Other components

- **Wearable band**
- **Supabase**

## Connections

- Wearable band → Event endpoint: sends event (evidence: `README.md`)
- Event endpoint → Request validation: validates through (evidence: `backend/supabase/functions/device-event/index.ts`)
- Event endpoint → Supabase: submits RPC (evidence: `backend/supabase/functions/device-event/index.ts`)
- Supabase → Alerts tab: provides live alerts (evidence: `README.md`)
- Alerts tab → Alert services: loads alerts (evidence: `README.md`)
- Alert services → Supabase: reads and acknowledges (evidence: `README.md`)
- Caregiver home → Alert services: shows alert state (evidence: `README.md`)
- Incident view → Help alert data: acknowledges alert (evidence: `README.md`)
- Incident view → Incident timeline: shows timeline (evidence: `mobile/src/lib/useAlertTimeline.ts`)
- Incident report → Incident timeline: shows incident history (evidence: `mobile/src/lib/useAlertTimeline.ts`)
- Carer accounts → Supabase: authenticates carers (evidence: `README.md`)
- Wearer profiles → Supabase: stores wearer details (evidence: `README.md`)
- Facility lookup → Supabase: looks up facilities (evidence: `README.md`)
- Safe zones → Phone GPS demo: can use demo GPS (evidence: `README.md`)
- Location tracking → Phone GPS demo: uses phone GPS stand-in (evidence: `README.md`)
- Wearable band → Demo event server: sends demo events (evidence: `simulator/server.js`)
- Demo event server → Caregiver home: serves demo status (evidence: `simulator/server.js`)
- Escalation settings → Caregiver home: supports sample escalation (evidence: `README.md`)
