# client2server > **Bi-directional event forwarder + Apple-style dashboard for OpenWrt router fleets** [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) Lightweight OpenWrt event forwarder with a real-time web dashboard. Routers stream DHCP, WiFi, and WAN events over WebSocket; the Go server fans them out to Redpanda and persists them to SQLite; a React/TypeScript SPA gives you live visibility and command control from any browser. ## Overview ``` ┌────────────────────────────────────────────────────────────────┐ │ client2server Architecture │ ├────────────────────────────────────────────────────────────────┤ │ │ │ OpenWrt Routers │ │ │ WebSocket :3843 + Hotplug (curl) │ │ ▼ │ │ ┌──────────────┐ │ │ │ Caddy LB │ ────────────────┐ │ │ │ :80/443 UI │ :3843 API/WS │ │ │ └──────┬───────┘ └──────┬────────┘ │ │ │ │ │ │ ▼ ▼ │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ Dashboard │ │ server1 │ │ server2 │ │ │ │ (React) │ │ (Go) │ │ (Go) │ │ │ │ /login │ │ SQLite │ │ SQLite │ │ │ │ /routers │ │ JWT │ │ JWT │ │ │ │ /events │ │ SSE │ │ SSE │ │ │ │ /commands │ │ WebSocket │ │ WebSocket │ │ │ │ /alerts │ └──────┬──────┘ └──────┬──────┘ │ │ └─────────────┘ │ │ │ │ └────────┬─────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────┐ │ │ │ Redpanda │ Kafka protocol │ │ │ :9092 │ Persisted │ │ └─────────────────┘ │ │ │ └────────────────────────────────────────────────────────────────┘ ``` ## Features ### Server (Go) - ✅ **WebSocket** connection with auto-reconnect from routers - ✅ **HTTP POST** fallback for hotplug scripts - ✅ **Redpanda** (Kafka) event fan-out for downstream consumers - ✅ **SQLite** persistence (events, commands, alerts, users) - ✅ **JWT auth** with role-based access (system_admin / project_admin / user) - ✅ **Server-Sent Events** for real-time dashboard feed - ✅ **Time-series metrics** (1-min buckets, 24h retention) - ✅ **Alerts** for offline routers (auto-clear on reconnect) - ✅ **Command queue** for offline routers (auto-flush on reconnect) - ✅ **Idempotency** (5-min TTL on command IDs) - ✅ **Load balanced** behind Caddy (2× Go servers, health checks) ### Router client (Lua) - ✅ **Hotplug-driven** WiFi connect/disconnect + DHCP lease events (instant, no polling) - ✅ **luv-based** async state-diff for WAN link, DHCP renew, IP changes (≤1s latency) - ✅ **UCI-configurable** server URL, token, check intervals - ✅ **Event buffer** for store-and-forward while offline - ✅ **Bidirectional** command execution (uci_set, shell, reboot, wifi_restart, status) ### Dashboard (React) - ✅ **Apple-style** dark theme (frosted glass surfaces, gradient hero, tabular stat numbers) - ✅ **Live event feed** via Server-Sent Events - ✅ **Real-time charts** of events and commands over time - ✅ **Router list** with online/offline status and queued command count - ✅ **Command console** with target router picker and one-click reboot/wifi_restart/status - ✅ **Alerts inbox** with one-click acknowledgement - ✅ **Event history** with router-id and event-type filters ## Quick Start ### Option 1: Docker Compose (Recommended) ```bash # Clone and run git clone https://git3.techno-world.net/lrosales/client2server.git cd client2server # Set secrets (use any 32+ byte strings) cat > .env <