# matthewzegarra/quadra architecture

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

- Interactive diagram: https://gitdiagram.com/matthewzegarra/quadra
- Repository: https://github.com/matthewzegarra/quadra

## Overview

Quadra is an offline-first neighborhood app. Residents browse nearby services, publish listings or favors (including by voice), and coordinate emergency aid; local SQLite remains usable offline, with queued changes synchronized to Supabase when connectivity returns. In emergencies, reports can also be relayed phone-to-phone. The graph preserves the documented day-to-day and emergency branches. Some subsystem links rely on README architecture statements; unsampled route details are not inferred beyond indexed references.

Main entry points: [`src/data/repositories/base.ts`](https://github.com/matthewzegarra/quadra/blob/main/src/data/repositories/base.ts) (Write and outbox), [`src/app/(tabs)/index.tsx`](https://github.com/matthewzegarra/quadra/blob/main/src/app/(tabs)/index.tsx) (Nearby home), [`src/app/publicar/[tipo].tsx`](https://github.com/matthewzegarra/quadra/blob/main/src/app/publicar/%5Btipo%5D.tsx) (Publish flow), [`src/data/repositories/emergency.ts`](https://github.com/matthewzegarra/quadra/blob/main/src/data/repositories/emergency.ts) (Aid reports)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Resident experience"]
  node_daily["Nearby home<br/>[index.tsx]"]
  node_publish["Publish flow<br/>[&#91;tipo&#93;.tsx]"]
  node_profile["Profile<br/>[perfil.tsx]"]
  node_emergencyui["Emergency screens<br/>[index.tsx]"]
  node_voice["Voice input<br/>[useVoiceInput.ts]"]
  node_shared_ui["Shared UI controls<br/>[ui.tsx]"]
  node_apptext["Accessible text<br/>[AppText.tsx]"]
  node_bigbutton["Action button<br/>[BigButton.tsx]"]
  node_theme["Design tokens<br/>[tokens.ts]"]
end

subgraph group_community["Neighborhood exchange"]
  node_listing["Service directory<br/>[listings.ts]"]
  node_favors["Favor exchange<br/>[favors.ts]"]
  node_catalog["Domain catalog<br/>[catalog.ts]"]
  node_moderation["Neighbor endorsements<br/>[moderation.ts]"]
end

subgraph group_emergency["Emergency coordination"]
  node_emergencyrepo["Aid reports<br/>[emergency.ts]"]
  node_meshrouter["Mesh routing<br/>[MeshRouter.ts]"]
  node_meshtransport["Mesh transport<br/>[MeshTransport.ts]"]
  node_nearby["Nearby links<br/>[NearbyTransport.ts]"]
end

subgraph group_localdata["Offline data"]
  node_localquery["Local query hooks<br/>[useLocalQuery.ts]"]
  node_sqlite[("SQLite database<br/>[db.ts]")]
  node_repo["Write and outbox<br/>[base.ts]"]
  node_sync["Sync engine<br/>[SyncEngine.ts]"]
  node_store["Data state<br/>[store.ts]"]
  node_session["Session state<br/>[store.ts]"]
  node_profiles["Profile records<br/>[profiles.ts]"]
end

subgraph group_services["Connectivity and services"]
  node_voiceonline["Voice parser<br/>[index.ts]"]
  node_voiceoffline["Offline parser"]
  node_supabase[("Supabase<br/>[supabase.ts]")]
  node_connectivity["Connectivity<br/>[connectivity.ts]"]
  node_location["GPS location<br/>[location.ts]"]
  node_geo["Distance utilities<br/>[geo.ts]"]
  node_privacy["Location privacy<br/>[privacy.ts]"]
  node_notify["Notifications<br/>[notify.ts]"]
  node_offline_map["Offline neighborhood map<br/>[offlineMap.ts]"]
end

node_resident(("Resident"))

node_resident -->|"browses"| node_daily
node_resident -->|"publishes"| node_publish
node_resident -->|"requests aid"| node_emergencyui
node_daily -->|"loads listings"| node_listing
node_daily -->|"uses categories"| node_catalog
node_publish -->|"saves listings"| node_listing
node_publish -->|"saves favors"| node_favors
node_publish -.->|"captures speech"| node_voice
node_voice -->|"parses offline"| node_voiceoffline
node_voice -->|"parses online"| node_voiceonline
node_emergencyui -->|"loads reports"| node_emergencyrepo
node_emergencyrepo -->|"uses mesh reports"| node_meshrouter
node_meshrouter -->|"reads and writes"| node_sqlite
node_meshrouter -->|"queues relayed reports"| node_repo
node_meshrouter -->|"dispatches messages"| node_meshtransport
node_meshtransport -->|"uses nearby links"| node_nearby
node_nearby -->|"relays to neighbor phones"| node_resident
node_daily -->|"shows neighborhood map"| node_offline_map
node_listing -->|"writes through"| node_repo
node_favors -->|"writes through"| node_repo
node_emergencyrepo -->|"writes through"| node_repo
node_repo -->|"writes locally"| node_sqlite
node_repo -->|"bumps table versions"| node_store
node_localquery -->|"reads locally"| node_sqlite
node_sync -->|"pulls local data"| node_sqlite
node_sync -->|"pushes outbox"| node_repo
node_sync -->|"syncs over HTTPS"| node_supabase
node_connectivity -.->|"triggers sync"| node_sync
node_profile -.->|"updates profile"| node_profiles
node_profiles -->|"uses session identity"| node_session
node_location -->|"uses coordinates"| node_geo
node_daily -->|"filters nearby"| node_listing
node_shared_ui -->|"renders text"| node_apptext
node_bigbutton -->|"renders text"| node_apptext
node_apptext -->|"reads easy mode"| node_session
node_apptext -->|"uses typography tokens"| node_theme
node_moderation -.->|"validates endorsements"| node_supabase
node_emergencyrepo -->|"notifies neighbors"| node_notify
node_privacy -->|"uses distance rules"| node_geo

click node_daily "https://github.com/matthewzegarra/quadra/blob/main/src/app/(tabs)/index.tsx"
click node_publish "https://github.com/matthewzegarra/quadra/blob/main/src/app/publicar/%5Btipo%5D.tsx"
click node_profile "https://github.com/matthewzegarra/quadra/blob/main/src/app/(tabs)/perfil.tsx"
click node_emergencyui "https://github.com/matthewzegarra/quadra/blob/main/src/app/emergencia/(tabs)/index.tsx"
click node_listing "https://github.com/matthewzegarra/quadra/blob/main/src/data/repositories/listings.ts"
click node_favors "https://github.com/matthewzegarra/quadra/blob/main/src/data/repositories/favors.ts"
click node_catalog "https://github.com/matthewzegarra/quadra/blob/main/src/features/catalog.ts"
click node_moderation "https://github.com/matthewzegarra/quadra/blob/main/src/data/repositories/moderation.ts"
click node_emergencyrepo "https://github.com/matthewzegarra/quadra/blob/main/src/data/repositories/emergency.ts"
click node_meshrouter "https://github.com/matthewzegarra/quadra/blob/main/src/mesh/MeshRouter.ts"
click node_meshtransport "https://github.com/matthewzegarra/quadra/blob/main/src/mesh/MeshTransport.ts"
click node_nearby "https://github.com/matthewzegarra/quadra/blob/main/src/mesh/NearbyTransport.ts"
click node_voice "https://github.com/matthewzegarra/quadra/blob/main/src/features/voice/useVoiceInput.ts"
click node_voiceonline "https://github.com/matthewzegarra/quadra/blob/main/supabase/functions/parse-voice/index.ts"
click node_voiceoffline "https://github.com/matthewzegarra/quadra/blob/main/src/features/voice/parseVoiceOffline.ts"
click node_localquery "https://github.com/matthewzegarra/quadra/blob/main/src/data/useLocalQuery.ts"
click node_sqlite "https://github.com/matthewzegarra/quadra/blob/main/src/data/db.ts"
click node_repo "https://github.com/matthewzegarra/quadra/blob/main/src/data/repositories/base.ts"
click node_sync "https://github.com/matthewzegarra/quadra/blob/main/src/data/sync/SyncEngine.ts"
click node_store "https://github.com/matthewzegarra/quadra/blob/main/src/data/store.ts"
click node_session "https://github.com/matthewzegarra/quadra/blob/main/src/features/session/store.ts"
click node_profiles "https://github.com/matthewzegarra/quadra/blob/main/src/data/repositories/profiles.ts"
click node_supabase "https://github.com/matthewzegarra/quadra/blob/main/src/lib/supabase.ts"
click node_connectivity "https://github.com/matthewzegarra/quadra/blob/main/src/lib/connectivity.ts"
click node_location "https://github.com/matthewzegarra/quadra/blob/main/src/lib/location.ts"
click node_geo "https://github.com/matthewzegarra/quadra/blob/main/src/lib/geo.ts"
click node_privacy "https://github.com/matthewzegarra/quadra/blob/main/src/lib/privacy.ts"
click node_notify "https://github.com/matthewzegarra/quadra/blob/main/src/lib/notify.ts"
click node_offline_map "https://github.com/matthewzegarra/quadra/blob/main/src/features/map/offlineMap.ts"
click node_shared_ui "https://github.com/matthewzegarra/quadra/blob/main/src/components/ui.tsx"
click node_apptext "https://github.com/matthewzegarra/quadra/blob/main/src/components/AppText.tsx"
click node_bigbutton "https://github.com/matthewzegarra/quadra/blob/main/src/components/BigButton.tsx"
click node_theme "https://github.com/matthewzegarra/quadra/blob/main/src/theme/tokens.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_daily,node_publish,node_profile,node_emergencyui,node_voice,node_shared_ui,node_apptext,node_bigbutton,node_theme toneBlue
class node_listing,node_favors,node_catalog,node_moderation toneAmber
class node_emergencyrepo,node_meshrouter,node_meshtransport,node_nearby toneMint
class node_localquery,node_sqlite,node_repo,node_sync,node_store,node_session,node_profiles toneRose
class node_voiceonline,node_voiceoffline,node_supabase,node_connectivity,node_location,node_geo,node_privacy,node_notify,node_offline_map,node_resident toneIndigo
```

## Components

### Resident experience

- [Nearby home](https://github.com/matthewzegarra/quadra/blob/main/src/app/(tabs)/index.tsx): `src/app/(tabs)/index.tsx`
- [Publish flow](https://github.com/matthewzegarra/quadra/blob/main/src/app/publicar/%5Btipo%5D.tsx): `src/app/publicar/[tipo].tsx`
- [Profile](https://github.com/matthewzegarra/quadra/blob/main/src/app/(tabs)/perfil.tsx): `src/app/(tabs)/perfil.tsx`
- [Emergency screens](https://github.com/matthewzegarra/quadra/blob/main/src/app/emergencia/(tabs)/index.tsx): `src/app/emergencia/(tabs)/index.tsx`
- [Voice input](https://github.com/matthewzegarra/quadra/blob/main/src/features/voice/useVoiceInput.ts): `src/features/voice/useVoiceInput.ts`
- [Shared UI controls](https://github.com/matthewzegarra/quadra/blob/main/src/components/ui.tsx): `src/components/ui.tsx`
- [Accessible text](https://github.com/matthewzegarra/quadra/blob/main/src/components/AppText.tsx): `src/components/AppText.tsx`
- [Action button](https://github.com/matthewzegarra/quadra/blob/main/src/components/BigButton.tsx): `src/components/BigButton.tsx`
- [Design tokens](https://github.com/matthewzegarra/quadra/blob/main/src/theme/tokens.ts): `src/theme/tokens.ts`

### Neighborhood exchange

- [Service directory](https://github.com/matthewzegarra/quadra/blob/main/src/data/repositories/listings.ts): `src/data/repositories/listings.ts`
- [Favor exchange](https://github.com/matthewzegarra/quadra/blob/main/src/data/repositories/favors.ts): `src/data/repositories/favors.ts`
- [Domain catalog](https://github.com/matthewzegarra/quadra/blob/main/src/features/catalog.ts): `src/features/catalog.ts`
- [Neighbor endorsements](https://github.com/matthewzegarra/quadra/blob/main/src/data/repositories/moderation.ts): `src/data/repositories/moderation.ts`

### Emergency coordination

- [Aid reports](https://github.com/matthewzegarra/quadra/blob/main/src/data/repositories/emergency.ts): `src/data/repositories/emergency.ts`
- [Mesh routing](https://github.com/matthewzegarra/quadra/blob/main/src/mesh/MeshRouter.ts): `src/mesh/MeshRouter.ts`
- [Mesh transport](https://github.com/matthewzegarra/quadra/blob/main/src/mesh/MeshTransport.ts): `src/mesh/MeshTransport.ts`
- [Nearby links](https://github.com/matthewzegarra/quadra/blob/main/src/mesh/NearbyTransport.ts): `src/mesh/NearbyTransport.ts`

### Offline data

- [Local query hooks](https://github.com/matthewzegarra/quadra/blob/main/src/data/useLocalQuery.ts): `src/data/useLocalQuery.ts`
- [SQLite database](https://github.com/matthewzegarra/quadra/blob/main/src/data/db.ts): `src/data/db.ts`
- [Write and outbox](https://github.com/matthewzegarra/quadra/blob/main/src/data/repositories/base.ts): `src/data/repositories/base.ts`
- [Sync engine](https://github.com/matthewzegarra/quadra/blob/main/src/data/sync/SyncEngine.ts): `src/data/sync/SyncEngine.ts`
- [Data state](https://github.com/matthewzegarra/quadra/blob/main/src/data/store.ts): `src/data/store.ts`
- [Session state](https://github.com/matthewzegarra/quadra/blob/main/src/features/session/store.ts): `src/features/session/store.ts`
- [Profile records](https://github.com/matthewzegarra/quadra/blob/main/src/data/repositories/profiles.ts): `src/data/repositories/profiles.ts`

### Connectivity and services

- [Voice parser](https://github.com/matthewzegarra/quadra/blob/main/supabase/functions/parse-voice/index.ts): `supabase/functions/parse-voice/index.ts`
- [Offline parser](https://github.com/matthewzegarra/quadra/blob/main/src/features/voice/parseVoiceOffline.ts): `src/features/voice/parseVoiceOffline.ts`
- [Supabase](https://github.com/matthewzegarra/quadra/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- [Connectivity](https://github.com/matthewzegarra/quadra/blob/main/src/lib/connectivity.ts): `src/lib/connectivity.ts`
- [GPS location](https://github.com/matthewzegarra/quadra/blob/main/src/lib/location.ts): `src/lib/location.ts`
- [Distance utilities](https://github.com/matthewzegarra/quadra/blob/main/src/lib/geo.ts): `src/lib/geo.ts`
- [Location privacy](https://github.com/matthewzegarra/quadra/blob/main/src/lib/privacy.ts): `src/lib/privacy.ts`
- [Notifications](https://github.com/matthewzegarra/quadra/blob/main/src/lib/notify.ts): `src/lib/notify.ts`
- [Offline neighborhood map](https://github.com/matthewzegarra/quadra/blob/main/src/features/map/offlineMap.ts): `src/features/map/offlineMap.ts`

### Other components

- **Resident**

## Connections

- Resident → Nearby home: browses (evidence: `README.md`)
- Resident → Publish flow: publishes (evidence: `README.md`)
- Resident → Emergency screens: requests aid (evidence: `README.md`)
- Nearby home → Service directory: loads listings (evidence: `src/app/(tabs)/index.tsx`)
- Nearby home → Domain catalog: uses categories (evidence: `src/app/(tabs)/index.tsx`)
- Publish flow → Service directory: saves listings (evidence: `src/app/publicar/[tipo].tsx`)
- Publish flow → Favor exchange: saves favors (evidence: `src/app/publicar/[tipo].tsx`)
- Publish flow → Voice input: captures speech
- Voice input → Offline parser: parses offline (evidence: `README.md`)
- Voice input → Voice parser: parses online (evidence: `README.md`)
- Emergency screens → Aid reports: loads reports (evidence: `src/app/emergencia/(tabs)/index.tsx`)
- Aid reports → Mesh routing: uses mesh reports (evidence: `src/data/repositories/emergency.ts`)
- Mesh routing → SQLite database: reads and writes (evidence: `src/mesh/MeshRouter.ts`)
- Mesh routing → Write and outbox: queues relayed reports (evidence: `src/mesh/MeshRouter.ts`)
- Mesh routing → Mesh transport: dispatches messages (evidence: `README.md`)
- Mesh transport → Nearby links: uses nearby links (evidence: `README.md`)
- Nearby links → Resident: relays to neighbor phones (evidence: `README.md`)
- Nearby home → Offline neighborhood map: shows neighborhood map (evidence: `README.md`)
- Service directory → Write and outbox: writes through (evidence: `src/data/repositories/listings.ts`)
- Favor exchange → Write and outbox: writes through (evidence: `src/data/repositories/favors.ts`)
- Aid reports → Write and outbox: writes through (evidence: `src/data/repositories/emergency.ts`)
- Write and outbox → SQLite database: writes locally (evidence: `src/data/repositories/base.ts`)
- Write and outbox → Data state: bumps table versions (evidence: `src/data/repositories/base.ts`)
- Local query hooks → SQLite database: reads locally (evidence: `src/data/useLocalQuery.ts`)
- Sync engine → SQLite database: pulls local data (evidence: `README.md`)
- Sync engine → Write and outbox: pushes outbox (evidence: `README.md`)
- Sync engine → Supabase: syncs over HTTPS (evidence: `README.md`)
- Connectivity → Sync engine: triggers sync (evidence: `src/data/sync/SyncEngine.ts`)
- Profile → Profile records: updates profile
- Profile records → Session state: uses session identity (evidence: `src/data/repositories/profiles.ts`)
- GPS location → Distance utilities: uses coordinates (evidence: `src/lib/location.ts`)
- Nearby home → Service directory: filters nearby (evidence: `src/app/(tabs)/index.tsx`)
- Shared UI controls → Accessible text: renders text (evidence: `src/components/ui.tsx`)
- Action button → Accessible text: renders text (evidence: `src/components/BigButton.tsx`)
- Accessible text → Session state: reads easy mode (evidence: `src/components/AppText.tsx`)
- Accessible text → Design tokens: uses typography tokens (evidence: `src/components/AppText.tsx`)
- Neighbor endorsements → Supabase: validates endorsements
- Aid reports → Notifications: notifies neighbors (evidence: `src/data/repositories/emergency.ts`)
- Location privacy → Distance utilities: uses distance rules (evidence: `src/lib/privacy.ts`)
