NexusHome IoT is a comprehensive smart home energy management platform built on .NET 8.0, leveraging Clean Architecture principles to ensure maintainability, testability, and scalability.
┌─────────────────────────────────────────────────────────────────────────────┐
│ External Systems │
├─────────────────────────────────────────────────────────────────────────────┤
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Weather │ │ Utility │ │ Azure │ │ Mobile │ │
│ │ API │ │ Provider │ │ IoT Hub │ │ App Users │ │
│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
│ │ │ │ │ │
└─────────┼─────────────────┼─────────────────┼─────────────────┼────────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ NexusHome IoT Platform │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ ASP.NET Core API │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │ │
│ │ │ REST API │ │ SignalR │ │ Background Services │ │ │
│ │ │ Controllers │ │ Hubs │ │ (MQTT, Energy, ML) │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ IoT Devices │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Smart │ │ Climate │ │ Security │ │ Energy │ │
│ │ Lighting │ │ Control │ │ Devices │ │ Meters │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────┐
│ NexusHome IoT Platform │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────────────────────────────────────────┐ │
│ │ API Layer (Port 5000) │ │
│ │ ┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────────────┐ │ │
│ │ │ Device │ │ Energy │ │ Automation │ │ SignalR Hubs │ │ │
│ │ │ Controller │ │ Controller │ │ Controller │ │ - DeviceStatus │ │ │
│ │ │ │ │ │ │ │ │ - EnergyMonitoring │ │ │
│ │ │ │ │ │ │ │ │ - Notifications │ │ │
│ │ └────────────┘ └────────────┘ └────────────┘ └────────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────────┐ │
│ │ Core Services Layer │ │
│ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────────────┐ │ │
│ │ │ SmartDevice │ │ EnergyOptim- │ │ PredictiveMaintenance │ │ │
│ │ │ Manager │ │ izationService │ │ Service │ │ │
│ │ └─────────────────┘ └─────────────────┘ └─────────────────────────┘ │ │
│ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────────────┐ │ │
│ │ │ Automation │ │ EnergyConsump- │ │ NotificationDispatcher │ │ │
│ │ │ RuleEngine │ │ tionAnalyzer │ │ │ │ │
│ │ └─────────────────┘ └─────────────────┘ └─────────────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────────┐ │
│ │ Infrastructure Layer │ │
│ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────────────┐ │ │
│ │ │ EnhancedMqtt │ │ SmartHomeDb │ │ OpenWeatherMap │ │ │
│ │ │ ClientService │ │ Context (EF) │ │ Provider │ │ │
│ │ └─────────────────┘ └─────────────────┘ └─────────────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
│ │ │
▼ ▼ ▼
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ MQTT Broker │ │ SQL Server │ │ Redis Cache │
│ (Mosquitto) │ │ (Primary DB) │ │ (Session/Cache) │
│ Port 1883 │ │ Port 1433 │ │ Port 6379 │
└──────────────────┘ └──────────────────┘ └──────────────────┘
- Responsibility: HTTP request handling, SignalR real-time communication
- Pattern: Thin controllers delegating to services
- Dependencies: Depends on Core Services layer only
- Responsibility: Business logic, domain entities, service interfaces
- Pattern: Domain-Driven Design with service layer
- Dependencies: No external dependencies, defines interfaces
- Responsibility: External integrations, data access, MQTT communication
- Pattern: Repository pattern, adapter pattern for external services
- Dependencies: Implements Core interfaces, uses external packages
IoT Device → MQTT Broker → MqttConnectionService → DeviceDataCollectionService
→ SmartDeviceManager → SmartHomeDbContext → SignalR Hub → Web Dashboard
EnergyMonitoringBackgroundService → EnergyConsumptionAnalyzer
→ EnergyOptimizationService (ML.NET) → AutomationRuleEngine
→ SmartDeviceManager → MQTT Command → IoT Device
DeviceTelemetryReading → PredictiveMaintenanceBackgroundService
→ PredictiveMaintenanceService (ML.NET Model)
→ MaintenanceSchedulingService → NotificationDispatcher
| Component | Technology | Purpose |
|---|---|---|
| Framework | .NET 8.0 | Core runtime |
| Web API | ASP.NET Core | HTTP endpoints |
| Real-time | SignalR | WebSocket communication |
| ORM | EF Core 8.0 | SQL Server access |
| IoT Protocol | MQTTnet 4.3 | Device communication |
| ML/AI | ML.NET 3.0 | Predictive analytics |
| Caching | Redis | Session and data cache |
| Logging | Serilog | Structured logging |
| Containers | Docker | Deployment |
- Authentication: JWT Bearer tokens with configurable expiration
- Authorization: Role-based access control (Admin, User, Device)
- Transport: TLS 1.2+ for all external communication
- Secrets: Environment variables for production secrets
- Rate Limiting: AspNetCoreRateLimit for API protection
See docker-compose.yml for container orchestration with:
- Health checks on all services
- Volume persistence for data durability
- Network isolation via bridge network
- Environment-based configuration