# sifayathf/salaamcompassproject architecture

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

- Interactive diagram: https://gitdiagram.com/sifayathf/salaamcompassproject
- Repository: https://github.com/sifayathf/salaamcompassproject

## Overview

Salaam Compass has two user-facing products in this repository: a crisis-response web platform and an Android offline Qibla compass. The web workflow accepts an emergency message, routes it through agent coordination, returns responses and a safety status, and presents them in chat. The README also documents specialized response capabilities not independently visible in the sampled implementation. The Android workflow selects a city or obtains a location, then uses compass readings to guide the user toward the Qibla. Some web UI and agent capabilities are documented but only partially implemented in the sampled source.

Main entry points: [`android/app/src/main/java/com/salaam/compass/MainActivity.kt`](https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/MainActivity.kt) (Android app), [`backend/agents/graph.py`](https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py) (Supervisor routing), [`backend/main.py`](https://github.com/sifayathf/salaamcompassproject/blob/main/backend/main.py) (FastAPI routes), [`frontend/src/components/Chat.tsx`](https://github.com/sifayathf/salaamcompassproject/blob/main/frontend/src/components/Chat.tsx) (Emergency chat)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Crisis Web Platform"]
  node_webapp["Web app shell<br/>[App.tsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_chat["Emergency chat<br/>[Chat.tsx]"]
  node_webapi["API client<br/>[api.ts]"]
end

subgraph group_response["Emergency Response"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_supervisor{{"Supervisor routing<br/>[graph.py]"}}
  node_weather["Weather response<br/>[graph.py]"]
  node_medical["Medical response<br/>[graph.py]"]
  node_community["Community response<br/>[graph.py]"]
  node_shelter["Shelter response<br/>[graph.py]"]
  node_resources["Resource response<br/>[graph.py]"]
  node_communication["Communication<br/>[graph.py]"]
  node_safety["Safety review<br/>[graph.py]"]
  node_translation["Translation support"]
  node_state["Workflow state<br/>[state.py]"]
end

subgraph group_data["Emergency Data"]
  node_dbconfig[("Database session<br/>[database.py]")]
  node_records["Emergency records<br/>[models.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
end

subgraph group_android["Android Qibla Compass"]
  node_mobile["Android app<br/>[MainActivity.kt]"]
  node_location["Location tracking<br/>[LocationTracker.kt]"]
  node_citypicker["City selection<br/>[CityPicker.kt]"]
  node_citysearch["Online city search<br/>[CitySearch.kt]"]
  node_cities["City data<br/>[Cities.kt]"]
  node_prefs["Saved place<br/>[Prefs.kt]"]
  node_sensor["Compass sensor<br/>[CompassSensor.kt]"]
  node_filter["Heading filter<br/>[HeadingFilter.kt]"]
  node_qibla["Qibla bearing<br/>[Qibla.kt]"]
  node_dial["Compass dial<br/>[CompassDial.kt]"]
end

node_person(("Community member"))
node_nominatim(("OpenStreetMap Nominatim"))
node_gps(("Device location"))

node_person -->|"describes emergency"| node_chat
node_chat -->|"submits message"| node_webapi
node_webapp -->|"renders"| node_chat
node_webapp -->|"renders"| node_dashboard
node_api -->|"streams workflow"| node_supervisor
node_supervisor -->|"routes weather"| node_weather
node_supervisor -->|"routes medical"| node_medical
node_supervisor -->|"routes community"| node_community
node_supervisor -->|"routes default"| node_safety
node_weather -->|"dispatches"| node_shelter
node_shelter -->|"dispatches"| node_resources
node_resources -->|"dispatches"| node_communication
node_medical -->|"dispatches"| node_communication
node_community -->|"dispatches"| node_communication
node_communication -->|"dispatches"| node_safety
node_supervisor -->|"uses state"| node_state
node_api -->|"creates tables"| node_dbconfig
node_api -->|"creates and queries"| node_records
node_records -->|"uses base"| node_dbconfig
node_api -->|"validates responses"| node_schemas
node_person -.->|"uses compass"| node_mobile
node_mobile -->|"tracks position"| node_location
node_mobile -->|"opens picker"| node_citypicker
node_citypicker -->|"searches places"| node_citysearch
node_citysearch -->|"queries"| node_nominatim
node_mobile -.->|"uses places"| node_cities
node_mobile -->|"loads and saves"| node_prefs
node_mobile -->|"starts sensor"| node_sensor
node_sensor -->|"filters heading"| node_filter
node_mobile -->|"calculates bearing"| node_qibla
node_mobile -->|"renders direction"| node_dial
node_location -.->|"reads position"| node_gps
node_translation -.->|"supports response"| node_communication

click node_webapp "https://github.com/sifayathf/salaamcompassproject/blob/main/frontend/src/App.tsx"
click node_dashboard "https://github.com/sifayathf/salaamcompassproject/blob/main/frontend/src/components/Dashboard.tsx"
click node_chat "https://github.com/sifayathf/salaamcompassproject/blob/main/frontend/src/components/Chat.tsx"
click node_webapi "https://github.com/sifayathf/salaamcompassproject/blob/main/frontend/src/api.ts"
click node_api "https://github.com/sifayathf/salaamcompassproject/blob/main/backend/main.py"
click node_supervisor "https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py"
click node_weather "https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py"
click node_medical "https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py"
click node_community "https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py"
click node_shelter "https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py"
click node_resources "https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py"
click node_communication "https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py"
click node_safety "https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py"
click node_translation "https://github.com/sifayathf/salaamcompassproject/tree/main/backend/agents"
click node_state "https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/state.py"
click node_dbconfig "https://github.com/sifayathf/salaamcompassproject/blob/main/backend/database.py"
click node_records "https://github.com/sifayathf/salaamcompassproject/blob/main/backend/models.py"
click node_schemas "https://github.com/sifayathf/salaamcompassproject/blob/main/backend/schemas.py"
click node_mobile "https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/MainActivity.kt"
click node_location "https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/LocationTracker.kt"
click node_citypicker "https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/CityPicker.kt"
click node_citysearch "https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/CitySearch.kt"
click node_cities "https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/core/Cities.kt"
click node_prefs "https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/Prefs.kt"
click node_sensor "https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/CompassSensor.kt"
click node_filter "https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/core/HeadingFilter.kt"
click node_qibla "https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/core/Qibla.kt"
click node_dial "https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/CompassDial.kt"

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_webapp,node_dashboard,node_chat,node_webapi toneBlue
class node_api,node_supervisor,node_weather,node_medical,node_community,node_shelter,node_resources,node_communication,node_safety,node_translation,node_state toneAmber
class node_dbconfig,node_records,node_schemas toneMint
class node_mobile,node_location,node_citypicker,node_citysearch,node_cities,node_prefs,node_sensor,node_filter,node_qibla,node_dial toneRose
class node_person,node_nominatim,node_gps toneIndigo
```

## Components

### Crisis Web Platform

- [Web app shell](https://github.com/sifayathf/salaamcompassproject/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Dashboard](https://github.com/sifayathf/salaamcompassproject/blob/main/frontend/src/components/Dashboard.tsx): `frontend/src/components/Dashboard.tsx`
- [Emergency chat](https://github.com/sifayathf/salaamcompassproject/blob/main/frontend/src/components/Chat.tsx): `frontend/src/components/Chat.tsx`
- [API client](https://github.com/sifayathf/salaamcompassproject/blob/main/frontend/src/api.ts): `frontend/src/api.ts`

### Emergency Response

- [FastAPI routes](https://github.com/sifayathf/salaamcompassproject/blob/main/backend/main.py): `backend/main.py`
- [Supervisor routing](https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py): `backend/agents/graph.py`
- [Weather response](https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py): `backend/agents/graph.py`
- [Medical response](https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py): `backend/agents/graph.py`
- [Community response](https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py): `backend/agents/graph.py`
- [Shelter response](https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py): `backend/agents/graph.py`
- [Resource response](https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py): `backend/agents/graph.py`
- [Communication](https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py): `backend/agents/graph.py`
- [Safety review](https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/graph.py): `backend/agents/graph.py`
- [Translation support](https://github.com/sifayathf/salaamcompassproject/tree/main/backend/agents): `backend/agents`
- [Workflow state](https://github.com/sifayathf/salaamcompassproject/blob/main/backend/agents/state.py): `backend/agents/state.py`

### Emergency Data

- [Database session](https://github.com/sifayathf/salaamcompassproject/blob/main/backend/database.py): `backend/database.py`
- [Emergency records](https://github.com/sifayathf/salaamcompassproject/blob/main/backend/models.py): `backend/models.py`
- [API schemas](https://github.com/sifayathf/salaamcompassproject/blob/main/backend/schemas.py): `backend/schemas.py`

### Android Qibla Compass

- [Android app](https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/MainActivity.kt): `android/app/src/main/java/com/salaam/compass/MainActivity.kt`
- [Location tracking](https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/LocationTracker.kt): `android/app/src/main/java/com/salaam/compass/LocationTracker.kt`
- [City selection](https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/CityPicker.kt): `android/app/src/main/java/com/salaam/compass/CityPicker.kt`
- [Online city search](https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/CitySearch.kt): `android/app/src/main/java/com/salaam/compass/CitySearch.kt`
- [City data](https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/core/Cities.kt): `android/app/src/main/java/com/salaam/compass/core/Cities.kt`
- [Saved place](https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/Prefs.kt): `android/app/src/main/java/com/salaam/compass/Prefs.kt`
- [Compass sensor](https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/CompassSensor.kt): `android/app/src/main/java/com/salaam/compass/CompassSensor.kt`
- [Heading filter](https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/core/HeadingFilter.kt): `android/app/src/main/java/com/salaam/compass/core/HeadingFilter.kt`
- [Qibla bearing](https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/core/Qibla.kt): `android/app/src/main/java/com/salaam/compass/core/Qibla.kt`
- [Compass dial](https://github.com/sifayathf/salaamcompassproject/blob/main/android/app/src/main/java/com/salaam/compass/CompassDial.kt): `android/app/src/main/java/com/salaam/compass/CompassDial.kt`

### Other components

- **Community member**
- **OpenStreetMap Nominatim**
- **Device location**

## Connections

- Community member → Emergency chat: describes emergency (evidence: `frontend/src/components/Chat.tsx`)
- Emergency chat → API client: submits message (evidence: `frontend/src/components/Chat.tsx`)
- Web app shell → Emergency chat: renders (evidence: `frontend/src/App.tsx`)
- Web app shell → Dashboard: renders (evidence: `frontend/src/App.tsx`)
- FastAPI routes → Supervisor routing: streams workflow (evidence: `backend/main.py`)
- Supervisor routing → Weather response: routes weather (evidence: `backend/agents/graph.py`)
- Supervisor routing → Medical response: routes medical (evidence: `backend/agents/graph.py`)
- Supervisor routing → Community response: routes community (evidence: `backend/agents/graph.py`)
- Supervisor routing → Safety review: routes default (evidence: `backend/agents/graph.py`)
- Weather response → Shelter response: dispatches (evidence: `backend/agents/graph.py`)
- Shelter response → Resource response: dispatches (evidence: `backend/agents/graph.py`)
- Resource response → Communication: dispatches (evidence: `backend/agents/graph.py`)
- Medical response → Communication: dispatches (evidence: `backend/agents/graph.py`)
- Community response → Communication: dispatches (evidence: `backend/agents/graph.py`)
- Communication → Safety review: dispatches (evidence: `backend/agents/graph.py`)
- Supervisor routing → Workflow state: uses state (evidence: `backend/agents/graph.py`)
- FastAPI routes → Database session: creates tables (evidence: `backend/main.py`)
- FastAPI routes → Emergency records: creates and queries (evidence: `backend/main.py`)
- Emergency records → Database session: uses base (evidence: `backend/models.py`)
- FastAPI routes → API schemas: validates responses (evidence: `backend/main.py`)
- Community member → Android app: uses compass
- Android app → Location tracking: tracks position (evidence: `android/app/src/main/java/com/salaam/compass/MainActivity.kt`)
- Android app → City selection: opens picker (evidence: `android/app/src/main/java/com/salaam/compass/MainActivity.kt`)
- City selection → Online city search: searches places (evidence: `android/app/src/main/java/com/salaam/compass/CityPicker.kt`)
- Online city search → OpenStreetMap Nominatim: queries (evidence: `android/app/src/main/java/com/salaam/compass/CitySearch.kt`)
- Android app → City data: uses places
- Android app → Saved place: loads and saves (evidence: `android/app/src/main/java/com/salaam/compass/MainActivity.kt`)
- Android app → Compass sensor: starts sensor (evidence: `android/app/src/main/java/com/salaam/compass/MainActivity.kt`)
- Compass sensor → Heading filter: filters heading (evidence: `android/app/src/main/java/com/salaam/compass/CompassSensor.kt`)
- Android app → Qibla bearing: calculates bearing (evidence: `android/app/src/main/java/com/salaam/compass/MainActivity.kt`)
- Android app → Compass dial: renders direction (evidence: `android/app/src/main/java/com/salaam/compass/MainActivity.kt`)
- Location tracking → Device location: reads position
- Translation support → Communication: supports response (evidence: `README.md`)
