Unified Dashboard Architecture

Problem Statement

The current dashboard implementation has several issues:

Proposed Solution: Single Unified Dashboard

Core Principles

  1. Single Data Pipeline: One unified data collection system feeding both real-time and historical views
  2. Single Dashboard Endpoint: Consolidate all monitoring at /dashboard/
  3. Operational Visibility: Include system health metrics that matter for operations
  4. Real-time Updates: WebSocket-based live updates for all widgets
  5. Progressive Enhancement: Works without JavaScript, enhanced with real-time updates

Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Loxone Data   │────│ Data Collector  │────│ Unified Storage β”‚
β”‚    Sources      β”‚    β”‚   Pipeline      β”‚    β”‚    System       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚                        β”‚
                                β–Ό                        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Real-time       β”‚    β”‚    Dashboard    β”‚    β”‚   Historical    β”‚
β”‚ WebSocket       │◄───│   Controller    │────│    Analysis     β”‚
β”‚ Updates         β”‚    β”‚                 β”‚    β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                                β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Unified Dashboard UI                         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Real-time       β”‚ Device & Room   β”‚ Operational     β”‚ Historicalβ”‚
β”‚ Monitoring      β”‚ Overview        β”‚ Metrics         β”‚ Analysis  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Dashboard Layout

Section 1: Real-time Monitoring (Top Row)

Section 2: Device & Room Overview (Second Row)

Section 3: Operational Metrics (Third Row)

Section 4: Historical Analysis (Bottom Row)

Data Collection Pipeline

Unified Data Collector

pub struct UnifiedDataCollector {
    // Loxone client connections
    clients: HashMap<String, Arc<dyn LoxoneClient>>,
    
    // Storage systems
    hot_storage: Arc<RwLock<HotDataStore>>,
    cold_storage: Arc<ColdDataStore>,
    
    // Real-time distribution
    websocket_manager: Arc<WebSocketManager>,
    
    // Metrics collection
    operational_metrics: Arc<OperationalMetricsCollector>,
}

Data Flow

  1. Collection: Single service polls Loxone every 5 seconds
  2. Processing: Normalize data into unified event format
  3. Distribution:
    • Hot storage for real-time dashboard
    • Cold storage for historical analysis
    • WebSocket broadcast for live updates
  4. Aggregation: Pre-compute common metrics for dashboard performance

Implementation Plan

Phase 1: Core Infrastructure

  1. Create UnifiedDataCollector service
  2. Implement unified data pipeline
  3. Create WebSocket endpoint for real-time updates
  4. Consolidate storage access layer

Phase 2: Dashboard Implementation

  1. Create single dashboard HTML template
  2. Implement JavaScript for real-time updates
  3. Add operational metrics collection
  4. Create responsive CSS for all screen sizes

Phase 3: Advanced Features

  1. Add historical analysis widgets
  2. Implement user preferences
  3. Add dashboard configuration
  4. Performance optimization

API Endpoints

Primary Dashboard

Data APIs

Operational Metrics Collection

Rate Limiter Metrics

API Performance Metrics

Security Metrics

Resource Metrics

Benefits

  1. Operational Visibility: Clear view of system health and performance
  2. Unified Experience: Single place for all monitoring needs
  3. Real-time Feedback: Immediate updates when devices change
  4. Historical Context: Understanding long-term patterns and trends
  5. Troubleshooting: Easy identification of issues and their timeline
  6. Performance Monitoring: Proactive identification of bottlenecks

Migration Strategy

  1. Phase 1: Keep existing endpoints, add new unified dashboard
  2. Phase 2: Migrate users to new dashboard, mark old endpoints deprecated
  3. Phase 3: Remove deprecated endpoints after user adoption

This architecture addresses all the current issues while providing a foundation for future dashboard enhancements.