# ace-ify/sahara-app architecture

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

- Interactive diagram: https://gitdiagram.com/ace-ify/sahara-app
- Repository: https://github.com/ace-ify/sahara-app

## Overview

Sahārā is a multilingual, voice-first healthcare companion for older adults, combining routine health support with emergency escalation. The main workflow runs from patient interaction in the mobile app through its voice/API services to the FastAPI agent, which classifies intent, executes companion tools, and can trigger emergency dispatch. The README also documents clinical scoring, medication scanning, care tracking, and voice-provider integrations. Some mobile and backend modules were not sampled; their links are included only where the README or source index supports them.

Main entry points: [`mobile/App.tsx`](https://github.com/ace-ify/sahara-app/blob/main/mobile/App.tsx) (Mobile app), [`agent/server/src/emergency.py`](https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/emergency.py) (Dispatch ladder), [`agent/server/src/server.py`](https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/server.py) (FastAPI service), [`mobile/src/services/voice.ts`](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/services/voice.ts) (Voice services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile care app"]
  node_mobile_app["Mobile app<br/>[App.tsx]"]
  node_app_context["App context<br/>[AppContext.tsx]"]
  node_talk["Voice conversation<br/>[TalkScreen.tsx]"]
  node_mobile_voice["Voice services<br/>[voice.ts]"]
  node_mobile_stt["Speech recognition<br/>[stt.ts]"]
  node_mobile_tts["Speech synthesis<br/>[tts.ts]"]
  node_mobile_api["Mobile API<br/>[api.ts]"]
  node_local_storage[("Persistent storage<br/>[storage.ts]")]
  node_chat_storage["Chat history<br/>[chatStorage.ts]"]
  node_onboarding["Onboarding"]
  node_caregiver_pairing["Caregiver pairing"]
  node_vitals["Vitals tracking<br/>[VitalsScreen.tsx]"]
  node_prescription["Prescription scanner"]
  node_medications["Medication care<br/>[MedsScreen.tsx]"]
  node_care_history["Care history"]
  node_doctor_summary["Doctor summary"]
  node_profile["Patient profile<br/>[ProfileScreen.tsx]"]
  node_emergency_screen["Emergency screen"]
end

subgraph group_backend["Agent backend"]
  node_server["FastAPI service<br/>[server.py]"]
  node_agent["Conversational agent<br/>[agent.py]"]
  node_brain["LLM reasoning<br/>[brain.py]"]
  node_tools["Healthcare tools<br/>[tools.py]"]
end

subgraph group_clinical["Clinical and emergency"]
  node_laya["Intent and triage<br/>[laya.py]"]
  node_emergency["Dispatch ladder<br/>[emergency.py]"]
  node_outbound_call["Outbound calls<br/>[outbound_call.py]"]
  node_whatsapp["WhatsApp alerts<br/>[whatsapp.py]"]
end

subgraph group_integrations["External integrations"]
  node_agora["Agora voice platform"]
  node_speech_providers["STT and TTS providers"]
  node_groq["Groq inference"]
  node_health_services["Health data services"]
end

node_patient(("Patient"))
node_caregiver(("Caregiver"))
node_ems(("Emergency services"))

node_patient -->|"uses"| node_mobile_app
node_mobile_app -->|"provides state"| node_app_context
node_mobile_app -->|"routes to"| node_talk
node_mobile_app -->|"routes to"| node_onboarding
node_mobile_app -->|"routes to"| node_caregiver_pairing
node_mobile_app -->|"routes to"| node_vitals
node_mobile_app -->|"routes to"| node_prescription
node_mobile_app -->|"routes to"| node_medications
node_mobile_app -->|"routes to"| node_care_history
node_mobile_app -->|"routes to"| node_doctor_summary
node_mobile_app -->|"routes to"| node_profile
node_mobile_app -->|"routes to"| node_emergency_screen
node_app_context -->|"reads and writes"| node_local_storage
node_talk -.->|"uses"| node_mobile_voice
node_mobile_voice -.->|"recognizes speech"| node_mobile_stt
node_mobile_voice -.->|"speaks responses"| node_mobile_tts
node_talk -.->|"sends requests"| node_mobile_api
node_chat_storage -->|"persists sessions"| node_local_storage
node_prescription -->|"requests scan"| node_mobile_api
node_mobile_app -->|"connects to agent"| node_server
node_mobile_voice -->|"uses real-time voice"| node_agora
node_mobile_stt -->|"transcribes speech"| node_speech_providers
node_mobile_tts -->|"synthesizes speech"| node_speech_providers
node_server -->|"invokes"| node_agent
node_server -->|"classifies intent"| node_laya
node_server -->|"executes tools"| node_tools
node_server -->|"configures dispatch"| node_emergency
node_agent -.->|"uses reasoning"| node_brain
node_agent -->|"requests inference"| node_groq
node_laya -->|"triggers escalation"| node_emergency
node_tools -->|"looks up care data"| node_health_services
node_emergency -->|"alerts"| node_caregiver
node_emergency -->|"dispatches"| node_ems
node_emergency -.->|"initiates calls"| node_outbound_call
node_emergency -.->|"sends alerts"| node_whatsapp

click node_mobile_app "https://github.com/ace-ify/sahara-app/blob/main/mobile/App.tsx"
click node_app_context "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/context/AppContext.tsx"
click node_talk "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/TalkScreen.tsx"
click node_mobile_voice "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/services/voice.ts"
click node_mobile_stt "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/services/stt.ts"
click node_mobile_tts "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/services/tts.ts"
click node_mobile_api "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/services/api.ts"
click node_local_storage "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/services/storage.ts"
click node_chat_storage "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/services/chatStorage.ts"
click node_onboarding "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/OnboardingScreen.tsx"
click node_caregiver_pairing "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/CaregiverPairingScreen.tsx"
click node_vitals "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/VitalsScreen.tsx"
click node_prescription "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/PrescriptionScannerScreen.tsx"
click node_medications "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/MedsScreen.tsx"
click node_care_history "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/CareHistoryScreen.tsx"
click node_doctor_summary "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/DoctorSummaryScreen.tsx"
click node_profile "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/ProfileScreen.tsx"
click node_emergency_screen "https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/EmergencyScreen.tsx"
click node_server "https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/server.py"
click node_agent "https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/agent.py"
click node_brain "https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/brain.py"
click node_laya "https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/laya.py"
click node_tools "https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/tools.py"
click node_emergency "https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/emergency.py"
click node_outbound_call "https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/outbound_call.py"
click node_whatsapp "https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/whatsapp.py"

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_mobile_app,node_app_context,node_talk,node_mobile_voice,node_mobile_stt,node_mobile_tts,node_mobile_api,node_local_storage,node_chat_storage,node_onboarding,node_caregiver_pairing,node_vitals,node_prescription,node_medications,node_care_history,node_doctor_summary,node_profile,node_emergency_screen toneBlue
class node_server,node_agent,node_brain,node_tools toneAmber
class node_laya,node_emergency,node_outbound_call,node_whatsapp toneMint
class node_agora,node_speech_providers,node_groq,node_health_services toneRose
class node_patient,node_caregiver,node_ems toneIndigo
```

## Components

### Mobile care app

- [Mobile app](https://github.com/ace-ify/sahara-app/blob/main/mobile/App.tsx): `mobile/App.tsx`
- [App context](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/context/AppContext.tsx): `mobile/src/context/AppContext.tsx`
- [Voice conversation](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/TalkScreen.tsx): `mobile/src/screens/TalkScreen.tsx`
- [Voice services](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/services/voice.ts): `mobile/src/services/voice.ts`
- [Speech recognition](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/services/stt.ts): `mobile/src/services/stt.ts`
- [Speech synthesis](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/services/tts.ts): `mobile/src/services/tts.ts`
- [Mobile API](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/services/api.ts): `mobile/src/services/api.ts`
- [Persistent storage](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/services/storage.ts): `mobile/src/services/storage.ts`
- [Chat history](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/services/chatStorage.ts): `mobile/src/services/chatStorage.ts`
- [Onboarding](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/OnboardingScreen.tsx): `mobile/src/screens/OnboardingScreen.tsx`
- [Caregiver pairing](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/CaregiverPairingScreen.tsx): `mobile/src/screens/CaregiverPairingScreen.tsx`
- [Vitals tracking](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/VitalsScreen.tsx): `mobile/src/screens/VitalsScreen.tsx`
- [Prescription scanner](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/PrescriptionScannerScreen.tsx): `mobile/src/screens/PrescriptionScannerScreen.tsx`
- [Medication care](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/MedsScreen.tsx): `mobile/src/screens/MedsScreen.tsx`
- [Care history](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/CareHistoryScreen.tsx): `mobile/src/screens/CareHistoryScreen.tsx`
- [Doctor summary](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/DoctorSummaryScreen.tsx): `mobile/src/screens/DoctorSummaryScreen.tsx`
- [Patient profile](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/ProfileScreen.tsx): `mobile/src/screens/ProfileScreen.tsx`
- [Emergency screen](https://github.com/ace-ify/sahara-app/blob/main/mobile/src/screens/EmergencyScreen.tsx): `mobile/src/screens/EmergencyScreen.tsx`

### Agent backend

- [FastAPI service](https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/server.py): `agent/server/src/server.py`
- [Conversational agent](https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/agent.py): `agent/server/src/agent.py`
- [LLM reasoning](https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/brain.py): `agent/server/src/brain.py`
- [Healthcare tools](https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/tools.py): `agent/server/src/tools.py`

### Clinical and emergency

- [Intent and triage](https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/laya.py): `agent/server/src/laya.py`
- [Dispatch ladder](https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/emergency.py): `agent/server/src/emergency.py`
- [Outbound calls](https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/outbound_call.py): `agent/server/src/outbound_call.py`
- [WhatsApp alerts](https://github.com/ace-ify/sahara-app/blob/main/agent/server/src/whatsapp.py): `agent/server/src/whatsapp.py`

### External integrations

- **Agora voice platform**
- **STT and TTS providers**
- **Groq inference**
- **Health data services**

### Other components

- **Patient**
- **Caregiver**
- **Emergency services**

## Connections

- Patient → Mobile app: uses
- Mobile app → App context: provides state (evidence: `mobile/App.tsx`)
- Mobile app → Voice conversation: routes to (evidence: `mobile/App.tsx`)
- Mobile app → Onboarding: routes to (evidence: `mobile/App.tsx`)
- Mobile app → Caregiver pairing: routes to (evidence: `mobile/App.tsx`)
- Mobile app → Vitals tracking: routes to (evidence: `mobile/App.tsx`)
- Mobile app → Prescription scanner: routes to (evidence: `mobile/App.tsx`)
- Mobile app → Medication care: routes to (evidence: `mobile/App.tsx`)
- Mobile app → Care history: routes to (evidence: `mobile/App.tsx`)
- Mobile app → Doctor summary: routes to (evidence: `mobile/App.tsx`)
- Mobile app → Patient profile: routes to (evidence: `mobile/App.tsx`)
- Mobile app → Emergency screen: routes to (evidence: `mobile/App.tsx`)
- App context → Persistent storage: reads and writes (evidence: `mobile/src/context/AppContext.tsx`)
- Voice conversation → Voice services: uses
- Voice services → Speech recognition: recognizes speech
- Voice services → Speech synthesis: speaks responses
- Voice conversation → Mobile API: sends requests
- Chat history → Persistent storage: persists sessions (evidence: `mobile/src/services/chatStorage.ts`)
- Prescription scanner → Mobile API: requests scan (evidence: `mobile/src/screens/PrescriptionScannerScreen.tsx`)
- Mobile app → FastAPI service: connects to agent
- Voice services → Agora voice platform: uses real-time voice
- Speech recognition → STT and TTS providers: transcribes speech
- Speech synthesis → STT and TTS providers: synthesizes speech
- FastAPI service → Conversational agent: invokes (evidence: `agent/server/src/server.py`)
- FastAPI service → Intent and triage: classifies intent (evidence: `agent/server/src/server.py`)
- FastAPI service → Healthcare tools: executes tools (evidence: `agent/server/src/server.py`)
- FastAPI service → Dispatch ladder: configures dispatch (evidence: `agent/server/src/server.py`)
- Conversational agent → LLM reasoning: uses reasoning
- Conversational agent → Groq inference: requests inference
- Intent and triage → Dispatch ladder: triggers escalation
- Healthcare tools → Health data services: looks up care data
- Dispatch ladder → Caregiver: alerts
- Dispatch ladder → Emergency services: dispatches
- Dispatch ladder → Outbound calls: initiates calls
- Dispatch ladder → WhatsApp alerts: sends alerts
