# mael-ux/ialert architecture

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

- Interactive diagram: https://gitdiagram.com/mael-ux/ialert
- Repository: https://github.com/mael-ux/ialert

## Overview

iAlert combines a mobile disaster-response client, an Express API and a Python AI service. The main workflow aggregates external hazard telemetry, normalizes it, ingests and clusters it into incidents, then exposes those incidents for globe/feed viewing and citizen reports. Users can also configure geofenced alerts and ask a conversational risk assistant. The README documents the overall service relationships; source excerpts confirm selected ingestion, incident, alert, and theme behavior, but not every mobile route or API call.

Main entry points: [`mobile/App.js`](https://github.com/mael-ux/ialert/blob/main/mobile/App.js) (Expo app), [`backend/src/server.js`](https://github.com/mael-ux/ialert/blob/main/backend/src/server.js) (Express API), [`backend/src/services/ingest.js`](https://github.com/mael-ux/ialert/blob/main/backend/src/services/ingest.js) (Telemetry ingestion), [`backend/src/routes/incidents.routes.js`](https://github.com/mael-ux/ialert/blob/main/backend/src/routes/incidents.routes.js) (Incident routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Mobile experience"]
  node_app["Expo app<br/>[App.js]"]
  node_globe["3D globe<br/>[globeMap.jsx]"]
  node_feed["Incident feed<br/>[feed.jsx]"]
  node_report["Citizen reporting<br/>[report.jsx]"]
  node_alerts_ui["Alert settings<br/>[alert-settings.jsx]"]
  node_polling["Alert polling"]
  node_chat_ui["Chat interface<br/>[chatbot.jsx]"]
end

subgraph group_backend["Incident backend"]
  node_api["Express API<br/>[server.js]"]
  node_incident_routes["Incident routes"]
  node_incident_logic["Incident matching<br/>[incidentLogic.js]"]
  node_ingest["Telemetry ingestion<br/>[ingest.js]"]
  node_alert_routes["Alert routes<br/>[alerts.routes.js]"]
end

subgraph group_ai["AI and telemetry"]
  node_ai_api["FastAPI service<br/>[main.py]"]
  node_aggregator["Disaster aggregation<br/>[service.py]"]
  node_normalizer["Event normalization<br/>[base.py]"]
  node_fetchers["Agency fetchers"]
  node_chat_agent["Risk assistant<br/>[chat_agent.py]"]
end

subgraph group_state["Persistent state"]
  node_db[("PostgreSQL data<br/>[schema.js]")]
end

subgraph group_integrations["External services"]
  node_hazards{{"Telemetry agencies"}}
  node_gemini{{"Google Gemini"}}
  node_weather{{"OpenWeather"}}
  node_auth{{"Clerk"}}
end

node_people(("Community members"))

node_people -->|"uses"| node_app
node_app -->|"renders hazards"| node_globe
node_app -->|"views incidents"| node_feed
node_app -->|"submits reports"| node_report
node_app -->|"configures alerts"| node_alerts_ui
node_alerts_ui -->|"checks alerts"| node_polling
node_polling -->|"polls endpoint"| node_alert_routes
node_app -->|"opens chat"| node_chat_ui
node_globe -->|"requests incidents"| node_api
node_feed -->|"requests incidents"| node_api
node_report -->|"posts report"| node_incident_routes
node_incident_routes -->|"matches incidents"| node_incident_logic
node_incident_routes -->|"reads and writes"| node_db
node_api -->|"routes requests"| node_incident_routes
node_api -->|"routes requests"| node_alert_routes
node_api -->|"schedules ingestion"| node_ingest
node_ingest -->|"fetches events"| node_ai_api
node_ingest -->|"matches events"| node_incident_logic
node_ingest -->|"upserts incidents"| node_db
node_alert_routes -->|"reads preferences"| node_db
node_chat_ui -->|"sends chat"| node_ai_api
node_ai_api -->|"dispatches chat"| node_chat_agent
node_ai_api -->|"serves disasters"| node_aggregator
node_aggregator -->|"runs fetchers"| node_fetchers
node_fetchers -->|"normalizes events"| node_normalizer
node_aggregator -->|"fetches telemetry"| node_hazards
node_chat_agent -->|"calls model"| node_gemini
node_chat_agent -->|"gets forecasts"| node_weather
node_app -->|"authenticates"| node_auth

click node_app "https://github.com/mael-ux/ialert/blob/main/mobile/App.js"
click node_globe "https://github.com/mael-ux/ialert/blob/main/mobile/app/components/globeMap.jsx"
click node_feed "https://github.com/mael-ux/ialert/blob/main/mobile/app/(tabs)/feed.jsx"
click node_report "https://github.com/mael-ux/ialert/blob/main/mobile/app/report.jsx"
click node_alerts_ui "https://github.com/mael-ux/ialert/blob/main/mobile/app/alert-settings.jsx"
click node_polling "https://github.com/mael-ux/ialert/blob/main/mobile/app/services/alertPollingService.js"
click node_chat_ui "https://github.com/mael-ux/ialert/blob/main/mobile/app/(tabs)/chatbot.jsx"
click node_api "https://github.com/mael-ux/ialert/blob/main/backend/src/server.js"
click node_incident_routes "https://github.com/mael-ux/ialert/blob/main/backend/src/routes/incidents.routes.js"
click node_incident_logic "https://github.com/mael-ux/ialert/blob/main/backend/src/services/incidentLogic.js"
click node_ingest "https://github.com/mael-ux/ialert/blob/main/backend/src/services/ingest.js"
click node_alert_routes "https://github.com/mael-ux/ialert/blob/main/backend/src/routes/alerts.routes.js"
click node_ai_api "https://github.com/mael-ux/ialert/blob/main/AI/main.py"
click node_aggregator "https://github.com/mael-ux/ialert/blob/main/AI/disasters/service.py"
click node_normalizer "https://github.com/mael-ux/ialert/blob/main/AI/disasters/base.py"
click node_fetchers "https://github.com/mael-ux/ialert/tree/main/AI/disasters"
click node_chat_agent "https://github.com/mael-ux/ialert/blob/main/AI/chat_agent.py"
click node_db "https://github.com/mael-ux/ialert/blob/main/backend/src/dataBase/schema.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_app,node_globe,node_feed,node_report,node_alerts_ui,node_polling,node_chat_ui toneBlue
class node_api,node_incident_routes,node_incident_logic,node_ingest,node_alert_routes toneAmber
class node_ai_api,node_aggregator,node_normalizer,node_fetchers,node_chat_agent toneMint
class node_db toneRose
class node_hazards,node_gemini,node_weather,node_auth,node_people toneIndigo
```

## Components

### Mobile experience

- [Expo app](https://github.com/mael-ux/ialert/blob/main/mobile/App.js): `mobile/App.js`
- [3D globe](https://github.com/mael-ux/ialert/blob/main/mobile/app/components/globeMap.jsx): `mobile/app/components/globeMap.jsx`
- [Incident feed](https://github.com/mael-ux/ialert/blob/main/mobile/app/(tabs)/feed.jsx): `mobile/app/(tabs)/feed.jsx`
- [Citizen reporting](https://github.com/mael-ux/ialert/blob/main/mobile/app/report.jsx): `mobile/app/report.jsx`
- [Alert settings](https://github.com/mael-ux/ialert/blob/main/mobile/app/alert-settings.jsx): `mobile/app/alert-settings.jsx`
- [Alert polling](https://github.com/mael-ux/ialert/blob/main/mobile/app/services/alertPollingService.js): `mobile/app/services/alertPollingService.js`
- [Chat interface](https://github.com/mael-ux/ialert/blob/main/mobile/app/(tabs)/chatbot.jsx): `mobile/app/(tabs)/chatbot.jsx`

### Incident backend

- [Express API](https://github.com/mael-ux/ialert/blob/main/backend/src/server.js): `backend/src/server.js`
- [Incident routes](https://github.com/mael-ux/ialert/blob/main/backend/src/routes/incidents.routes.js): `backend/src/routes/incidents.routes.js`
- [Incident matching](https://github.com/mael-ux/ialert/blob/main/backend/src/services/incidentLogic.js): `backend/src/services/incidentLogic.js`
- [Telemetry ingestion](https://github.com/mael-ux/ialert/blob/main/backend/src/services/ingest.js): `backend/src/services/ingest.js`
- [Alert routes](https://github.com/mael-ux/ialert/blob/main/backend/src/routes/alerts.routes.js): `backend/src/routes/alerts.routes.js`

### AI and telemetry

- [FastAPI service](https://github.com/mael-ux/ialert/blob/main/AI/main.py): `AI/main.py`
- [Disaster aggregation](https://github.com/mael-ux/ialert/blob/main/AI/disasters/service.py): `AI/disasters/service.py`
- [Event normalization](https://github.com/mael-ux/ialert/blob/main/AI/disasters/base.py): `AI/disasters/base.py`
- [Agency fetchers](https://github.com/mael-ux/ialert/tree/main/AI/disasters): `AI/disasters`
- [Risk assistant](https://github.com/mael-ux/ialert/blob/main/AI/chat_agent.py): `AI/chat_agent.py`

### Persistent state

- [PostgreSQL data](https://github.com/mael-ux/ialert/blob/main/backend/src/dataBase/schema.js): `backend/src/dataBase/schema.js`

### External services

- **Telemetry agencies**
- **Google Gemini**
- **OpenWeather**
- **Clerk**

### Other components

- **Community members**

## Connections

- Community members → Expo app: uses
- Expo app → 3D globe: renders hazards
- Expo app → Incident feed: views incidents
- Expo app → Citizen reporting: submits reports
- Expo app → Alert settings: configures alerts
- Alert settings → Alert polling: checks alerts
- Alert polling → Alert routes: polls endpoint
- Expo app → Chat interface: opens chat
- 3D globe → Express API: requests incidents
- Incident feed → Express API: requests incidents (evidence: `mobile/app/(tabs)/feed.jsx`)
- Citizen reporting → Incident routes: posts report
- Incident routes → Incident matching: matches incidents (evidence: `backend/src/routes/incidents.routes.js`)
- Incident routes → PostgreSQL data: reads and writes (evidence: `backend/src/routes/incidents.routes.js`)
- Express API → Incident routes: routes requests (evidence: `backend/src/server.js`)
- Express API → Alert routes: routes requests (evidence: `backend/src/server.js`)
- Express API → Telemetry ingestion: schedules ingestion (evidence: `backend/src/server.js`)
- Telemetry ingestion → FastAPI service: fetches events (evidence: `backend/src/services/ingest.js`)
- Telemetry ingestion → Incident matching: matches events (evidence: `backend/src/services/ingest.js`)
- Telemetry ingestion → PostgreSQL data: upserts incidents (evidence: `backend/src/services/ingest.js`)
- Alert routes → PostgreSQL data: reads preferences (evidence: `backend/src/routes/alerts.routes.js`)
- Chat interface → FastAPI service: sends chat
- FastAPI service → Risk assistant: dispatches chat (evidence: `AI/main.py`)
- FastAPI service → Disaster aggregation: serves disasters (evidence: `AI/main.py`)
- Disaster aggregation → Agency fetchers: runs fetchers (evidence: `AI/disasters/service.py`)
- Agency fetchers → Event normalization: normalizes events (evidence: `AI/disasters/base.py`)
- Disaster aggregation → Telemetry agencies: fetches telemetry
- Risk assistant → Google Gemini: calls model
- Risk assistant → OpenWeather: gets forecasts
- Expo app → Clerk: authenticates
