# amirhesham957-bit/zad-app-1 architecture

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

- Interactive diagram: https://gitdiagram.com/amirhesham957-bit/zad-app-1
- Repository: https://github.com/amirhesham957-bit/zad-app-1

## Overview

Zad is an Android family assistant combining household inventory, spending and family features with Supabase Edge Functions and AI. The documented user workflow includes scanning receipts or shelves to update inventory and shopping needs, and capturing bank notifications for spending analysis. The tree and excerpts expose backend AI, Telegram and intelligence services plus native Android capture/location components, but not the main Flutter feature implementation. Edges for documented but unsampled capabilities are therefore limited to README-supported links; other uncertain wiring is omitted.

Main entry points: [`supabase/functions/zad-brain/staff.ts`](https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/staff.ts) (Assistant staff), [`zad_flutter`](https://github.com/amirhesham957-bit/zad-app-1/tree/main/zad_flutter) (Zad app), [`zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ZadNotificationListenerService.kt`](https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ZadNotificationListenerService.kt) (Bank notifications), [`zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ZadBankListenerPlugin.kt`](https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ZadBankListenerPlugin.kt) (Bank plugin)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Android client"]
  node_app["Zad app"]
  node_activity["Android host<br/>[MainActivity.kt]"]
end

subgraph group_capture["Device capture"]
  node_bank_listener["Bank notifications"]
  node_notification_store[("Captured queue")]
  node_bank_plugin["Bank plugin"]
  node_bank_delivery["Background delivery"]
  node_screen_events["Screen events<br/>[ScreenEvents.kt]"]
  node_geofence_plugin["Geofence plugin"]
  node_fences["Location fences<br/>[Fences.kt]"]
  node_place_receiver["Place events"]
  node_place_store[("Place event store<br/>[PlaceEventStore.kt]")]
  node_geo_delivery["Geofence delivery<br/>[Delivery.kt]"]
end

subgraph group_brain["Zad intelligence"]
  node_brain_entry["AI assistant<br/>[index.ts]"]
  node_staff["Assistant staff<br/>[staff.ts]"]
  node_model["Model adapter<br/>[callModel.ts]"]
  node_decision_review["Decision review<br/>[decisionReview.ts]"]
  node_brain_shared["Shared brain logic<br/>[shared.ts]"]
  node_agent_mail["Agent mail<br/>[agentMail.ts]"]
  node_bill_anomaly["Bill anomaly analysis<br/>[billAnomaly.ts]"]
  node_life_shift["Life changes<br/>[lifeShift.ts]"]
  node_dialect["Dialect support<br/>[dialect.ts]"]
  node_voice["Voice support<br/>[zadVoice.ts]"]
end

subgraph group_services["Backend services"]
  node_intelligence["AI services"]
  node_telegram["Telegram bot"]
  node_household["Household workflows"]
end

node_family(("Family user"))
node_supabase[("Supabase")]
node_bank_apps["Bank apps"]
node_location_services["Location services"]
node_model_providers["AI providers"]

node_family -->|"uses"| node_app
node_app -.->|"uses"| node_household
node_app -->|"stores data"| node_supabase
node_app -->|"captures spending"| node_bank_listener
node_bank_apps -.->|"posts notifications"| node_bank_listener
node_bank_listener -->|"queues captures"| node_notification_store
node_bank_listener -->|"registers"| node_screen_events
node_bank_plugin -->|"reads queue"| node_notification_store
node_bank_plugin -->|"uses"| node_bank_delivery
node_bank_plugin -->|"uses"| node_screen_events
node_bank_plugin -->|"uses"| node_bank_listener
node_geofence_plugin -->|"configures"| node_fences
node_geofence_plugin -->|"uses"| node_place_store
node_fences -->|"registers fences"| node_location_services
node_location_services -.->|"reports transitions"| node_place_receiver
node_place_receiver -->|"writes events"| node_place_store
node_place_receiver -->|"schedules"| node_geo_delivery
node_family -->|"asks assistant"| node_brain_entry
node_brain_entry -.->|"dispatches"| node_staff
node_staff -->|"uses"| node_decision_review
node_staff -->|"uses"| node_agent_mail
node_staff -->|"uses"| node_bill_anomaly
node_staff -->|"uses"| node_life_shift
node_staff -->|"uses"| node_brain_shared
node_model -.->|"calls models"| node_model_providers
node_family -->|"requests AI features"| node_intelligence
node_family -.->|"chats via Telegram"| node_telegram
node_app -.->|"hosts Android features"| node_activity

click node_app "https://github.com/amirhesham957-bit/zad-app-1/tree/main/zad_flutter"
click node_activity "https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/android/app/src/main/kotlin/com/aistudio/zad/wrtqvx/MainActivity.kt"
click node_bank_listener "https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ZadNotificationListenerService.kt"
click node_notification_store "https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/CapturedNotificationStore.kt"
click node_bank_plugin "https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ZadBankListenerPlugin.kt"
click node_bank_delivery "https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/BackgroundDelivery.kt"
click node_screen_events "https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ScreenEvents.kt"
click node_geofence_plugin "https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/ZadGeofencePlugin.kt"
click node_fences "https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/Fences.kt"
click node_place_receiver "https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/PlaceEventReceiver.kt"
click node_place_store "https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/PlaceEventStore.kt"
click node_geo_delivery "https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/Delivery.kt"
click node_brain_entry "https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/index.ts"
click node_staff "https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/staff.ts"
click node_model "https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/callModel.ts"
click node_decision_review "https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/decisionReview.ts"
click node_brain_shared "https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/shared.ts"
click node_agent_mail "https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/agentMail.ts"
click node_bill_anomaly "https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/billAnomaly.ts"
click node_life_shift "https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/lifeShift.ts"
click node_dialect "https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/_shared/dialect.ts"
click node_voice "https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/_shared/zadVoice.ts"
click node_intelligence "https://github.com/amirhesham957-bit/zad-app-1/tree/main/supabase/functions/zad-core-intelligence"
click node_telegram "https://github.com/amirhesham957-bit/zad-app-1/tree/main/supabase/functions/zad-telegram-bot"
click node_household "https://github.com/amirhesham957-bit/zad-app-1/tree/main/supabase/functions"

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_activity,node_family toneBlue
class node_bank_listener,node_notification_store,node_bank_plugin,node_bank_delivery,node_screen_events,node_geofence_plugin,node_fences,node_place_receiver,node_place_store,node_geo_delivery,node_supabase toneAmber
class node_brain_entry,node_staff,node_model,node_decision_review,node_brain_shared,node_agent_mail,node_bill_anomaly,node_life_shift,node_dialect,node_voice toneMint
class node_intelligence,node_telegram,node_household toneRose
class node_bank_apps,node_location_services,node_model_providers toneIndigo
```

## Components

### Android client

- [Zad app](https://github.com/amirhesham957-bit/zad-app-1/tree/main/zad_flutter): `zad_flutter`
- [Android host](https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/android/app/src/main/kotlin/com/aistudio/zad/wrtqvx/MainActivity.kt): `zad_flutter/android/app/src/main/kotlin/com/aistudio/zad/wrtqvx/MainActivity.kt`

### Device capture

- [Bank notifications](https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ZadNotificationListenerService.kt): `zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ZadNotificationListenerService.kt`
- [Captured queue](https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/CapturedNotificationStore.kt): `zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/CapturedNotificationStore.kt`
- [Bank plugin](https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ZadBankListenerPlugin.kt): `zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ZadBankListenerPlugin.kt`
- [Background delivery](https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/BackgroundDelivery.kt): `zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/BackgroundDelivery.kt`
- [Screen events](https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ScreenEvents.kt): `zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ScreenEvents.kt`
- [Geofence plugin](https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/ZadGeofencePlugin.kt): `zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/ZadGeofencePlugin.kt`
- [Location fences](https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/Fences.kt): `zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/Fences.kt`
- [Place events](https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/PlaceEventReceiver.kt): `zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/PlaceEventReceiver.kt`
- [Place event store](https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/PlaceEventStore.kt): `zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/PlaceEventStore.kt`
- [Geofence delivery](https://github.com/amirhesham957-bit/zad-app-1/blob/main/zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/Delivery.kt): `zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/Delivery.kt`

### Zad intelligence

- [AI assistant](https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/index.ts): `supabase/functions/zad-brain/index.ts`
- [Assistant staff](https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/staff.ts): `supabase/functions/zad-brain/staff.ts`
- [Model adapter](https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/callModel.ts): `supabase/functions/zad-brain/callModel.ts`
- [Decision review](https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/decisionReview.ts): `supabase/functions/zad-brain/decisionReview.ts`
- [Shared brain logic](https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/shared.ts): `supabase/functions/zad-brain/shared.ts`
- [Agent mail](https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/agentMail.ts): `supabase/functions/zad-brain/agentMail.ts`
- [Bill anomaly analysis](https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/billAnomaly.ts): `supabase/functions/zad-brain/billAnomaly.ts`
- [Life changes](https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/zad-brain/lifeShift.ts): `supabase/functions/zad-brain/lifeShift.ts`
- [Dialect support](https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/_shared/dialect.ts): `supabase/functions/_shared/dialect.ts`
- [Voice support](https://github.com/amirhesham957-bit/zad-app-1/blob/main/supabase/functions/_shared/zadVoice.ts): `supabase/functions/_shared/zadVoice.ts`

### Backend services

- [AI services](https://github.com/amirhesham957-bit/zad-app-1/tree/main/supabase/functions/zad-core-intelligence): `supabase/functions/zad-core-intelligence`
- [Telegram bot](https://github.com/amirhesham957-bit/zad-app-1/tree/main/supabase/functions/zad-telegram-bot): `supabase/functions/zad-telegram-bot`
- [Household workflows](https://github.com/amirhesham957-bit/zad-app-1/tree/main/supabase/functions): `supabase/functions`

### Other components

- **Family user**
- **Supabase**
- **Bank apps**
- **Location services**
- **AI providers**

## Connections

- Family user → Zad app: uses (evidence: `README.md`)
- Zad app → Household workflows: uses
- Zad app → Supabase: stores data (evidence: `README.md`)
- Zad app → Bank notifications: captures spending (evidence: `README.md`)
- Bank apps → Bank notifications: posts notifications
- Bank notifications → Captured queue: queues captures (evidence: `zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ZadNotificationListenerService.kt`)
- Bank notifications → Screen events: registers (evidence: `zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ZadNotificationListenerService.kt`)
- Bank plugin → Captured queue: reads queue (evidence: `zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ZadBankListenerPlugin.kt`)
- Bank plugin → Background delivery: uses (evidence: `zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ZadBankListenerPlugin.kt`)
- Bank plugin → Screen events: uses (evidence: `zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ZadBankListenerPlugin.kt`)
- Bank plugin → Bank notifications: uses (evidence: `zad_flutter/packages/zad_bank_listener/android/src/main/kotlin/com/aistudio/zad/banklistener/ZadBankListenerPlugin.kt`)
- Geofence plugin → Location fences: configures (evidence: `zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/ZadGeofencePlugin.kt`)
- Geofence plugin → Place event store: uses (evidence: `zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/ZadGeofencePlugin.kt`)
- Location fences → Location services: registers fences (evidence: `zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/Fences.kt`)
- Location services → Place events: reports transitions
- Place events → Place event store: writes events (evidence: `zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/PlaceEventReceiver.kt`)
- Place events → Geofence delivery: schedules (evidence: `zad_flutter/packages/zad_geofence/android/src/main/kotlin/com/aistudio/zad/geofence/PlaceEventReceiver.kt`)
- Family user → AI assistant: asks assistant (evidence: `README.md`)
- AI assistant → Assistant staff: dispatches
- Assistant staff → Decision review: uses (evidence: `supabase/functions/zad-brain/staff.ts`)
- Assistant staff → Agent mail: uses (evidence: `supabase/functions/zad-brain/staff.ts`)
- Assistant staff → Bill anomaly analysis: uses (evidence: `supabase/functions/zad-brain/staff.ts`)
- Assistant staff → Life changes: uses (evidence: `supabase/functions/zad-brain/staff.ts`)
- Assistant staff → Shared brain logic: uses (evidence: `supabase/functions/zad-brain/staff.ts`)
- Model adapter → AI providers: calls models
- Family user → AI services: requests AI features (evidence: `README.md`)
- Family user → Telegram bot: chats via Telegram
- Zad app → Android host: hosts Android features (evidence: `zad_flutter/android/app/src/main/kotlin/com/aistudio/zad/wrtqvx/ZadBalanceWidget.kt`)
