Design a system to monitor IoT devices for maintenance and repair alerts
Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2021-02-02
Problem Statement
Designing a system that monitors IoT devices in real-time to detect anomalies, trigger maintenance alerts, and notify relevant personnel for repair. The focus is on object-oriented design, modular architecture, event handling, and alerting mechanisms.
✅ Functional Requirements
1.Device Management
•Register and manage IoT devices: deviceId, deviceType, location, status.
•Support metadata such as manufacturer, installation date, maintenance schedule.
2.Data Collection & Monitoring
•Collect telemetry data from devices (e.g., temperature, vibration, battery level).
•Store historical data for trend analysis.
•Detect anomalies or threshold breaches in real-time.
3.Alerting & Notifications
•Generate alerts when devices require maintenance or repair.
•Notify personnel via email, SMS, or in-app notification.
•Support severity levels: critical, warning, informational.
4.Maintenance Scheduling
•Track maintenance history for devices.
•Schedule preventive maintenance based on thresholds, usage, or calendar schedules.
5.Reporting & Analytics (Optional)
•Generate reports of device health, uptime, and failures.
•Analyze patterns to predict future failures (predictive maintenance).
🔐 Constraints & Assumptions
•Focus is on LLD, event handling, and alert generation, not on actual device communication protocols.
•Assume devices can send data periodically or on event triggers.
•The system should be scalable to thousands of devices.
🧱 Key Components & Classes
1.Device Class
1
2class Device {
3private:
4 string deviceId;
5 string deviceType;
6 string location;
7 string status; // ACTIVE, INACTIVE, ERROR
8 vector<SensorData*> telemetryData;
9public:
10 void updateStatus(string newStatus);
11 void addTelemetryData(SensorData* data);
12};1.SensorData Class
1
2class SensorData {
3private:
4 string sensorType;
5 double value;
6 DateTime timestamp;
7public:
8 double getValue();
9 string getSensorType();
10};1.Alert Class
1
2class Alert {
3private:
4 string alertId;
5 Device* device;
6 string severity; // CRITICAL, WARNING, INFO
7 string message;
8 DateTime timestamp;
9public:
10 void notify();
11};1.MonitoringService Class
•Monitors incoming data from devices.
•Checks thresholds and triggers alerts.
1
2class MonitoringService {
3public:
4 void processSensorData(Device* device, SensorData* data);
5 void generateAlert(Device* device, string message, string severity);
6};1.NotificationManager Class
•Handles delivery of alerts via Email, SMS, or Push notifications.
1
2class NotificationManager {
3public:
4 void sendAlert(Alert* alert);
5};1.MaintenanceScheduler Class
•Tracks device maintenance schedules.
•Generates scheduled alerts for preventive maintenance.
🔄 Example Workflow
1.Device sends telemetry data → MonitoringService.processSensorData().
2.Data exceeds threshold → generateAlert() creates an Alert object.
3.NotificationManager.sendAlert() notifies the maintenance personnel.
4.Maintenance personnel perform repair → Device.updateStatus() updates device health.
5.Optional: MaintenanceScheduler triggers periodic preventive maintenance alerts.
🧪 Expected Deliverables
•Class diagram showing Device, SensorData, Alert, MonitoringService, NotificationManager, and MaintenanceScheduler.
•Implementation of data processing, alert generation, and notification delivery.
•Test cases:
•Device crossing threshold triggers alert
•Notification delivery to multiple channels
•Scheduled preventive maintenance alerts
•Updating device status post-repair
💡 Discussion Points
•Threshold handling: static vs dynamic thresholds based on historical trends.
•Scalability: handling thousands of devices simultaneously.
•Extensibility for predictive maintenance using analytics.
•Concurrency: ensuring alerts are generated reliably under high data volume.