Skip to content

OpenAlert: Nostr & Multi-Protocol Alerting Bridge

Development of OpenAlert is supported by a grant from the Human Rights Foundation (HRF) Bitcoin Development Fund (View the Announcement).

OpenAlert is a decentralized alerting gateway designed to route critical system events across diverse transport layers. Originally conceived as a module for the py-phone-caller ecosystem, OpenAlert is architected as a standalone component that operates independently and integrates universally via standard alerting protocols.


1. Core Architecture

OpenAlert operates as a multi-protocol gateway, abstracting the transport layer of notifications to allow messages to flow fluidly between traditional IT infrastructure APIs and decentralized edge networks.

  • Universal Downstream Compatibility: OpenAlert formats its outbound digital payloads using the industry-standard Prometheus Alertmanager JSON schema. This enables it to trigger py-phone-caller (which natively ingests Alertmanager webhooks) or seamlessly integrate with any other enterprise alerting and incident management system (e.g., Grafana, PagerDuty, or custom internal dashboards).
  • Standalone Capable: OpenAlert's core daemon (openalertd, implemented in native Rust in src/openalert) runs entirely on its own as a protocol translator—bridging local monitoring stacks to global networks—without requiring local telephony hardware.

2. Supported Protocols & Data Flow

OpenAlert is fundamentally bidirectional, acting as both a listener and a broadcaster across primary decentralized and physical transport layers:

REST, Nostr, and Alertmanager Interfaces

  • Inbound (Receive): The gateway listens for incoming JSON payloads via standard REST webhooks (compatible with existing IT watchdogs). Simultaneously, it monitors the Nostr network via persistent WebSocket connections to a configured relay pool.
    • Ingress Authentication ([rest.auth]): Inbound alert endpoints (/api/v1/alert, /webhook/prometheus, status, and management APIs) support HTTP Basic (username + SHA-256 hashed password) or Bearer token (token_hash) authentication. Credentials are verified using timing-safe constant-time comparisons (subtle::ConstantTimeEq) and are stored exclusively as hashes generated via openalertd hash-password.
  • Outbound (Send): Upon processing an incoming decentralized event (from Nostr, BitChat, or the /sos Emergency Portal), the system standardizes the payload into a Prometheus Alertmanager webhook and POSTs it to configured local or remote py-phone-caller endpoints.
    • Per-Endpoint Webhook Authentication ([py_phone_caller.webhooks.auth]): Each webhook instance supports dedicated HTTP Basic (username + password) or Bearer token (token) authentication. Passwords and tokens support ${ENV_VAR} expansion syntax to prevent storing cleartext credentials in configuration files.

Emergency SOS Web Portal (/sos) & Off-Grid Wi-Fi Captive Portal

