# Dangerous Pi - Project Status **Last Updated**: 2026-03-03 ## βœ… Phase 3 Complete - Hardware Testing Passed All MVP features tested on actual hardware: - Raspberry Pi Zero 2 W with Proxmark3 Easy - PiSugar 2 UPS (auto-detected via I2C) - Bluetooth LE advertising working - WiFi AP mode active (192.168.4.1) --- ## πŸ“Š Feature Evaluation Summary (2026-03-03) | Feature | Completion | Backend | Frontend | Notes | |---------|------------|---------|----------|-------| | **HTTPS** | βœ… 100% | βœ… Complete | βœ… Toggle + info | Done 2026-03-03 | | **Authentication** | 40% | βœ… Basic + WS tokens | βœ… Login prompt | WebSocket protected | | **Plugin System** | 85% | βœ… Complete + hooks wired | βœ… Complete | Remote install missing | ### πŸ” Security Gaps (Remaining) 1. **Single User Only**: Basic HTTP auth with hardcoded username, no multi-user support 2. **No Logout**: Active sessions cannot be revoked 3. **No JWT**: Still using Basic Auth for REST endpoints (tokens only for WS) ### βœ… HTTPS (100% Complete - Done 2026-03-03) **Implemented:** - SSL API endpoints fully working (`/api/system/ssl/info`, `/api/system/ssl/regenerate`) - Certificate generation script with EC P-256 keys, 10-year validity (`scripts/generate-ssl-cert.sh`) - nginx HTTPS config with TLS 1.2/1.3, HSTS, modern ciphers (`nginx/dangerous-pi-https.conf`) - Captive portal detection for Android, iOS, Windows, macOS, Firefox, Kindle - Systemd services for auto-generation (`dangerous-pi-ssl-gen.service`) - nginx config switching script (`scripts/configure-nginx.sh`) - Pi-gen integration (stage 05-https-support) - Frontend displays HTTPS status badge in Settings - Subject Alternative Names: 192.168.4.1, dangerous-pi.local, localhost - βœ… Frontend Enable/Disable toggle (`POST /api/system/ssl/toggle`) - βœ… Certificate regeneration button in UI - βœ… SSL info display (expiration, SANs, SHA256 fingerprint) ### πŸ”‘ Authentication (40% Complete) **Implemented:** - Basic HTTP authentication (`app/backend/api/auth.py`) - `AUTH_ENABLED` environment variable toggle (default: false) - Single username/password via env vars - Conditional router protection when enabled - βœ… WebSocket token-based auth (`app/backend/api/token_store.py`) - Done 2026-03-03 - βœ… `POST /api/auth/token` - exchange Basic Auth for WS token (24h TTL) - βœ… `GET /api/auth/status` - public endpoint for auth status check - βœ… WebSocket validates token query param, rejects with close code 4401 - βœ… Frontend LoginPrompt modal (`app/frontend/app/components/LoginPrompt.tsx`) - βœ… WebSocket manager handles auth flow (token fetch, retry, auth_required state) **Missing:** - JWT token-based auth for REST endpoints - Multi-user support - User management - Role-based access control (RBAC) - Logout functionality - Session revocation **Estimated to Complete:** ~2-3 weeks (full system, JWT + multi-user + RBAC) ### πŸ”Œ Plugin System (85% Complete) **Implemented:** - Plugin Manager: 804 lines, full lifecycle (load/enable/disable/unload) - Hook system: `register_hook()` and `trigger_hook()` methods implemented - Header widget system: severity levels (INFO/WARNING/ERROR/SUCCESS), dismissible, actions, expiration - Hardware access layer: GPIO, I2C, SPI, Serial with permission enforcement - 7 API endpoints: discover, list, info, enable, disable, load, unload - Frontend UI: discovery button, plugin listing, enable/disable toggles, permission badges - Hello World example plugin with registered hooks - WebSocket broadcasting capability for plugins (requires `websocket` permission) - βœ… Hook triggers wired in PM3 service (`pm3_command` hook) - Done 2026-03-03 - βœ… Hook triggers wired in Update manager (`update_check` hook) - Done 2026-03-03 **Missing:** - Remote plugin installation (from GitHub releases) - pip dependency management - Permission consent dialog before enabling **Estimated to Complete:** - Remote installation: ~1-2 weeks --- ## βœ… Completed Features ### Backend (Python + FastAPI) **Core Infrastructure:** - βœ… FastAPI application with async support - βœ… SQLite database (sessions, config, command history, crash reports) - βœ… Configuration management via environment variables - βœ… Comprehensive error handling **API Endpoints:** - βœ… Health check (`/api/health`) - βœ… System info (`/api/system/info`) - βœ… PM3 status (`/api/pm3/status`) - βœ… PM3 command execution (`/api/pm3/command`) - βœ… PM3 device management (`/api/pm3/devices/*`) - βœ… Session management (`/api/system/session/*`) - βœ… WebSocket events (`/ws/events`) **Core Components:** - βœ… **PM3 Worker** - Uses built-in `pm3` Python module (SWIG bindings) - βœ… **PM3 Device Manager** - Multi-device support with unique device IDs - βœ… **Session Manager** - Per-device sessions with takeover support - βœ… **WebSocket Manager** - Real-time event broadcasting to all clients - βœ… **Service Container** - Dependency injection for services **WiFi Manager (Complete):** - βœ… Interface detection (USB vs built-in) - βœ… Network scanning with signal strength - βœ… Full mode switching (AP/Client/Dual/Auto/Off) - βœ… Network connection with password support - βœ… Hidden SSID support - βœ… Saved networks management - βœ… Static IP configuration - βœ… DHCP management - βœ… 10 WiFi API endpoints **Update Manager (Complete):** - βœ… GitHub releases API integration - βœ… Automatic periodic update checks - βœ… Version comparison (semantic versioning) - βœ… Update download with progress tracking - βœ… Checksum verification (SHA256) - βœ… Automatic installation with backup - βœ… PM3 client rebuild after updates - βœ… Rollback on installation failure - βœ… 6 Update API endpoints **UPS Manager (Complete):** - βœ… I2C battery monitoring (MAX17040-compatible) - βœ… Battery percentage, voltage, current tracking - βœ… Power source detection (AC/Battery) - βœ… Safe shutdown triggers at configurable thresholds - βœ… Battery status (Charging, Discharging, Full, Critical) - βœ… Event callbacks for battery warnings - βœ… WebSocket and BLE notification integration - βœ… 3 UPS API endpoints - βœ… **Power Management Policy** (NEW - 2025-11-26) - Assumes AC power when UPS not detected (no restrictions) - Battery-level restrictions when on UPS battery - Power restrictions API endpoint for firmware flashing - Safe defaults: all operations allowed without UPS **BLE Manager (Complete - MVP):** - βœ… Bluetooth Low Energy notification support - βœ… Auto-detects BLE capability - βœ… Configurable device name - βœ… Multiple notification types (updates, battery, shutdown, etc.) - βœ… BLE advertising management - βœ… Device connection tracking - βœ… Notification queueing - βœ… 4 BLE API endpoints - 🚧 **Planned Enhancement**: Full web client feature parity via BLE - Command execution via BLE - Status queries via BLE - Guided workflow triggers via BLE - For React Native mobile app integration **Plugin Framework (85% Complete - See Feature Evaluation):** - βœ… Dynamic plugin loading/unloading (804-line plugin manager) - βœ… Plugin lifecycle management (load, enable, disable, unload) - βœ… Hook system: `register_hook()` and `trigger_hook()` fully implemented - βœ… Hook triggers wired in PM3 service and Update manager - βœ… Header widget system with severity levels, actions, expiration - βœ… Hardware access layer: GPIO, I2C, SPI, Serial with permission checks - βœ… JSON-based metadata with permissions and dependencies - βœ… Plugin discovery from directory - βœ… Enable/disable individual plugins - βœ… Example "Hello World" plugin with registered hooks - βœ… 7 Plugin API endpoints (discover, list, info, enable, disable, load, unload) - βœ… Frontend UI with discovery, listing, toggle controls, permission badges - ❌ Remote plugin installation not implemented - ❌ pip dependency management not implemented **Proxmark3 Firmware Enhancements (Complete - 2025-12-02):** - βœ… Two-channel hardware PWM LED brightness control - LED A (Green, PA0/PWM0): 0-100% brightness - LED B (Blue, PA2/PWM2): 0-100% brightness - LED C/D: Basic on/off/toggle - βœ… New `hw led` command with full LED control - βœ… PWM channel reallocation (timing moved PWM0β†’PWM1) - βœ… Backward compatible protocol (CMD_LED_CONTROL 0x011A) - βœ… Multi-device identification via brightness levels - βœ… Zero performance impact on RF operations - βœ… Tested and flashed to Proxmark3 Easy - πŸ“„ Documentation: [LED_PWM_IMPLEMENTATION.md](LED_PWM_IMPLEMENTATION.md) **System Integration (Complete):** - βœ… Systemd service units with security hardening - βœ… Automated install/uninstall scripts - βœ… Environment configuration template - βœ… Hardware access groups (i2c, bluetooth, gpio, dialout) - βœ… Pi-gen stage integration for OS image building - βœ… Port conflict resolution with ttyd-bash - βœ… I2C interface auto-enable for UPS HAT **Testing:** - βœ… Component tests (`test_backend.py`) - βœ… UPS manager test (`test_ups.py`) - βœ… BLE manager test (`test_ble.py`) - βœ… Plugin manager test (`test_plugins.py`) - βœ… All tests passing ### Frontend (Remix.js + React) **Design System:** - βœ… Cyberpunk theme (Dangerous Things aesthetic) - βœ… Dark mode default, light mode available - βœ… Auto theme detection (system preference) - βœ… Lightweight CSS (~15KB) - βœ… System fonts only (zero download) - βœ… Mobile-first responsive design **Pages:** - βœ… **Dashboard** (`/`) - System status (CPU, memory, disk) - PM3 connection status with multi-device support - Quick actions - Real-time WebSocket notifications - βœ… **Commands** (`/commands`) - Command input with history (↑/↓ navigation) - Quick command buttons - Terminal-style output - Session management - βœ… **Settings** (`/settings`) - General settings (auth, HTTPS) - Wi-Fi configuration (full UI with scanning, mode switching) - Update management - Advanced options - System actions (restart, shutdown) - βœ… **Logs** (`/logs`) - Command history table - Success/failure status - Timestamp formatting **Components:** - βœ… Responsive navigation (mobile bottom bar, desktop top) - βœ… Theme toggle button - βœ… Status badges with pulse animation - βœ… Toast notifications - βœ… Loading states - βœ… Form validation - βœ… **DeviceSelector** - Multi-PM3 device selection with LED identification - βœ… **PowerWidget** - Real-time UPS/battery status in header - βœ… **ConnectDialog** - PM3 connection management - βœ… **QRScanner** - HTML5-based QR code scanning - βœ… **LoginPrompt** - Modal login form for WebSocket auth **Hooks:** - βœ… **useWebSocket** - Singleton WebSocket manager with event subscriptions and token auth **Performance:** - βœ… Server-side rendering (SSR) - βœ… Code splitting by route - βœ… Progressive enhancement - βœ… Bundle size < 150KB (target - with room for Victory charts) **Visualization (Planned):** - πŸ“‹ **Victory Charts** - Cross-platform charting library - Mobile-first design with touch gestures - Shared components across Web/Mobile/Desktop - Real-time data visualization - ~50KB bundle impact (within budget via code splitting) - πŸ“‹ **Guided Workflows** - Multi-step wizards for common tasks - ID Transponder - Clone MIFARE Classic 1K - Clone to T5577 - HF/LF/HW Tune with live charts - Sniffing utility ### Documentation - βœ… **claude.md** - AI development guide (updated with Victory) - βœ… **README_DEV.md** - Developer quick start - βœ… **UI_GUIDELINES.md** - Design system and UX principles (mobile-first) - βœ… **GETTING_STARTED.md** - Complete setup guide - βœ… **WIFI_MANAGER.md** - WiFi management guide - βœ… **UPDATE_MANAGER.md** - Update system guide - βœ… **PORT_CONFLICT.md** - Port conflict resolution guide - βœ… **MVP_COMPLETE.md** - MVP completion summary - βœ… **BUILD_GUIDE.md** - Pi-gen image building guide - βœ… **QUICK_BUILD.md** - Quick build reference - βœ… **VISUALIZATION_PLAN.md** - Charting and guided workflows plan - βœ… **systemd/README.md** - Service management documentation - βœ… **pi-gen/stageDTPM3/04-dangerous-pi/README.md** - Build integration docs - βœ… **app/frontend/README.md** - Frontend documentation - βœ… **README.md** - Updated main readme --- ## 🚧 Future Enhancements (Post-MVP) ### High Priority (Next Phase) 1. **Data Visualization & Guided Workflows** 🎯 **IN PLANNING** - Victory charts integration (~50KB bundle) - PM3 output parser layer (text β†’ structured JSON) - Real-time tuning visualizations (HF/LF/HW tune) - Guided workflow framework (multi-step wizards) - Touch-optimized interactive charts - Mobile-first UI components - **Target**: 4-6 weeks implementation - **Dependencies**: Victory, PM3 output parsers 2. **Cross-Platform Apps** 🎯 **PLANNED** - **React Native Mobile App** (iOS/Android) - Shared Victory chart components with web - Full BLE integration for offline operation - Native performance and UX - Share ~90% codebase with web app - **Electron Desktop App** (Windows/Mac/Linux) - Same codebase as web + React Native - Native system integration - Offline-first capabilities - **Target**: Post-visualization implementation 3. **Enhanced BLE Manager** 🎯 **PLANNED** - Full web client feature parity via BLE - Command execution over BLE (for mobile app) - Bidirectional communication (GATT server) - Status queries and responses - Guided workflow triggers - Notification improvements - **Target**: Concurrent with React Native app 4. **Frontend Build Integration** - Serve frontend from backend in production - Build script for combined deployment - Asset optimization - Service worker for offline support 5. **Backup System** - Application directory backup - Optional SD card image backup - Scheduled backups - Restore functionality - Cloud storage plugin (optional) ### Medium Priority 6. **Authentication** (40% Complete - See Feature Evaluation) - βœ… Basic HTTP auth (backend) - βœ… WebSocket token auth with LoginPrompt - ❌ JWT tokens needed for REST - ❌ Multi-user support needed - ❌ RBAC needed 7. **HTTPS Support** βœ… COMPLETE - βœ… Self-signed certificate generation - βœ… Automatic cert creation on first boot - βœ… Frontend toggle and cert info display 8. **Advanced PM3 Features** - Waveform viewer with pan/zoom - Protocol trace analyzer - Antenna tuning dashboard - Command templates - Favorite commands ### Low Priority 6. **Plugin Ecosystem** - Plugin marketplace/appstore - Plugin signing and verification - Plugin dependency resolution - Community plugin repository 7. **Enhanced BLE** - Full GATT server implementation - Bi-directional communication - Mobile app integration 8. **Additional UPS Support** - Temperature monitoring - Battery health reporting --- ## πŸ“Š Project Metrics ### Backend - **Lines of Code**: ~7,000+ - **Files**: 40+ - **API Endpoints**: 54+ (PM3 10+, System 18+, WiFi 10, Updates 6, Plugins 7, Auth 3) - **Managers**: 7 (PM3Device, Session, WiFi, Update, UPS, BLE, Plugin) - **Services**: 4 (PM3, System, WiFi, Update) + ServiceContainer - **Dependencies**: 11 packages - **Test Coverage**: All managers tested ### Frontend - **Lines of Code**: ~2,500+ - **Files**: 13+ - **Pages**: 5 (Dashboard, Commands, Settings, Logs, Updates) - **Components**: 5 (DeviceSelector, PowerWidget, ConnectDialog, QRScanner, LoginPrompt) - **Hooks**: 1 (useWebSocket) - **CSS**: 15KB (uncompressed) - **Bundle Size**: ~120KB (estimated, gzipped) ### System Integration - **Systemd Services**: 1 - **Installation Scripts**: 2 (install, uninstall) - **Port Resolution Scripts**: 1 - **Pi-gen Stages**: 1 (with 3 scripts) ### Documentation - **Guides**: 12 files - **Total Documentation**: ~10,000+ lines - **API Documentation**: Auto-generated (FastAPI) --- ## 🎯 Next Steps ### Immediate 1. βœ… **Power Management Policy** (COMPLETE - 2025-11-26) - Power restrictions API implemented - UPS-aware power management - Safe defaults for systems without UPS - Ready for hardware deployment 2. **Hardware Testing** (NEXT - Blocked until pi-gen build complete) - Test on actual Raspberry Pi Zero 2 W - Test with real UPS HAT (optional hardware) - Test BLE notifications with mobile device - Performance optimization for Pi hardware 3. **Pi-gen Build Testing** (READY) - Run `./build-image.sh quick` to test PM3 client build - Verify Python bindings compilation - Test full image build - Deploy to Pi hardware 4. **Frontend Build Integration** - Create production build script - Serve frontend from backend - Single-server deployment 3. **OS Image Creation** - Build custom image with pi-gen - Test image on Pi Zero 2 W - Verify all services start correctly - Document installation process ### Short Term 1. **Additional Example Plugins** - Create 2-3 more example plugins - Document plugin development - Plugin best practices guide 2. **Frontend Enhancements** - Add UPS status to dashboard - Add BLE status indicator - Add plugin management UI - Update management UI improvements 3. **Testing & QA** - Integration testing on hardware - Load testing - Security review - Documentation review ### Medium Term 1. **Backup System** - Implement backup functionality - Schedule backups - Cloud storage plugins 2. **Advanced Features** - Authentication system - HTTPS support - Advanced PM3 wizards - Command templates ### Long Term 1. **Plugin Ecosystem** - Plugin marketplace/appstore - Community plugins - Plugin repository 2. **Public Release** - Beta testing program - User documentation - Release to community --- ## πŸ—οΈ Architecture ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Browser (User) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ REST API WebSocket Static Assets β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Remix.js Frontend (React) β”‚ β”‚ β”‚ β”‚ β€’ Dashboard β€’ Commands β€’ Settings β€’ Logs β”‚ β”‚ β€’ Cyberpunk Theme β€’ Mobile-First β€’ SSR β”‚ β”‚ β€’ useWebSocket hook β€’ DeviceSelector β€’ PowerWidget β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ Proxy to β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ FastAPI Backend (Python) β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ API Layer β”‚ β”‚ WebSocket β”‚ β”‚ Services β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β€’ Health β”‚ β”‚ β€’ PM3 Status β”‚ β”‚ β€’ PM3Service β”‚ β”‚ β”‚ β”‚ β€’ System β”‚ β”‚ β€’ Devices β”‚ β”‚ β€’ System β”‚ β”‚ β”‚ β”‚ β€’ PM3 β”‚ β”‚ β€’ UPS/Batteryβ”‚ β”‚ β€’ WiFi β”‚ β”‚ β”‚ β”‚ β€’ WiFi β”‚ β”‚ β€’ Updates β”‚ β”‚ β€’ Update β”‚ β”‚ β”‚ β”‚ β€’ Updates β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Managers β”‚ β”‚ Workers β”‚ β”‚ Database β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β€’ PM3Device β”‚ β”‚ β€’ PM3 Worker β”‚ β”‚ SQLite β”‚ β”‚ β”‚ β”‚ β€’ Session β”‚ β”‚ (SWIG) β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β€’ WiFi β”‚ β”‚ β”‚ β”‚ β€’ Sessions β”‚ β”‚ β”‚ β”‚ β€’ Updates β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β€’ Config β”‚ β”‚ β”‚ β”‚ β€’ UPS β”‚ β”‚ β€’ History β”‚ β”‚ β”‚ β”‚ β€’ BLE β”‚ ServiceContainer β”‚ β€’ Crashes β”‚ β”‚ β”‚ β”‚ β€’ Plugin β”‚ (DI) β”‚ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ pm3 Python module (SWIG) β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Proxmark3 Hardware (Multi-device) β”‚ β”‚ /dev/ttyACM0, /dev/ttyACM1, ... β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ## πŸ› οΈ Technology Stack ### Backend - **Language**: Python 3.11+ - **Framework**: FastAPI - **Database**: SQLite (aiosqlite) - **Server**: Uvicorn - **PM3 Integration**: Official Python bindings (SWIG) ### Frontend - **Framework**: Remix v2 (React Router) - **Language**: TypeScript - **Build**: Vite - **Styling**: Vanilla CSS (no framework) - **Transport**: Fetch API + WebSocket ### Infrastructure - **OS**: Raspberry Pi OS (Debian Trixie) - **Hardware**: Raspberry Pi Zero 2 W - **Networking**: RaspAP (existing) - **Services**: Systemd (planned) --- ## πŸ“ File Structure ``` dangerous-pi/ β”œβ”€β”€ app/ β”‚ β”œβ”€β”€ backend/ # FastAPI backend β”‚ β”‚ β”œβ”€β”€ api/ # REST endpoints β”‚ β”‚ β”‚ β”œβ”€β”€ health.py # Health checks β”‚ β”‚ β”‚ β”œβ”€β”€ pm3.py # PM3 commands + devices β”‚ β”‚ β”‚ β”œβ”€β”€ system.py # System + UPS + BLE + CPU β”‚ β”‚ β”‚ β”œβ”€β”€ wifi.py # WiFi management β”‚ β”‚ β”‚ β”œβ”€β”€ updates.py # Update management β”‚ β”‚ β”‚ β”œβ”€β”€ plugins.py # Plugin management β”‚ β”‚ β”‚ β”œβ”€β”€ auth.py # Authentication + token endpoints β”‚ β”‚ β”‚ └── token_store.py # In-memory WS auth tokens β”‚ β”‚ β”œβ”€β”€ websocket/ # WebSocket real-time events β”‚ β”‚ β”‚ β”œβ”€β”€ manager.py # Connection manager β”‚ β”‚ β”‚ β”œβ”€β”€ routes.py # WebSocket endpoint β”‚ β”‚ β”‚ └── notifications.py # Event broadcasting helpers β”‚ β”‚ β”œβ”€β”€ services/ # Business logic layer β”‚ β”‚ β”‚ β”œβ”€β”€ container.py # Dependency injection β”‚ β”‚ β”‚ β”œβ”€β”€ pm3_service.py # PM3 operations β”‚ β”‚ β”‚ β”œβ”€β”€ system_service.py # System operations β”‚ β”‚ β”‚ β”œβ”€β”€ wifi_service.py # WiFi operations β”‚ β”‚ β”‚ └── update_service.py # Update operations β”‚ β”‚ β”œβ”€β”€ workers/ # Background workers β”‚ β”‚ β”‚ └── pm3_worker.py # PM3 command executor (SWIG) β”‚ β”‚ β”œβ”€β”€ managers/ # State management β”‚ β”‚ β”‚ β”œβ”€β”€ pm3_device_manager.py # Multi-device PM3 management β”‚ β”‚ β”‚ β”œβ”€β”€ session_manager.py # Per-device sessions β”‚ β”‚ β”‚ β”œβ”€β”€ wifi_manager.py # WiFi management β”‚ β”‚ β”‚ β”œβ”€β”€ update_manager.py # Update system β”‚ β”‚ β”‚ β”œβ”€β”€ ups_manager.py # UPS monitoring β”‚ β”‚ β”‚ β”œβ”€β”€ ups_drivers/ # UPS driver implementations β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ base.py # Abstract base driver β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ i2c_driver.py # Generic I2C fuel gauge β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ pisugar_driver.py # PiSugar TCP driver β”‚ β”‚ β”‚ β”‚ └── pisugar_i2c_driver.py # PiSugar I2C driver β”‚ β”‚ β”‚ β”œβ”€β”€ ble_manager.py # BLE notifications β”‚ β”‚ β”‚ └── plugin_manager.py # Plugin framework β”‚ β”‚ β”œβ”€β”€ ble/ # BLE GATT implementation β”‚ β”‚ β”‚ β”œβ”€β”€ gatt_server.py # GATT server β”‚ β”‚ β”‚ β”œβ”€β”€ characteristics.py # GATT characteristics β”‚ β”‚ β”‚ └── bluez_adapter.py # BlueZ D-Bus adapter β”‚ β”‚ β”œβ”€β”€ models/ # Database models β”‚ β”‚ β”‚ └── database.py # SQLite schema β”‚ β”‚ β”œβ”€β”€ config.py # Configuration β”‚ β”‚ └── main.py # FastAPI app β”‚ β”œβ”€β”€ frontend/ # Remix.js frontend β”‚ β”‚ β”œβ”€β”€ app/ β”‚ β”‚ β”‚ β”œβ”€β”€ routes/ # Page routes β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ _index.tsx # Dashboard β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ commands.tsx # Command interface β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ settings.tsx # Settings + WiFi + Updates β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ updates.tsx # Update management β”‚ β”‚ β”‚ β”‚ └── logs.tsx # Command logs β”‚ β”‚ β”‚ β”œβ”€β”€ components/ # React components β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ DeviceSelector.tsx # Multi-device selection β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ PowerWidget.tsx # UPS/battery status β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ ConnectDialog.tsx # Connection management β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ QRScanner.tsx # QR code scanning β”‚ β”‚ β”‚ β”‚ └── LoginPrompt.tsx # WS auth login modal β”‚ β”‚ β”‚ β”œβ”€β”€ hooks/ # Custom React hooks β”‚ β”‚ β”‚ β”‚ └── useWebSocket.ts # WebSocket singleton manager β”‚ β”‚ β”‚ β”œβ”€β”€ root.tsx # Root layout β”‚ β”‚ β”‚ β”œβ”€β”€ styles.css # Cyberpunk theme β”‚ β”‚ β”‚ β”œβ”€β”€ entry.client.tsx # Client entry β”‚ β”‚ β”‚ └── entry.server.tsx # Server entry β”‚ β”‚ β”œβ”€β”€ vite.config.ts # Vite configuration β”‚ β”‚ β”œβ”€β”€ tsconfig.json # TypeScript config β”‚ β”‚ └── package.json # Dependencies β”‚ └── plugins/ # Plugin directory β”‚ └── hello_world/ # Example plugin β”‚ β”œβ”€β”€ plugin.json # Plugin metadata β”‚ └── main.py # Plugin implementation β”œβ”€β”€ systemd/ # Service configuration β”‚ β”œβ”€β”€ dangerous-pi.service # Systemd unit file β”‚ β”œβ”€β”€ dangerous-pi.env.example # Environment template β”‚ β”œβ”€β”€ install-service.sh # Installation script β”‚ β”œβ”€β”€ uninstall-service.sh # Uninstallation script β”‚ └── README.md # Service documentation β”œβ”€β”€ scripts/ # Helper scripts β”‚ └── resolve-port-conflict.sh # Port conflict resolution β”œβ”€β”€ pi-gen/ # OS image builder β”‚ └── stageDTPM3/ # Custom stage β”‚ └── 04-dangerous-pi/ # Dangerous Pi stage β”‚ β”œβ”€β”€ 00-run.sh # Pre-chroot prep β”‚ β”œβ”€β”€ 00-run-chroot.sh # Installation β”‚ β”œβ”€β”€ 01-run-chroot.sh # Port conflict handling β”‚ └── README.md # Build documentation β”œβ”€β”€ data/ # Runtime data β”‚ └── dangerous_pi.db # SQLite database β”œβ”€β”€ logs/ # Application logs β”œβ”€β”€ requirements.txt # Python dependencies β”œβ”€β”€ test_backend.py # Backend tests β”œβ”€β”€ test_ups.py # UPS manager tests β”œβ”€β”€ test_ble.py # BLE manager tests β”œβ”€β”€ test_plugins.py # Plugin manager tests β”œβ”€β”€ .env.example # Environment template β”œβ”€β”€ .gitignore # Git ignore rules β”œβ”€β”€ claude.md # AI dev guide β”œβ”€β”€ UI_GUIDELINES.md # Design system β”œβ”€β”€ WIFI_MANAGER.md # WiFi guide β”œβ”€β”€ UPDATE_MANAGER.md # Update guide β”œβ”€β”€ PORT_CONFLICT.md # Port conflict guide β”œβ”€β”€ MVP_COMPLETE.md # MVP summary β”œβ”€β”€ README.md # Main readme β”œβ”€β”€ README_DEV.md # Dev quick start β”œβ”€β”€ GETTING_STARTED.md # Setup guide └── PROJECT_STATUS.md # This file ``` --- ## 🎨 Design Highlights ### Cyberpunk Aesthetic - **Primary**: Cyan (#00ffff) - Neon glow effect - **Secondary**: Magenta (#ff00ff) - **Accent**: Green (#00ff88) - **Background**: Dark blue (#0a0e1a) - **Monospace**: Terminal feel for code blocks ### Performance Optimizations - Server-side rendering (fast First Contentful Paint) - System fonts only (zero web font download) - Minimal CSS (15KB, no framework) - Code splitting by route - CSS-only animations ### Accessibility - WCAG 2.1 AA compliant - Keyboard navigation - 44x44px touch targets - High contrast colors - ARIA labels --- ## πŸš€ Deployment Path ### Development (Current) ``` Backend: python -m app.backend.main Frontend: npm run dev (separate server) ``` ### Production (Planned) ``` 1. Build frontend: npm run build 2. Backend serves static files from build/ 3. Single server on port 8000 4. Systemd service for auto-start 5. Integrated into pi-gen image ``` --- ## πŸ“ˆ Performance Targets ### Backend - Response time: < 100ms (health checks) - Command execution: < 1s (most PM3 commands) - WebSocket latency: < 50ms (event delivery) - Memory usage: < 100MB ### Frontend - First Contentful Paint: < 1.5s βœ… - Time to Interactive: < 3s βœ… - Bundle size: < 150KB gzipped βœ… - Lighthouse score: > 90 (all categories) --- ## πŸŽ“ Learning Resources For contributors and maintainers: - **Backend**: [README_DEV.md](README_DEV.md) - **Frontend**: [app/frontend/README.md](app/frontend/README.md) - **UI/UX**: [UI_GUIDELINES.md](UI_GUIDELINES.md) - **Setup**: [GETTING_STARTED.md](GETTING_STARTED.md) - **Architecture**: [claude.md](claude.md) --- ## 🀝 Contributing Want to add features? Follow these steps: 1. Read [claude.md](claude.md) for architecture overview 2. Check [UI_GUIDELINES.md](UI_GUIDELINES.md) for design principles 3. Add backend endpoints in `app/backend/api/` 4. Add frontend pages in `app/frontend/app/routes/` 5. Test with `test_backend.py` and manual testing 6. Update documentation --- ## πŸ“ Changelog ### v1.0.0-dev (2025-11-26) - MVP Implementation **Implementation Complete (Not Yet Tested on Hardware):** - WiFi Manager with full functionality (10 endpoints) - Update Manager with GitHub integration (6 endpoints) - UPS Manager with I2C battery monitoring (3 endpoints) - BLE Manager with notification support (4 endpoints) - Plugin Framework with example plugin (7 endpoints) - Systemd service integration with security hardening - Pi-gen build integration (stage 04) - Port conflict resolution tools - 3 new test scripts (UPS, BLE, plugins) - 8 new documentation files **Technical:** - ~5,000+ lines of code - 40+ API endpoints - 6 managers (Session, WiFi, Update, UPS, BLE, Plugin) - 12 documentation files - 4 test suites ### v0.1.0 (2025-11-25) - Foundation Release **Added:** - Complete FastAPI backend with PM3 integration - Remix.js frontend with cyberpunk theme - Dashboard with system status - Command execution interface - Settings page with WiFi UI - Command logs - Session management - Real-time notifications (migrated to WebSocket in v1.0.0) - Comprehensive documentation **Technical:** - ~2,700 lines of code - 22 files - 6 documentation files - 4 web pages - 10 API endpoints --- ## 🎯 Success Criteria ### Phase 1: Foundation βœ… COMPLETE - [x] Working backend API - [x] Working frontend UI - [x] PM3 command execution - [x] Session management - [x] Real-time updates (WebSocket) - [x] Comprehensive documentation ### Phase 2: Core Features (Implementation) βœ… COMPLETE - [x] WiFi manager implementation - [x] Update manager implementation - [x] UPS monitoring implementation - [x] BLE notifications implementation - [x] Plugin framework implementation - [x] Systemd services implementation - [x] Pi-gen integration scripts - [x] Port conflict resolution scripts - [x] Local testing (all tests passing) ### Phase 3: MVP Deployment & Hardware Testing βœ… COMPLETE - [x] Deploy to actual Raspberry Pi Zero 2 W - [x] Test with real Proxmark3 hardware (Iceman firmware 2025-12-30) - [x] Test UPS HAT integration (PiSugar 2 detected and working) - [x] Test BLE on Pi hardware (advertising as DangerousPi) - [x] Combined frontend/backend deployment - [x] Build custom OS image with pi-gen - [x] Fix any hardware-specific issues (PATH fix for iw command) - [ ] Performance optimization on Pi Zero 2 W (ongoing) - [ ] WiFi mode detection fix (reports "client" when in AP mode) ### Phase 4: Enhancement 🚧 IN PROGRESS - [ ] Backup system - [x] HTTPS Settings UI (toggle, cert info, regenerate) - Done 2026-03-03 - [x] Plugin hook wiring (pm3_command, update_check) - Done 2026-03-03 - [x] WebSocket authentication (token-based) - Done 2026-03-03 - [ ] Full authentication (JWT, multi-user, RBAC) - [ ] Additional plugins - [ ] Advanced PM3 features ### Phase 5: Release πŸ“‹ PLANNED - [ ] Beta testing program - [ ] Public release - [ ] User testing - [ ] Community feedback - [ ] Plugin marketplace --- ## πŸ’¬ Notes **Why this architecture?** - FastAPI: Async support, auto-docs, fast - Remix: SSR performance, progressive enhancement - SQLite: Simple, no external database needed - WebSocket: Bidirectional real-time communication, better reconnection handling - Service Layer: Clean separation of concerns, dependency injection for testability **Why cyberpunk theme?** - Matches Dangerous Things brand aesthetic - High contrast works well on small screens - Dark mode saves battery on mobile devices - Monospace fonts create terminal feel **Why no CSS framework?** - Frameworks add 50-200KB overhead - Custom CSS is faster to load - More control over design - Easier to maintain --- Built with ❀️ by **[Dangerous Things](https://dangerousthings.com)**