# aryaa-7/relief-link architecture

> Architecture diagram of the GitHub repository aryaa-7/relief-link, 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/aryaa-7/relief-link
- Repository: https://github.com/aryaa-7/relief-link

## Overview

ReliefLink is an offline-capable disaster-relief reporting hub: phone reports reach a FastAPI service, are stored in MongoDB, and are triaged by a background worker using a networked Ollama server or rule-based fallback. Coordinators review reports, update cases, manage AI-server settings, and request resource matching through a locally served dashboard. The README documents the Flutter client and offline sync, but this tree contains no Flutter application source; its internal workflow is therefore represented only at the documented boundary. Relationships for unsampled routes are limited to indexed references or README statements.

Main entry points: [`app/main.py`](https://github.com/aryaa-7/relief-link/blob/master/app/main.py) (FastAPI hub), [`app/worker.py`](https://github.com/aryaa-7/relief-link/blob/master/app/worker.py) (Background AI worker), [`app/store.py`](https://github.com/aryaa-7/relief-link/blob/master/app/store.py) (MongoDB store operations), [`app/routes/admin.py`](https://github.com/aryaa-7/relief-link/blob/master/app/routes/admin.py) (Admin endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Clients"]
  node_dashboard["Coordinator dashboard<br/>[App.jsx]"]
  node_api_client["Dashboard API client<br/>[api.js]"]
end

subgraph group_api["Hub API"]
  node_hub["FastAPI hub<br/>[main.py]"]
  node_report_routes["Report endpoints<br/>[reports.py]"]
  node_admin_routes["Admin endpoints<br/>[admin.py]"]
  node_resource_routes["Resource endpoints<br/>[resources.py]"]
  node_match_routes["Matching endpoints<br/>[matches.py]"]
  node_location_routes["Location endpoints<br/>[locations.py]"]
  node_contract["API models<br/>[models.py]"]
end

subgraph group_triage["AI Triage"]
  node_worker["Background AI worker<br/>[worker.py]"]
  node_triage_logic["AI triage and validation<br/>[triage.py]"]
  node_ollama["Ollama client<br/>[ollama_client.py]"]
  node_fallback["Rule-based fallback<br/>[fallback.py]"]
  node_runtime["AI runtime status<br/>[runtime.py]"]
  node_ai_server(("Ollama AI server"))
end

subgraph group_data["Relief Data"]
  node_store["MongoDB store operations<br/>[store.py]"]
  node_mongo[("MongoDB")]
end

subgraph group_coord["Coordination"]
  node_resource_matching["Resource matching<br/>[store.py]"]
end

node_volunteers(("Volunteer phones"))
node_coordinator(("Coordinator"))

node_volunteers -->|"submits reports"| node_hub
node_coordinator -->|"reviews cases"| node_dashboard
node_dashboard -->|"calls"| node_api_client
node_api_client -->|"polls and updates"| node_hub
node_hub -->|"routes requests"| node_report_routes
node_hub -->|"routes requests"| node_admin_routes
node_hub -->|"routes requests"| node_resource_routes
node_hub -->|"routes requests"| node_match_routes
node_hub -->|"routes requests"| node_location_routes
node_hub -->|"starts worker"| node_worker
node_report_routes -->|"stores and queries"| node_store
node_admin_routes -->|"reads and saves"| node_store
node_admin_routes -->|"tests connection"| node_ollama
node_admin_routes -->|"updates settings"| node_runtime
node_worker -->|"claims and saves reports"| node_store
node_worker -->|"runs triage"| node_triage_logic
node_worker -->|"uses on failure"| node_fallback
node_worker -->|"checks availability"| node_ollama
node_triage_logic -->|"requests model output"| node_ollama
node_ollama -->|"reads connection settings"| node_runtime
node_ollama -->|"sends HTTP requests"| node_ai_server
node_worker -->|"updates AI status"| node_runtime
node_store -->|"reads and writes"| node_mongo
node_resource_routes -->|"stores and lists resources"| node_store
node_match_routes -->|"runs and lists matches"| node_store
node_match_routes -->|"requests matching"| node_resource_matching
node_resource_matching -->|"reads resources and reports"| node_mongo
node_location_routes -->|"returns location data"| node_contract
node_report_routes -->|"validates API data"| node_contract
node_dashboard -->|"configures AI server"| node_admin_routes
node_dashboard -->|"requests matching"| node_match_routes

click node_dashboard "https://github.com/aryaa-7/relief-link/blob/master/dashboard/src/App.jsx"
click node_api_client "https://github.com/aryaa-7/relief-link/blob/master/dashboard/src/api.js"
click node_hub "https://github.com/aryaa-7/relief-link/blob/master/app/main.py"
click node_report_routes "https://github.com/aryaa-7/relief-link/blob/master/app/routes/reports.py"
click node_admin_routes "https://github.com/aryaa-7/relief-link/blob/master/app/routes/admin.py"
click node_resource_routes "https://github.com/aryaa-7/relief-link/blob/master/app/routes/resources.py"
click node_match_routes "https://github.com/aryaa-7/relief-link/blob/master/app/routes/matches.py"
click node_location_routes "https://github.com/aryaa-7/relief-link/blob/master/app/routes/locations.py"
click node_contract "https://github.com/aryaa-7/relief-link/blob/master/app/models.py"
click node_worker "https://github.com/aryaa-7/relief-link/blob/master/app/worker.py"
click node_triage_logic "https://github.com/aryaa-7/relief-link/blob/master/app/ai/triage.py"
click node_ollama "https://github.com/aryaa-7/relief-link/blob/master/app/ai/ollama_client.py"
click node_fallback "https://github.com/aryaa-7/relief-link/blob/master/app/ai/fallback.py"
click node_runtime "https://github.com/aryaa-7/relief-link/blob/master/app/runtime.py"
click node_store "https://github.com/aryaa-7/relief-link/blob/master/app/store.py"
click node_resource_matching "https://github.com/aryaa-7/relief-link/blob/master/app/store.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_dashboard,node_api_client toneBlue
class node_hub,node_report_routes,node_admin_routes,node_resource_routes,node_match_routes,node_location_routes,node_contract toneAmber
class node_worker,node_triage_logic,node_ollama,node_fallback,node_runtime,node_ai_server toneMint
class node_store,node_mongo toneRose
class node_resource_matching,node_volunteers,node_coordinator toneIndigo
```

## Components

### Clients

- [Coordinator dashboard](https://github.com/aryaa-7/relief-link/blob/master/dashboard/src/App.jsx): `dashboard/src/App.jsx`
- [Dashboard API client](https://github.com/aryaa-7/relief-link/blob/master/dashboard/src/api.js): `dashboard/src/api.js`

### Hub API

- [FastAPI hub](https://github.com/aryaa-7/relief-link/blob/master/app/main.py): `app/main.py`
- [Report endpoints](https://github.com/aryaa-7/relief-link/blob/master/app/routes/reports.py): `app/routes/reports.py`
- [Admin endpoints](https://github.com/aryaa-7/relief-link/blob/master/app/routes/admin.py): `app/routes/admin.py`
- [Resource endpoints](https://github.com/aryaa-7/relief-link/blob/master/app/routes/resources.py): `app/routes/resources.py`
- [Matching endpoints](https://github.com/aryaa-7/relief-link/blob/master/app/routes/matches.py): `app/routes/matches.py`
- [Location endpoints](https://github.com/aryaa-7/relief-link/blob/master/app/routes/locations.py): `app/routes/locations.py`
- [API models](https://github.com/aryaa-7/relief-link/blob/master/app/models.py): `app/models.py`

### AI Triage

- [Background AI worker](https://github.com/aryaa-7/relief-link/blob/master/app/worker.py): `app/worker.py`
- [AI triage and validation](https://github.com/aryaa-7/relief-link/blob/master/app/ai/triage.py): `app/ai/triage.py`
- [Ollama client](https://github.com/aryaa-7/relief-link/blob/master/app/ai/ollama_client.py): `app/ai/ollama_client.py`
- [Rule-based fallback](https://github.com/aryaa-7/relief-link/blob/master/app/ai/fallback.py): `app/ai/fallback.py`
- [AI runtime status](https://github.com/aryaa-7/relief-link/blob/master/app/runtime.py): `app/runtime.py`
- **Ollama AI server**

### Relief Data

- [MongoDB store operations](https://github.com/aryaa-7/relief-link/blob/master/app/store.py): `app/store.py`
- **MongoDB**

### Coordination

- [Resource matching](https://github.com/aryaa-7/relief-link/blob/master/app/store.py): `app/store.py`

### Other components

- **Volunteer phones**
- **Coordinator**

## Connections

- Volunteer phones → FastAPI hub: submits reports
- Coordinator → Coordinator dashboard: reviews cases
- Coordinator dashboard → Dashboard API client: calls (evidence: `dashboard/src/App.jsx`)
- Dashboard API client → FastAPI hub: polls and updates
- FastAPI hub → Report endpoints: routes requests (evidence: `app/main.py`)
- FastAPI hub → Admin endpoints: routes requests (evidence: `app/main.py`)
- FastAPI hub → Resource endpoints: routes requests (evidence: `app/main.py`)
- FastAPI hub → Matching endpoints: routes requests (evidence: `app/main.py`)
- FastAPI hub → Location endpoints: routes requests (evidence: `app/main.py`)
- FastAPI hub → Background AI worker: starts worker (evidence: `app/main.py`)
- Report endpoints → MongoDB store operations: stores and queries (evidence: `app/routes/reports.py`)
- Admin endpoints → MongoDB store operations: reads and saves (evidence: `app/routes/admin.py`)
- Admin endpoints → Ollama client: tests connection (evidence: `app/routes/admin.py`)
- Admin endpoints → AI runtime status: updates settings (evidence: `app/routes/admin.py`)
- Background AI worker → MongoDB store operations: claims and saves reports (evidence: `app/worker.py`)
- Background AI worker → AI triage and validation: runs triage (evidence: `app/worker.py`)
- Background AI worker → Rule-based fallback: uses on failure (evidence: `app/worker.py`)
- Background AI worker → Ollama client: checks availability (evidence: `app/worker.py`)
- AI triage and validation → Ollama client: requests model output (evidence: `app/ai/triage.py`)
- Ollama client → AI runtime status: reads connection settings (evidence: `app/ai/ollama_client.py`)
- Ollama client → Ollama AI server: sends HTTP requests (evidence: `app/ai/ollama_client.py`)
- Background AI worker → AI runtime status: updates AI status (evidence: `app/worker.py`)
- MongoDB store operations → MongoDB: reads and writes (evidence: `app/store.py`)
- Resource endpoints → MongoDB store operations: stores and lists resources (evidence: `app/routes/resources.py`)
- Matching endpoints → MongoDB store operations: runs and lists matches (evidence: `app/routes/matches.py`)
- Matching endpoints → Resource matching: requests matching (evidence: `app/routes/matches.py`)
- Resource matching → MongoDB: reads resources and reports (evidence: `app/store.py`)
- Location endpoints → API models: returns location data (evidence: `app/routes/locations.py`)
- Report endpoints → API models: validates API data (evidence: `app/routes/reports.py`)
- Coordinator dashboard → Admin endpoints: configures AI server (evidence: `dashboard/src/App.jsx`)
- Coordinator dashboard → Matching endpoints: requests matching (evidence: `dashboard/src/App.jsx`)