For civilians, bystanders, or field personnel who do not have BitChat or 0xChat installed on their mobile devices, OpenAlert provides a dedicated, simplified Emergency SOS Web Portal:

  • Configurable SOS Endpoint ([sos]): Served by default at /sos (configurable via sos.path). Provides a mobile-first, high-contrast emergency dispatch form (Category: SOS, MEDICAL, FIRE, SECURITY, INFRASTRUCTURE, Sender/Location, and Emergency Message) completely isolated from the administrative NOC dashboard (/).
  • Offline 4-Digit SVG Visual CAPTCHA: Generates dynamic, distorted 4-digit SVG challenges in-memory signed with an ephemeral HMAC-SHA256 key and one-time nonce verification (GET /api/v1/sos/challenge → POST /api/v1/sos/trigger), preventing automated bot abuse or radio flooding completely offline without external internet dependencies.
  • One-Tap Browser GPS Geolocation (gps_enabled = true): Optional mobile geolocation button appending GPS:lat,lon (±acc_m) to the SOS alert summary.
  • ⚡ NIP-57 Lightning Zap Alert Adapter ([sos] zap_enabled & [nostr.zaps]): Optional collapsible section on /sos (POST /api/v1/sos/zap-invoice & GET /api/v1/sos/zap-status/{id}) that constructs a signed Kind 9734 Zap Request, resolves the node's lud16 Lightning Address, renders an inline SVG BOLT-11 QR code + lightning: wallet deep-link, and verifies the resulting Kind 9735 Zap Receipt via a 6-stage cryptographic pipeline with tiered satoshi severity escalation (min_sats_warning = 21, min_sats_critical = 1000, min_sats_emergency = 10000) and strict Nostr/0xChat-only egress isolation.
  • Configurable Authentication & Rate-Limiting ([sos.auth]): Open access by default (protected by the offline SVG CAPTCHA and cooldown_seconds rate-limiting), with optional HTTP Basic Auth (username + SHA-256 password_hash) configurable in openalertd.toml.
  • Turnkey Linux Wi-Fi Access Point & Port 80 Isolation (packaging/wifi-ap/): Includes an optional, standard Linux OS configuration bundle (hostapd + dnsmasq + nginx-light) for embedded ARM SBCs (such as Orange Pi Zero 3 and Raspberry Pi). Broadcasts the OpenAlert-SOS Wi-Fi network (10.42.0.1/24), intercepts iOS/Android/Windows captive portal probes on Port 80, and automatically pops up the /sos emergency form on any smartphone that joins the Wi-Fi hotspot—even when the node has zero Ethernet or internet connectivity.

Standardized Nostr Alert Events (NIP-ALERT.md)

OpenAlert defines a formal Nostr specification (NIP-ALERT.md) for addressable parameterized replaceable alert events (Kind 30000):

  • Standardized Tag Schema: Mandatory d (<alert_id>), severity (warning, critical, emergency, info), source (rest, prometheus, nostr, bitchat, peering, sms), expiration (NIP-40 Unix timestamp), and t (alert, openalert), plus optional sender, node, and enc (xchacha20poly1305-v1) tags.
  • Dual Privacy Modes: Cleartext mode ([nostr.privacy] mode = "public") for public community advisories, and Authenticated AEAD Group-Encrypted mode (mode = "encrypted", XChaCha20-Poly1305 with 24-byte random nonce and 256-bit pre-shared key) so untrusted relays cannot inspect alert contents or originating node metadata.

0xChat & Embedded Nostr Tactical Micro-Relay

