Full-stack IoT system with ESP32, FastAPI, React, and real-time MQTT
Architected a full-stack IoT system for a smart home model meant to give full lighting, temperature, and security control through a React dashboard; built with ESP32 firmware in C/C++. Implemented a rules engine with configurable threshold triggers and MQTT pub/sub for real-time sensor data (temperature, occupancy, light, door lock) with sub-second actuation latency.
Case Study
Problem
Build a full-stack smart-home platform that gives homeowners real-time visibility and control over lighting, temperature, occupancy, and door-lock status, all from a single web dashboard.
Architecture
- ESP32 firmware (C/C++) with sensors + actuators communicating over MQTT
- MQTT broker bridging firmware to backend
- FastAPI backend with JWT auth, SQLite persistence, and configurable rules engine
- React dashboard for real-time monitoring and control
- Docker Compose deployment with GitHub Actions CI/CD
Challenges
- Achieving sub-second actuation latency end-to-end across MQTT and HTTP layers
- Reliably detecting occupancy with a PIR sensor and debouncing false positives
- Keeping JWT session management consistent between ESP32 and the web client
- Writing cross-platform Docker Compose configs that work on both ARM and x86 hosts
Tradeoffs
- Chose SQLite over PostgreSQL for simplicity; acceptable for a single-home deployment
- Used polling on the frontend for some metrics instead of WebSockets to reduce complexity
- Stored JWT secrets in environment variables rather than a secrets manager to avoid cloud dependency
Outcome
End-to-end smart home platform running on real hardware, with sub-second sensor-to-dashboard latency and a passing Pytest + Jest CI suite.
What I Learned
- Embedded MQTT pub/sub patterns and their tradeoffs vs HTTP polling
- FastAPI dependency injection and JWT middleware design
- How Docker networking affects service discovery between containers
- Debouncing and hardware noise mitigation for PIR sensors