HelpHub is a disaster-resilient, offline-first communication system built in Java. It operates entirely on a local Wi-Fi hotspot or LAN, without Internet dependency, enabling survivors and rescue workers to send and receive messages when conventional networks are down.
- Core Principles
- System Architecture
- Communication Flow & Protocols
- Persistence & Security Model
- Project Structure
- Build & Setup (Developers)
- Running the System (Operators & End Users)
- Key Components (Code Tour)
- Credits
-
Offline-First: Works fully without Internet; all communication is LAN-based.
-
Lightweight & Dependency-Free: Built on standard Java (Sockets, Threads, JDBC) with minimal libs (Jetty, SLF4J). No heavy frameworks like Spring.
-
Resilience > Consistency: At-least-once delivery with guaranteed persistence, even if the server crashes.
-
Multi-Platform: Two client types:
- Secure CLI (Java, TLS) for responders
- Web client (browser) for survivors
-
Security-Focused: TLS-encrypted transport for CLI clients; threat model assumes passive eavesdropping protection.
+--------------------------------------------+
| HelpHub Relay Server (Java) |
| |
| +--------------------------------------+ |
| | Core Logic (Message Router) | |
| +--------------------------------------+ |
| | | |
+----------------------------> | Port 5000 | Port 8080 | Port 5001
| (TCP/TLS) | (Secure TCP) | (HTTP & WS) | (Plain TCP)
| | | |
| | ClientHandler | WebSocketHandler | AdminConnectionHandler
| +--------------------+-------------------+--------------------+
| | | | |
| +--------------------+-------------------+ |
| | |
| +-------------v-------------+ |
| | Persistence (SQLite DB) | |
| +-----------------------------+ |
| |
+-----------------+ +-----------------+ +-----------------+ |
| CLI Client | | CLI Client | | Web Client | <---------+
| (Laptop, Java) | | (Laptop, Java) | | (Phone Browser) |
+-----------------+ +-----------------+ +-----------------+
+---------------------------------------+
| JavaFX Dashboard |
| (Coordinator) |
+---------------------------------------+
- CLI (TCP/TLS): First message = plain-text client ID. If taken, server rejects.
- Web Client (WebSocket): First JSON message =
STATUSwith ID. If taken, server rejects.
All messages pass through RelayServer.routeMessageToAll():
-
Persist to SQLite (
PENDING) -
Route depending on type:
- DIRECT: Send to recipient if connected (TCP/WebSocket). Otherwise kept
PENDING. - BROADCAST / SOS: Sent to all clients except sender.
- DIRECT: Send to recipient if connected (TCP/WebSocket). Otherwise kept
- Store-and-Forward: All messages stored before routing.
- ACK: Clients confirm receipt → DB updated to
DELIVERED. - Replay on Connect: Pending messages replayed in priority order.
- Dashboard sends password
- Dashboard sends command (e.g.,
GET_DATA,ADMIN_KICK alpha) - Server replies with confirmation / JSON blob
messages: Stores full message objects with status + priorityclients: Tracks known clients + last seenschema_version: Schema migrations
- Threat Model: Protects against passive Wi-Fi sniffing
- CLI Clients: TLS v1.3 over
SSLSocket - Keystore: Self-signed cert (
helphub.keystore) used by both server + CLI clients - Admin: Password-authenticated, plain TCP
- Limitations: Web clients use
ws://(unencrypted); malicious authenticated clients not prevented
src/main/java/com/helphub/
├── common/ # Shared models & utilities
├── client/ # Command-line client
├── server/ # Relay server + WebSocket support
├── dashboard/ # JavaFX monitoring dashboard
├── security/ # TLS keystore generator
- resources/webapp/ → Web client (HTML/JS)
- test/ → JUnit tests
- Java 17+
- Apache Maven
mvn clean packageProduces executable JAR → target/helphub-0.1.0.jar
# PowerShell
mvn exec:java "-Dexec.mainClass=com.helphub.security.KeyUtil"
# Linux/macOS
mvn exec:java -Dexec.mainClass="com.helphub.security.KeyUtil"Generates helphub.keystore for server + CLI clients.
# Linux/macOS
export KEYSTORE_PASSWORD="HelpHubPassword"
java -cp target/helphub-0.1.0.jar com.helphub.server.RelayServer
# PowerShell
$env:KEYSTORE_PASSWORD="HelpHubPassword"
java -cp target/helphub-0.1.0.jar com.helphub.server.RelayServerServer prints banner with helphub.local and fallback IP.
- Connect phone to same Wi-Fi
- Open browser →
http://helphub.local:8080(or fallback IP) - If the easy address doesn't work, use the fallback IP address that the coordinator announced from the server's screen.
- The chat interface will load, assign a memorable name (e.g., Brave-Lion), and be ready to use.
Copy these files to client machine:
target/helphub-0.1.0.jarhelphub.keystore
Run:
java -cp helphub-0.1.0.jar com.helphub.client.Client --id alpha --server 192.168.43.101# Set admin password(On linux/macOS)
export ADMIN_PASSWORD="YourSecretAdminPassword"
# PowerShell(On Windows)
$env:ADMIN_PASSWORD="YourSecretAdminPassword"
# Start dashboard
mvn javafx:run "-Dadmin.password=YourSecretAdminPassword"RelayServer.java→ main server & routing logicDb.java→ SQLite persistence + migrationsWebSocketHandler.java→ web client managementClient.java→ CLI client entrypointConnectionManager.java→ CLI connection lifecycleKeyUtil.java→ TLS keystore generator