Micboard Django App - Architecture Overview
System Architecture
┌─────────────────────────────────────────────────────────────┐│ Multi-Manufacturer Device Networks ││ (Shure, Sennheiser, Audio-Technica, etc.) │└──────────────────────────┬──────────────────────────────────┘ │ │ Network Communication │┌──────────────────────────▼──────────────────────────────────┐│ Manufacturer API Servers/Middleware ││ - Shure System API ││ - Sennheiser API ││ - Other manufacturer APIs ││ - Device discovery and communication │└──────────────────────────┬──────────────────────────────────┘ │ │ HTTP/HTTPS REST APIs │┌──────────────────────────▼──────────────────────────────────┐│ Micboard Django App (This Application) ││ ││ ┌────────────────────────────────────────────────┐ ││ │ Plugin Architecture │ ││ │ - ManufacturerPlugin abstract base class │ ││ │ - Dynamic plugin loading │ ││ │ - Manufacturer-specific implementations │ ││ └────────────┬───────────────────────────────────┘ ││ │ ││ ┌────────────▼───────────────────────────────────┐ ││ │ poll_devices command │ ││ │ - Multi-manufacturer polling │ ││ │ - Model updates with manufacturer isolation │ ││ │ - WebSocket broadcasting │ ││ └────────────┬───────────────────────────────────┘ ││ │ ││ ┌────────────▼───────────────────────────────────┐ ││ │ Django Models │ ││ │ - Manufacturer, Receiver, Transmitter │ ││ │ - Group, Config (manufacturer-aware) │ ││ │ - Database persistence with data isolation │ ││ └────────────┬───────────────────────────────────┘ ││ │ ││ ├──────────────┬─────────────────┐ ││ │ │ │ ││ ┌────────────▼───────┐ ┌───▼────────┐ ┌──────▼──────┐ ││ │ Views/API │ │ WebSocket │ │ Django │ ││ │ - REST endpoints │ │ Consumers │ │ Admin │ ││ │ - Manufacturer │ │ - Real-time│ │ - Config UI │ ││ │ filtering │ │ updates │ │ │ ││ └────────────────────┘ └────────────┘ └─────────────┘ │└──────────────────────────┬──────────────────────────────────┘ │ │ HTTP/WebSocket │┌──────────────────────────▼──────────────────────────────────┐│ Web Browser / Client ││ - Dashboard UI ││ - Real-time updates ││ - Multi-manufacturer device management │└──────────────────────────────────────────────────────────────┘Component Details
1. Plugin Architecture
Purpose: Extensible support for manufacturer protocols without duplicating shared transport and safety behavior.
Key Components:
micboard.services.common.base.plugin.ManufacturerPlugin- Plugin contractmicboard.services.common.base.plugin.build_manufacturer_plugin- Cached construction boundarymicboard.services.common.base.client.BaseHTTPClient- Shared verified HTTP transportmicboard.integrations.<vendor>- Manufacturer-local clients, discovery, transforms, and streams
The contract exposes name, code, inventory and per-device reads, transformation, health,
discovery-IP management, and a client boundary. Protocol details remain in each integration. See
Manufacturer plugin development for the complete live contract and a
copy-safe implementation workflow.
Features:
- Convention-based plugin discovery and cached construction
- Shared response bounds, retries, TLS validation, rate limiting, and exception behavior
- Manufacturer data isolation
- Independently testable protocol adapters
2. Polling Service (poll_devices.py)
Purpose: One-shot command and service that fetch data from multiple manufacturers
Workflow:
- Iterate through configured manufacturers
- Load appropriate plugin for each manufacturer
- Poll each manufacturer API once per invocation
- Transform and validate data using plugin
- Update Django models with manufacturer relationships
- Broadcast updates via WebSocket to connected clients
- Cache data for quick API responses
Configuration:
- Deployment-controlled polling intervals
- Manufacturer-specific settings
- WebSocket broadcasting enable/disable
- Logging and error handling
3. Real-Time Connection Management (RealTimeConnection Model)
Purpose: Track and monitor real-time connections for automatic failover and health monitoring
Key Components:
RealTimeConnectionmodel - Tracks SSE/WebSocket connection lifecycle- Health monitoring tasks - Automatic cleanup and status reporting
- Management commands - CLI tools for connection monitoring
- Admin interface - Visual oversight of connection health
Connection States:
connecting- Establishing connectionconnected- Active real-time updatesdisconnected- Temporarily offlineerror- Connection failed with errorsstopped- Intentionally stopped
Features:
- Automatic reconnection with exponential backoff
- Error tracking and recovery
- Connection duration monitoring
- Health status aggregation
- Manufacturer-aware connection management
4. WebSocket Consumer (consumers.py)
Purpose: Real-time bidirectional communication with clients
Features:
- Async WebSocket handling
- Channel layer integration for broadcasting
- Client command handling (ping/pong)
- Automatic reconnection support
- Manufacturer-aware message filtering
Message Types:
device_update- Full device data updates (manufacturer-filtered)device_status_update- Persisted hardware status transitionsapi_health_update- Manufacturer API health transitionsping/pong- Client keepalive, metered per connection
4. Django Models
Manufacturer
- Represents a wireless microphone manufacturer
- Stores manufacturer code, name, and configuration
- Central point for manufacturer-specific settings
Receiver
- Represents a wireless receiver (manufacturer-aware)
- Foreign key to Manufacturer model
- Tracks API device ID, IP, type, slot
- Records last seen timestamp
Transmitter
- Transmitter/microphone data
- Battery, audio levels, RF metrics
- Frequency, antenna, quality info
- Auto-updated by polling service
DiscoveredDevice
- Network-discovered devices before registration
- Manufacturer relationship for proper categorization
- Temporary storage during device discovery
RealTimeConnection
- Tracks real-time subscription connections (SSE/WebSocket)
- Connection status, error tracking, and reconnection logic
- One-to-one relationship with Receiver model
- Automatic health monitoring and cleanup
Group & MicboardConfig
- Logical grouping of devices
- Key-value configuration storage
- Optional manufacturer relationships for manufacturer-specific settings
Admin Hardware Layout & Health
The Django admin includes a “Hardware Layout Overview” to provide a compact, hardware-first view of receivers grouped by manufacturer and location. It focuses on the mapping Receiver -> Channel -> Frequency and optionally the assigned user. This view is useful for site technicians to quickly confirm physical configurations.
API health is probed by native Huey tasks and surfaced in the public UI as a footer indicator. The context processor reads a bounded aggregate from cache, falling back to the latest persisted per-manufacturer health logs; public request rendering never performs manufacturer network I/O.
5. Views and API Endpoints
Dashboard Views:
/- Main monitoring dashboard (manufacturer-filtered)/about/- About page
API Endpoints (all support ?manufacturer=code filtering):
GET /api/data/- Current device data (cached, manufacturer-filtered)POST /api/discover/- Trigger device discovery (manufacturer-specific)POST /api/refresh/- Force data refresh (manufacturer-specific)POST /api/config/- Update global/manufacturer-specific configPOST /api/group/- Manage groupsGET /api/receivers/- List receivers (manufacturer-filtered)GET /api/receivers/{id}/- Get receiver detailsGET /api/health/- Check API health (per-manufacturer)
5. Management Commands
Real-Time Status (realtime_status):
- Display connection status summary
- Filter by manufacturer or status
- Show detailed connection information
- Color-coded output for quick status assessment
Device Polling (poll_devices):
- Poll manufacturer APIs for device data
- Update models and broadcast via WebSocket
- Evaluate a hard-bounded set of alert-eligible wireless units
- Never start or enqueue real-time subscription supervisors
- Support for async execution with native Huey
6. Admin Interface
Real-Time Connections:
- Visual monitoring of connection health
- Color-coded status indicators
- Bulk actions for connection management
- Detailed connection history and error tracking
Hardware Layout Overview:
- Compact view of receivers grouped by manufacturer and location
- Focus on Receiver -> Channel -> Frequency mapping
- Useful for site technicians to verify physical configurations
7. Views and API Endpoints
Dashboard Views:
/- Main monitoring dashboard (manufacturer-filtered)/about/- About page
API Endpoints (all support ?manufacturer=code filtering):
GET /api/data/- Current device data (cached, manufacturer-filtered)POST /api/discover/- Trigger device discovery (manufacturer-specific)POST /api/refresh/- Force data refresh (manufacturer-specific)POST /api/config/- Update global/manufacturer-specific configPOST /api/group/- Manage groupsGET /api/receivers/- List receivers (manufacturer-filtered)GET /api/receivers/{id}/- Get receiver detailsGET /api/health/- Check API health (per-manufacturer)
Data Flow
Normal Operation (Polling)
1. A deployment scheduler invokes poll_devices --async2. For each configured manufacturer: a. Load manufacturer plugin b. Call plugin.get_devices() c. Transform data using plugin.transform_device_data() d. Update Django models with manufacturer relationships3. Cache manufacturer-filtered data4. Broadcast updates to WebSocket clients5. Exit; the deployment scheduler controls the next intervalReal-time Updates (WebSocket + SSE)
1. The host explicitly launches a foreground command or native Huey task entrypoint: a. For Shure: start the WebSocket supervisor b. For Sennheiser: start the SSE supervisor2. A process-shared cache lease permits one supervisor per transport/manufacturer3. Hard device and concurrency limits bound subscription work4. RealTimeConnection models track subscription status5. Health monitoring tasks check connection health6. Updates broadcast via WebSocket to connected clients7. Polling runs independently and never starts supervisorsAPI Request Flow
1. Client requests /api/data/?manufacturer=shure2. Check manufacturer-filtered cache3. If cached: return immediately4. If not: query models with manufacturer filter5. Transform to JSON using manufacturer-aware serializers6. Cache result with manufacturer key7. Return to clientPlugin System
Plugin Discovery
micboard.services.common.base.plugin discovers plugins from the manufacturer code and caches
the selected class:
from micboard.services.common.base.plugin import ( build_manufacturer_plugin, get_manufacturer_plugin,)
plugin_class = get_manufacturer_plugin("shure")plugin = build_manufacturer_plugin(manufacturer)For code acme_audio, class discovery imports micboard.integrations.acme_audio.plugin and
prefers AcmeAudioPlugin. No package initializer or registry map needs editing.
Adding New Manufacturers
- Create
micboard/integrations/<code>/plugin.py. - Implement a concrete, conventionally named
ManufacturerPluginsubclass. - Keep device, discovery, transform, and streaming behavior in that integration package.
- Create or enable a
Manufacturerrow whosecodematches the package name. - Verify
get_manufacturer_plugin("<code>")resolves the class.
Data Isolation
- Each manufacturer’s data is stored with manufacturer relationships
- API responses are filtered by manufacturer code
- Configuration can be global or manufacturer-specific
- WebSocket broadcasts include manufacturer context
Configuration Management
Manufacturer Configuration
Each manufacturer is configured in the database with:
- code: Unique identifier (e.g., ‘shure’, ‘sennheiser’)
- name: Human-readable name
- config: JSON configuration object with API credentials and settings
Settings Integration
All configuration is centralized in Django settings:
MICBOARD_CONFIG = { 'DEFAULT_POLLING_INTERVAL': 10, 'WEBSOCKET_BROADCASTING': True, 'CACHE_TIMEOUT': 30,}Manufacturer-Specific Settings
Manufacturer configurations are stored in the database:
# Shure manufacturer configurationmanufacturer = Manufacturer.objects.create( code='shure', name='Shure Incorporated', config={ 'api_url': 'https://shure-api.example.com', 'api_key': 'your-api-key', 'timeout': 30, 'polling_interval': 10, })Environment Variables (Recommended for Production)
export SHURE_API_URL="https://api.shure.com"export SHURE_API_KEY="secret-key"export SENNHEISER_API_URL="https://api.sennheiser.com"export SENNHEISER_API_KEY="another-secret"Global vs Manufacturer-Specific Config
- Global Config: Stored in
MicboardConfigwithmanufacturer=None - Manufacturer Config: Stored in
MicboardConfigwithmanufacturerset - Plugin Config: Stored in
Manufacturer.configJSON field
Deployment Architecture
Development
Single Machine:- Django runserver- poll_devices for one-shot device refreshes- In-memory channel layer- SQLite databaseProduction
Multi-Process:- Nginx (reverse proxy, static files)- Daphne (ASGI server for WebSockets)- Native Huey consumer- Deployment scheduler invoking poll_devices --async- Redis (channel layer, caching)- PostgreSQL (database)- Supervisor/systemd (process management)Scalability Considerations
Horizontal Scaling
- Multiple Daphne workers for WebSocket connections
- Huey workers consuming queued polling tasks
- Load balancer for HTTP traffic
- Redis for shared state
Performance Optimization
- Redis caching for API responses
- Database query optimization (select_related, prefetch_related)
- WebSocket connection pooling
- API request batching
Security
Authentication
- Required Shure System API authentication (shared secret)
- Django session-based auth for admin
- WebSocket authentication via Django middleware
Network Security
- TLS/SSL for Shure API communication
- HTTPS for web traffic
- WSS (WebSocket Secure) for production
- Firewall rules for Shure device network
Monitoring and Logging
Logging Components
- API client logs (requests, errors)
- Polling service logs (updates, errors)
- WebSocket logs (connections, disconnections)
- Django request logs
Metrics to Monitor
- API response times
- Device polling success rate
- WebSocket connection count
- Database query performance
- Cache hit rates
Error Handling
API Failures
- Automatic retry with backoff
- Graceful degradation (use cached data)
- Error logging and alerting
- Status indicator in UI
Database Errors
- Transaction rollback
- Integrity constraint handling
- Connection pool management
WebSocket Errors
- Automatic reconnection
- Message queuing during disconnection
- Connection health monitoring
Future Enhancements
Recently Implemented
- Real-Time Subscriptions - SSE/WebSocket connections with automatic failover
- Connection Health Monitoring - RealTimeConnection model and health tasks
- Management Commands - CLI tools for monitoring and status checking
- Admin Interface - Visual oversight of real-time connection health
Planned Features
- Additional Manufacturer Plugins - Audio-Technica, Lectrosonics
- Historical Data Storage - Time-series data for trending and analytics
- Advanced Alert System - Battery/RF issues with manufacturer-specific thresholds
- Mobile App Support - Native apps for iOS/Android
- Multi-Site Deployment - Centralized monitoring across multiple locations
- Advanced Reporting - Manufacturer-specific analytics and reports
Integration Opportunities
- Notification Systems - Slack/Teams integrations with manufacturer context
- Monitoring Dashboards - Grafana/Prometheus with manufacturer filtering
- Syslog Integration - Centralized logging with manufacturer tags
- Calendar Integration - Event-based monitoring schedules
- Asset Management - Integration with IT asset management systems
Migration from Original Micboard
Advantages of New Architecture
- Official API: Uses Shure’s supported API instead of reverse-engineered protocols
- Maintainability: Cleaner separation of concerns
- Scalability: Easier to scale horizontally
- Real-time: Better WebSocket implementation
- Database: Persistent storage of device configurations
- Modern: Uses current Django best practices
Migration Path
- Install Shure System API server
- Run both systems in parallel
- Verify data accuracy
- Switch DNS/routing to new system
- Decommission old system
Troubleshooting Guide
Common Issues
Issue: No devices detected
- Solution: Check Shure System API connectivity, verify devices are on network
Issue: WebSocket disconnects frequently
- Solution: Check Redis connection, increase timeout values, verify network stability
Issue: Slow API responses
- Solution: Check Redis cache, optimize database queries, increase polling interval
Issue: High CPU usage
- Solution: Increase polling interval, reduce log verbosity, optimize queries
Manufacturer Integration Guides
Comprehensive integration documentation for supported manufacturers:
Shure System API
- Guide: Shure Integration Guide
- Contents: Authentication, API endpoints, configuration, troubleshooting
- API Reference: https://www.shure.com/en-US/products/software/systemapi
- Status: Production ready with comprehensive test suite
Sennheiser SSCv2 API
- Guide: Sennheiser Integration Reference
- Contents: Device configuration, authentication, API operations, security
- API Reference: https://docs.cloud.sennheiser.com/en-us/api-docs/
- Status: Integration ready
Support and Documentation
Official API Documentation
- Shure System API: https://www.shure.com/en-US/products/software/systemapi
- Sennheiser Sound Control Protocol: https://docs.cloud.sennheiser.com/en-us/api-docs/api-docs/sound-control-protocol.html
Framework Documentation
- Django Channels: https://channels.readthedocs.io/
- Django REST Framework: https://www.django-rest-framework.org/
Micboard Documentation
- Development Guide: development.md
- Plugin Development: Adding New Manufacturers
- Rate Limiting: Shared Rate Limiter
- Integration References: integration-references.md
- Original Micboard: https://github.com/mikecentral/micboard
This architecture provides a robust, scalable, and maintainable solution for wireless microphone monitoring using modern Django practices and manufacturer APIs from Shure, Sennheiser, and other wireless audio providers.
