When Disasters Strike, Cell Towers Fall First — So I Built a Mesh Network for Coastal Communities

Published: (March 2, 2026 at 02:21 AM EST)
5 min read
Source: Dev.to

Source: Dev.to

Ocean Sentinels is an Android‑first platform that lets coastal communities report hazards, coordinate rescues, and stay connected even when cellular or Wi‑Fi networks are down. The core idea is to turn ordinary Android phones into a disaster‑proof relay network using Bluetooth Low Energy (BLE). A report created offline hops phone‑to‑phone (≈ 400 m per hop) until any device in the chain reaches the internet and uploads the data to the server.

How It Works

[ Phone A ] ---BLE 400 m---> [ Phone B ] ---BLE 400 m---> [ Phone C : Has Internet ]
No signal                     No signal                     Uploads to server ✓
  • Report hazards – GPS + photo (high waves, flooding, lost boats, etc.)
  • BLE mesh relay – offline propagation tested up to ~400 m per hop
  • Live map – real‑time incident markers (Mapbox)
  • Role‑based access – Citizens, Rescue Teams, Authorities, Admins
  • Push notifications – Firebase, works even when the app is closed
  • Web dashboard – for authorities (requires internet)

Overview

Ocean Sentinels provides a unified, full‑stack safety platform for coastal communities worldwide. It supports four user roles, each with a dedicated console and workflow:

RoleCapabilities
CitizenSubmit incident reports, view live map
Rescue TeamReceive push alerts, verify reports, coordinate response
AuthorityDashboard analytics, manage users, oversee incidents
AdminFull system configuration and user management

Key technical highlights

  • Android app – Kotlin + Jetpack Compose, Hilt DI, Room for offline storage, foreground BLE service.
  • BLE mesh layer – time‑based expiry (72 h) instead of hop‑count TTL, works with Android 6+ MAC‑randomization.
  • Backend – FastAPI + PostgreSQL, role‑based access control, WebSocket live updates.
  • Push – Firebase Cloud Messaging for instant alerts.

Architecture

+-------------------+        +-------------------+        +-------------------+
|   Android App     |  |   BLE Mesh Layer  |  |   Internet (API) |
+-------------------+        +-------------------+        +-------------------+
        |                               |
        v                               v
+-------------------+        +-------------------+
|   Local Room DB   |        |   Firebase Cloud  |
+-------------------+        +-------------------+
  • Device ↔︎ Mesh – BLE advertisements carry encrypted payloads; each node stores pending reports in Room.
  • Device ↔︎ Server – When any node regains connectivity, it batches stored reports and sends them via the FastAPI endpoint.
  • Server ↔︎ Dashboard – WebSocket pushes new incidents to the web UI; REST API serves historical data.

Project Structure

/android-app
    /src/main/kotlin/com/oceansentinels
        - ui/                # Compose screens
        - ble/               # Mesh service
        - di/                # Hilt modules
        - data/              # Room + repository
/backend
    /app
        - routers/          # FastAPI routers
        - models/           # SQLAlchemy models
        - services/         # Business logic
/web-dashboard
    /src
        - components/       # React/Vue components
        - store/            # State management

Backend API

  • POST /reports/ – Accepts JSON with GPS, photo URL, and optional metadata.
  • GET /reports/ – Returns paginated list of recent incidents (filterable by region, severity).
  • WebSocket /ws/updates – Streams new incident events to connected dashboards.

Authentication is JWT‑based; role claims determine access to admin endpoints.

Frontend Web App

  • Built with React + TypeScript.
  • Mapbox GL JS renders the live incident map.
  • Role‑specific panels (verification, analytics, user management).
  • Real‑time updates via the WebSocket endpoint.

Android App

  • Kotlin + Jetpack Compose UI.
  • BLE Mesh Service runs as a foreground service to survive background restrictions.
  • Room stores pending reports; a WorkManager job syncs them when connectivity is restored.
  • Firebase Messaging delivers push alerts even if the app is closed.

BLE Mesh Network

  • Range: ~400 m per hop in open areas (tested with three phones).
  • Message Lifetime: 72 h time‑based expiry, ensuring delivery across long chains.
  • Identification: Uses generated UUIDs instead of MAC addresses (Android 6+ randomizes MACs).

Real‑World Test

Three phones placed ~400 m apart successfully relayed a hazard report from the offline end to a device with internet, which then uploaded the data to the server.

Getting Started

Prerequisites

  • Android Studio Flamingo (or newer)
  • Python 3.10+ with pip
  • PostgreSQL 13+

Android

git clone https://github.com/yourorg/ocean-sentinels.git
cd ocean-sentinels/android-app
./gradlew assembleDebug

Install the generated APK on a device and grant location & Bluetooth permissions.

Backend

cd ocean-sentinels/backend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
alembic upgrade head          # apply migrations
uvicorn app.main:app --reload

Web Dashboard

cd ocean-sentinels/web-dashboard
npm install
npm run dev

Open http://localhost:3000 in a browser.

Deployment

  • Backend – Dockerize the FastAPI service; use PostgreSQL on a managed cloud instance.
  • Web – Serve the static build via Nginx or a CDN.
  • Android – Distribute via Google Play (internal testing) or side‑load APKs for target communities.

Configuration

SettingDescriptionDefault
BLE_MAX_HOPSMaximum hops before dropping a message50
MESSAGE_TTL_HOURSTime‑based expiry for pending reports72
MAPBOX_TOKENMapbox access token for the live map""
FIREBASE_SERVER_KEYServer key for push notifications""
DATABASE_URLPostgreSQL connection stringpostgresql://user:pass@localhost/db

All values can be overridden with environment variables.

API Reference

  • AuthenticationPOST /auth/login returns JWT.
  • Reports – see Backend API section above.
  • Users – admin endpoints for CRUD operations (/users/).

Full OpenAPI spec is available at http:///docs.

License

This project is licensed under the MIT License. See LICENSE for details.

Test Credentials

RoleEmailPassword
Citizensihcitizen@vi.comSIH@2025
Rescuesihrescue@vi.comOcean@123
AdminOceanAdmin1admin

These accounts work on both the Android app and the web dashboard.

0 views
Back to Blog

Related posts

Read more »

Google Gemini Writing Challenge

What I Built - Where Gemini fit in - Used Gemini’s multimodal capabilities to let users upload screenshots of notes, diagrams, or code snippets. - Gemini gener...