Student: Karan Chauhan (400606872)
Course: SFWRTECH 4SA3 - Software Architecture
- Milestone 1 - Proposal
- Milestone 2 - Architecture
- Milestone 3 - Architecture Viewpoints (4+1)
- Milestone 4 - Final Implementation
EnviroSync is a backend IoT telemetry system that receives local readings from M5StickC Plus 2 + ENV IV, enriches the readings with OpenWeatherMap data, applies alert rules, and stores unified records in PostgreSQL.
- Adapter Pattern (
src/adapters/weather_adapter.py): wraps OpenWeatherMap and returns a normalizedWeatherReading. - Circuit Breaker Pattern (
src/patterns/circuit_breaker.py): protects external weather calls with fail-fast behavior during repeated failures. - Factory Method Pattern (
src/factories/alert_factory.py): generates alert objects from telemetry and weather context.
src/main.py: FastAPI application and endpoints.src/database.py: PostgreSQL schema setup and data persistence.src/models.py: shared request/response models and alert dataclasses.edge/m5stickc_envirosync.yaml: ESPHome config for M5StickC Plus 2 + ENV IV push.
uv syncCreate .env in the project root:
DATABASE_URL=postgresql://username:password@host:5432/database_name
OPENWEATHER_API_KEY=your_openweather_api_key
WEATHER_LAT=43.2609
WEATHER_LON=-79.9192
WEATHER_TIMEOUT_SECONDS=10uv run uvicorn src.main:app --host 0.0.0.0 --port 8000 --reloadSwagger UI:
start http://127.0.0.1:8000/docsHealth:
curl http://127.0.0.1:8000/healthIngest telemetry:
curl -X POST http://127.0.0.1:8000/telemetry ^
-H "Content-Type: application/json" ^
-d "{\"temperature\":24.2,\"humidity\":45.1,\"pressure\":1009.6,\"device_id\":\"m5stickc-plus2\"}"Recent records:
curl "http://127.0.0.1:8000/telemetry/recent?limit=10"Recent alerts:
curl "http://127.0.0.1:8000/alerts/recent?limit=10"Note: GET / is not implemented, so http://127.0.0.1:8000/ returns {"detail":"Not Found"} by design.
- Use
edge/m5stickc_envirosync.yaml. - Replace Wi-Fi credentials and
http://<PYTHON_SERVER_IP>:8000/telemetry. - Flash to M5StickC Plus 2 with ENV IV connected via I2C.
- Device posts temperature, humidity, and pressure every 60 seconds.
- Button A can also push telemetry immediately for a live demo.
