Act as a Principal Full-Stack Engineer and IoT Systems Architect. You have full root/administrator owner access to this system and are authorized to download, install, and execute any required packages, system dependencies, libraries, or tools needed to build and run this application. ### TASK SUMMARY Build an end-to-end Wi-Fi Signal Motion Detection and Analytics System consisting of: 1. A background Wi-Fi monitoring service. 2. A backend API server with data persistence. 3. A professional, modern web dashboard featuring real-time analytics, signal charts, motion logs, and a interactive room/signal map. --- ### CORE ARCHITECTURE & REQUIREMENTS #### 1. Wi-Fi Monitoring & Signal Capture Engine (Python) - Develop a Python service (`wifi_monitor.py`) that periodically captures ambient Wi-Fi metrics (such as RSSI/signal levels, noise ratio, ping latency, and packet loss rate) between this laptop and the connected router/access point. - Implement cross-platform hardware detection (support Linux/macOS/Windows network CLI interfaces like `nmcli`, `/proc/net/wireless`, `airport`, or `netsh`). - Use an adaptive sliding window anomaly-detection algorithm (e.g., standard deviation / z-score thresholds on signal strength fluctuations and packet variance) to register motion/interference events. - Store continuous metric time-series data and flagged motion events in a local SQLite database (`wifi_analytics.db`). #### 2. REST & WebSocket API Backend (FastAPI / Flask) - Build a Python backend server exposing REST endpoints for historical data and a WebSocket endpoint for real-time live streaming of Wi-Fi metrics and motion events. - Endpoints needed: - `GET /api/current`: Returns live Wi-Fi RSSI, latency, and motion state. - `GET /api/history?range=1h|24h|7d`: Returns aggregated time-series metrics for charts. - `GET /api/events`: Returns a log of all detected motion anomalies. - `WS /ws/live`: Real-time WebSocket feed pushing data every 1 second. #### 3. Professional Frontend Web Dashboard - Create a modern, dark-mode responsive dashboard using clean HTML5, Tailwind CSS/Bootstrap, Chart.js (or ApexCharts), and Leaflet.js (or HTML Canvas). - Key Components: - **Live Indicator Panel:** Displays real-time signal strength (dBm), connection stability, and a prominent "Motion Detected" vs. "Clear" status badge. - **Analytics Charts:** - Line chart tracking RSSI and Latency over time with flagged event markers. - Motion frequency bar chart aggregated by hour/day. - **Interactive Area Map:** - An interactive floorplan / coverage map representation showing the Wi-Fi router node, the laptop node, and an animated Wi-Fi wave heat zone that changes color/intensity (e.g., Green = stable, Red = disturbance detected) when motion occurs in the path. - Allow basic customization/drag placement of router and laptop positions on the grid. - **Event Audit Log:** Datatable of detected events with timestamp, signal deviation percentage, and duration. --- ### EXECUTION STEPS FOR HERMES AGENT 1. **Environment Setup & Dependencies:** - Detect operating system and network interface. - Install all required system tools and Python libraries (e.g., `fastapi`, `uvicorn`, `sqlite3`, `psutil`, `requests`, `websockets`, `pandas`, `numpy`). 2. **Database Initialization:** - Create SQLite tables for `wifi_logs` and `motion_events`. 3. **Backend & Monitor Implementation:** - Write and test the monitoring loop and background worker. - Launch the web backend server. 4. **Frontend Dashboard Assembly:** - Generate static assets (HTML/CSS/JS) and serve them directly from the API backend. 5. **Run & Verify:** - Start all background services and provide me with the local URL (e.g., `http://localhost:8000`) where I can open and use the live dashboard.