
The One
Home Automation Re-architecture
Overview
The Problem
An existing home automation system controlled lights, cameras, sensors, and access in a facility with hundreds of devices. It worked, but around 100 devices it started collapsing: rising latency, frequent crashes, and the server under constant load. The client needed to expand to 1000+ devices, but the existing architecture made that impossible.
Code analysis revealed the root cause: every device was polling HTTP every second asking whether there were updates, even when nothing had changed. With 200 devices, this meant 200 requests per second at idle. At 1000 devices it would be 1000 requests per second just standing still. The server couldn't cope.
The Solution
I re-architected the system starting from the communication layer. I replaced HTTP polling with persistent WebSockets: devices open one connection and receive notifications only when there's something to communicate. Idle load dropped to near zero. To further reduce traffic I introduced custom binary serialization instead of JSON: device status messages compress by 80%.
Every IoT device manufacturer uses different proprietary protocols. I wrote custom parsers for each protocol present in the facility, with an abstraction layer that exposes them all through the same interface to the frontend. Redux Toolkit manages the global state of every device predictably, using incremental diffs instead of full replacements.
The architecture is hybrid to guarantee continuity: local Redis handles real-time state and immediate commands (if internet goes down, the facility still works), cloud MongoDB syncs logs, configurations, and remote access. A health monitoring system with auto-recovery detects offline or erroring devices and attempts automatic restoration before alerting the team.
The Result
The identity sync bug was fixed: 0 ID corruptions since the fix went live. The reconnection burst crash was eliminated with exponential backoff on the Socket.IO client. Three protocol parsers were written and integrated. The new WebSocket, Redis, and MongoDB architecture was fully implemented, but the project was suspended for organizational reasons before the final rollout.
Key Features
- Identity bug fixed: eliminated the ID corruption problem that was affecting the system in production
- Reconnect burst crash fixed: exponential backoff on the Socket.IO client
- 3+ custom protocol parsers written to integrate devices from different manufacturers
- Re-architected with WebSocket + local Redis + cloud MongoDB: implemented, suspended before full rollout