# harkirat-data/sos-mesh-network architecture

> Architecture diagram of the GitHub repository harkirat-data/sos-mesh-network, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harkirat-data/sos-mesh-network
- Repository: https://github.com/harkirat-data/sos-mesh-network

## Overview

SOS Mesh Network is a Flutter Android app for sending emergency messages across nearby phones without cellular service. The principal workflow is a victim preparing an SOS with GPS coordinates, BLE relays forwarding it, and an internet-connected gateway uploading it to Firebase for a rescue dashboard. The README documents beacon discovery, GATT payload transfer, TTL-based flood routing, and deduplication. Source excerpts were not provided, so edges reflect documented relationships; screen-to-service wiring and implementation details remain unverified.

Main entry points: [`lib/services/ble_mesh_service.dart`](https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/services/ble_mesh_service.dart) (BLE mesh service), [`lib/models/sos_message.dart`](https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/models/sos_message.dart) (SOS message), [`lib/screens/sos_screen.dart`](https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/screens/sos_screen.dart) (SOS interface), [`lib/services/firebase_service.dart`](https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/services/firebase_service.dart) (Firebase database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Mobile app"]
  node_home["Home navigation<br/>[home_screen.dart]"]
  node_sos["SOS interface<br/>[sos_screen.dart]"]
  node_settings["Node roles"]
  node_status["Mesh activity<br/>[status_screen.dart]"]
  node_app_entry["App entry<br/>[main.dart]"]
end

subgraph group_mesh["BLE mesh"]
  node_message["SOS message<br/>[sos_message.dart]"]
  node_ble["BLE mesh service"]
  node_beacon["ID beacon"]
  node_gatt["GATT transfer"]
  node_routing["Flood routing"]
end

subgraph group_services["Device services"]
  node_location["GPS location"]
end

subgraph group_rescue["Rescue delivery"]
  node_firebase[("Firebase database")]
  node_dashboard["Rescue dashboard"]
end

node_victim(("Victim"))
node_peers(("Nearby phones"))

node_victim -->|"submits SOS"| node_sos
node_sos -.->|"prepares message"| node_message
node_location -.->|"provides coordinates"| node_message
node_message -->|"sent over BLE"| node_ble
node_ble -->|"advertises ID"| node_beacon
node_beacon -->|"discovers peer"| node_gatt
node_gatt -->|"transfers payload"| node_peers
node_ble -->|"forwards messages"| node_routing
node_routing -->|"relays SOS"| node_peers
node_ble -->|"gateway uploads"| node_firebase
node_firebase -->|"relays SOS"| node_dashboard

click node_home "https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/screens/home_screen.dart"
click node_sos "https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/screens/sos_screen.dart"
click node_settings "https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/screens/settings_screen.dart"
click node_status "https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/screens/status_screen.dart"
click node_message "https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/models/sos_message.dart"
click node_ble "https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/services/ble_mesh_service.dart"
click node_beacon "https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/services/ble_mesh_service.dart"
click node_gatt "https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/services/ble_mesh_service.dart"
click node_routing "https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/services/ble_mesh_service.dart"
click node_location "https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/services/location_service.dart"
click node_firebase "https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/services/firebase_service.dart"
click node_app_entry "https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/main.dart"

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_home,node_sos,node_settings,node_status,node_app_entry toneBlue
class node_message,node_ble,node_beacon,node_gatt,node_routing toneAmber
class node_location toneMint
class node_firebase,node_dashboard toneRose
class node_victim,node_peers toneIndigo
```

## Components

### Mobile app

- [Home navigation](https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/screens/home_screen.dart): `lib/screens/home_screen.dart`
- [SOS interface](https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/screens/sos_screen.dart): `lib/screens/sos_screen.dart`
- [Node roles](https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/screens/settings_screen.dart): `lib/screens/settings_screen.dart`
- [Mesh activity](https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/screens/status_screen.dart): `lib/screens/status_screen.dart`
- [App entry](https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/main.dart): `lib/main.dart`

### BLE mesh

- [SOS message](https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/models/sos_message.dart): `lib/models/sos_message.dart`
- [BLE mesh service](https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/services/ble_mesh_service.dart): `lib/services/ble_mesh_service.dart`
- [ID beacon](https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/services/ble_mesh_service.dart): `lib/services/ble_mesh_service.dart`
- [GATT transfer](https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/services/ble_mesh_service.dart): `lib/services/ble_mesh_service.dart`
- [Flood routing](https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/services/ble_mesh_service.dart): `lib/services/ble_mesh_service.dart`

### Device services

- [GPS location](https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/services/location_service.dart): `lib/services/location_service.dart`

### Rescue delivery

- [Firebase database](https://github.com/harkirat-data/sos-mesh-network/blob/main/lib/services/firebase_service.dart): `lib/services/firebase_service.dart`
- **Rescue dashboard**

### Other components

- **Victim**
- **Nearby phones**

## Connections

- Victim → SOS interface: submits SOS (evidence: `README.md`)
- SOS interface → SOS message: prepares message
- GPS location → SOS message: provides coordinates
- SOS message → BLE mesh service: sent over BLE (evidence: `README.md`)
- BLE mesh service → ID beacon: advertises ID (evidence: `README.md`)
- ID beacon → GATT transfer: discovers peer (evidence: `README.md`)
- GATT transfer → Nearby phones: transfers payload (evidence: `README.md`)
- BLE mesh service → Flood routing: forwards messages (evidence: `README.md`)
- Flood routing → Nearby phones: relays SOS (evidence: `README.md`)
- BLE mesh service → Firebase database: gateway uploads (evidence: `README.md`)
- Firebase database → Rescue dashboard: relays SOS (evidence: `README.md`)