To provide secure, human-in-the-loop mobile alerting and Command & Control (C2) without cloud dependencies:

  • Embedded Tactical Micro-Relay ([nostr.relay_server]): Zero-external-dependency Nostr WebSocket server running directly inside openalertd on port 8088 (NIP-01, NIP-11 discovery, NIP-20 acknowledgments, NIP-33 #d filtering, NIP-40 expiration, NIP-57 Zap mirroring, SQLite event indexing).
  • NIP-17 / NIP-59 / NIP-44 Onion Encryption: Dual-mode DM engine supporting both legacy NIP-04 Kind 4 and modern three-tier Gift Wraps (Kind 1059 Wrap → Kind 13 Seal → Kind 14 Rumor) with ChaCha20-Poly1305.
  • Interactive Tactical C2: Operators interact directly from 0xChat using status, ping, mesh <msg>, sms <num> <msg>, ack, or help.
  • Thread-Aware Reply ACK: Tapping "Reply" on an alert in 0xChat and sending ack or ok automatically follows the NIP-10 #e event tag to mark the alert resolved in SQLite.
  • Dual SSL / TLS Strategy (Proxy Offloading & Native TLS): Production deployments delegate WSS termination to edge reverse proxies (Caddy, Nginx). For air-gapped field kits, openalertd integrates battle-ready native TLS ([nostr.relay_server.tls]) using tokio-rustls for direct wss:// encrypted sockets without third-party dependencies.
  • NIP-57 Lightning Zap Receipt Verifier ([nostr.zaps]): 6-stage cryptographic verification of Kind 9735 Zap Receipts (Kind 9735 BIP-340 Schnorr signature + provider allowlist, inner Kind 9734 Schnorr signature, recipient #p match, BOLT-11 Bech32 checksum + description_hash binding, and tiered satoshi anti-spam thresholds). Verified Zaps are mirrored to the Embedded Nostr Relay (:8088) and dispatched to 0xChat subscribers while strictly isolated from telephony/SMS/BLE/LoRa egress.

BitChat Bluetooth LE Mesh Implementation

To guarantee event delivery when standard internet routing (TCP/IP) fails, OpenAlert natively implements the BitChat protocol.

  • Offline-First Ad-Hoc Mesh: Utilizes Bluetooth Low Energy (BLE) peripheral GATT services via Linux BlueZ D-Bus, bypassing ISPs, cellular networks, and centralized servers.
  • Noise XX End-to-End Encryption: Direct private messages to openalertd are secured via the Noise_XX_25519_ChaChaPoly_SHA256 pattern, providing mutual authentication, identity hiding, and forward secrecy.
  • 1-on-1 Alert Ingress & Public Escalation:
    • Emergency alerts sent via 1-on-1 encrypted private chat to openalertd are decrypted and acknowledged privately, preserving the exact user message payload end-to-end across LoRa, SMS, and voice synthesis.
    • The daemon immediately escalates the alert to the public BitChat mesh (addressed to [0xFF; 8]), publishes it across Nostr relays, and dispatches it to py-phone-caller's Prometheus webhook for automated telephony dispatch.
    • Public mesh broadcasts are filtered to prevent recursive alerting loops.

Heterogeneous Peering & Multi-Hop Distance-Vector Mesh

When backhauls fail or are unavailable, OpenAlert operates an autonomous peering grid:

  • Heterogeneous Physical Transports: Supports LoRa serial transceivers (/dev/ttyACM*, /dev/ttyUSB* with SLIP framing and ETSI EN 300 220 duty-cycle pacing), local Ethernet/LAN, and encrypted WireGuard VPN tunnels.
  • Dynamic Distance-Vector Routing: Computes shortest path metrics with split-horizon loop suppression and hop decrements across multi-node topologies.
  • Self-Healing Circuit Breakers & Flash Spooling: Automatic link state tracking with exponential cooldown backoff and persistent SQLite flash-spool storage to ensure zero packet loss during network partitions.

3. Quickstart & Building openalertd

The production daemon is located in src/openalert:

cd src/openalert

# Build in release or dev mode
cargo build --release

# Run automated tests (unit + integration tests)
cargo test

# Launch openalertd with the default configuration
cargo run -- config/openalertd.toml

# Install as a hardened systemd service (optionally with the Wi-Fi SOS Captive Portal)
sudo ./packaging/install.sh --with-wifi-ap

# Build Multi-Stage Docker Image (native x86_64 / arm64):
docker build -t openalertd:1.1.0 -f Dockerfile .

# Build ARM64 Image via Fast Cross-Compilation (no QEMU rustc slowdown):
docker buildx build --platform linux/arm64 -f Dockerfile.arm64 -t openalertd:1.1.0-arm64 --load .

# Launch Docker Compose stack (from repo root, with optional hardware passthrough):
docker compose -f ../../docker-compose.yml -f ../../docker-compose.hardware.yml up -d

4. Web UI Mission Control & Operator Telemetry

OpenAlert features a zero-dependency, self-contained real-time Web Dashboard served directly by the daemon on /:

  • Day / Night High-Contrast Theme Engine: 1-click tactical toggle between Midnight NOC (dark obsidian glass) and Day Mode (crisp high-contrast slate & titanium white with sunlight-readable typography for mobile field operators).
  • Zero-Dependency Web Audio Emergency Alarms (Muted by Default): Pure HTML5 Web Audio API synthesized acoustic alarms without external sound files. Operators can toggle Sound ON / Muted with 1 click. Generates distinctive synthesized alarms for critical sirens, warnings, and chimes.
  • Active Incident Strobe Banner & 1-Tap Acknowledge (ACK): High-severity critical alarms drop an animated pulsating banner with an instant "Acknowledge & Silence" trigger that suppresses audio and marks the incident resolved.
  • Live Status Hero Panels & Gauges: Real-time daemon health, link states, spool buffer, and a visual LoRa Duty-Cycle Progress Meter tracking against the 1.0% ETSI EN 300 220 airtime ceiling.
  • Live SSE Telemetry: Server-Sent Events streaming daemon diagnostics, topology links, Nostr relay health, and BitChat radar every 2s without external web servers or frameworks.
  • 💻 Interactive Console & Live Log Terminal: Dedicated streaming terminal with real-time log filtering (by text or level: ALL, INFO, WARN, ERROR), auto-scroll locking, 1-click clipboard export, and buffer clearance.
  • 🛠️ Integrated Operational Tools: In-browser Nostr Secp256k1 keypair generator, BIP-340 Bech32 converter & deriver, cellular SMS UCS-2 hex translator, and 256-bit cryptographic keygen.
  • ⚙️ Live Configuration & ACL Management: Web-based editing of Nostr 0xChat operator lists, SMS authorized sender ACLs, and live TOML configuration file with automatic .bak backups and syntax validation.
  • Authentication ([dashboard.auth]): Zero-friction open access by default; configurable HTTP Basic and Bearer authentication backed by timing-safe constant-time comparisons (subtle::ConstantTimeEq) and SHA-256 password hashing.

5. CLI Management & Turnkey Profiles

Operational CLI Commands

The daemon provides operational terminal subcommands:

cd src/openalert

# Validate configuration syntax and directory structure
cargo run -- check-config config/openalertd.toml

# Generate a full Nostr identity keypair (nsec / npub / hex) with ready-to-paste TOML
cargo run -- generate-keypair

# Convert 0xChat mobile npub or nsec into hex (and auto-derive pubkeys)
cargo run -- convert-key npub1uvtjer4wn7y2qpe4clvqd7qz7x483pthpngewqddc03xes39uq3sw9p5u6

# Bi-directionally convert between UTF-8 text and cellular SMS UCS-2 hex
cargo run -- convert-sms "Critical alert ⚠️"

# Generate a secure SHA-256 password hash for dashboard or /sos authentication
cargo run -- hash-password "yourSecretPassword"

# Query live daemon status, peering links, and persistent spool
cargo run -- status
cargo run -- peers
cargo run -- spool

Turnkey Deployment Profiles

Pre-configured, production-ready configuration profiles are located in config/profiles/:

  • config/profiles/edge-sensor.toml: Minimal footprint off-grid sensor (LoRa serial + BitChat BLE + /sos portal; REST on 127.0.0.1:8091).
  • config/profiles/mesh-repeater.toml: Hilltop tower relay bridging RF LoRa clusters to LAN backhaul routers.
  • config/profiles/central-gateway.toml: NOC / Datacenter gateway with protected Web UI, Asterisk telephony egress, Nostr quorum, and WireGuard VPN peering.

6. Multi-Layered Configuration & Cloud-Native 12-Factor Setup

OpenAlert provides a flexible multi-layered configuration engine powered by the Rust config crate and Serde, offering complete feature parity with py-phone-caller's Python Dynaconf ecosystem.

Operators have 4 distinct ways to configure the daemon:

  1. TOML Configuration File: Standard static configuration in config/openalertd.toml.
  2. Turnkey Deployment Profiles: Modular hardware profiles in config/profiles/ (edge-sensor.toml, mesh-repeater.toml, central-gateway.toml).
  3. 12-Factor Environment Variables: Cloud-native overrides via OPENALERT_<SECTION>__<KEY> (e.g. OPENALERT_REST__LISTEN_PORT=8080, OPENALERT_SOS__PATH="/sos", OPENALERT_STORAGE__PATH=":memory:") allowing pure container execution with zero disk files mounted.
  4. Dynamic Web UI & REST API: Live in-process configuration inspection, syntax validation, automated .bak backups, and hot-reloading from the browser.

Tip

For the comprehensive configuration guide, full environment variable mapping table, and Kubernetes / Docker Compose manifests, see the OpenAlert Configuration Guide.