A cloud-native, Kubernetes-based microservices platform for monitoring ThermoWorks wireless thermometers with Home Assistant integration. This project transforms a monolithic Flask application into a scalable, distributed system following modern DevOps practices.
- Architecture Overview
- Features
- Services
- Prerequisites
- Quick Start
- Configuration
- API Documentation
- Deployment
- Development
- Monitoring
- Contributing
The platform follows a microservices architecture with clear service boundaries:
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β API Gateway β β Device Service β βTemperature Svc β
β (Kong/Nginx) β β (PostgreSQL) β β (InfluxDB) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
ββββββββββββββββββββββββββΌβββββββββββββββββββββββββ
β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
βHome Assistant β β Notification β β Data Proc. β
β Service β β Service β β Service β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- Device Management Service: ThermoWorks device discovery and configuration
- Temperature Data Service: Real-time data collection with time-series storage
- Home Assistant Integration: Sensor creation and state synchronization
- API Gateway: Centralized routing, authentication, and rate limiting
- Data Processing Service: Analytics, alerts, and data transformation
- Notification Service: Multi-channel alerting and escalation
- Web UI: Real-time temperature monitoring dashboard
See the detailed FEATURES.md for comprehensive documentation of implemented features.
- OAuth2 authentication with ThermoWorks Cloud API
- Robust API client with automatic token refresh and error handling
- Configurable polling intervals from 5 seconds to 5 minutes
- Real-time temperature charts with multiple probe support
- Device health monitoring with battery and signal indicators
- Disconnected probe detection with visual indicators
- Redis-based caching for sub-second response times
- InfluxDB integration for high-performance time-series data
- Configurable retention policies (1 day, 1 week, 1 month, 1 year)
- Aggregation queries (mean, max, min) with custom intervals
- Batch processing for high-throughput data ingestion
- Automatic sensor creation with proper device classes
- State synchronization with battery and signal strength
- Entity naming conventions following HA best practices
- Service discovery and health monitoring
- User Authentication with email/password login
- Account security with lockout protection
- Zero-trust network policies with Kubernetes NetworkPolicy
- OpenTelemetry instrumentation for distributed tracing
- Structured logging with JSON formatting
- Health checks and readiness probes
- Resource quotas and security contexts
Port: 8080 Database: PostgreSQL Purpose: Device discovery, registration, and configuration management
Key Endpoints:
POST /api/devices/discover- Discover and register ThermoWorks devicesGET /api/devices- List all registered devicesGET /api/devices/{id}- Get specific device detailsPUT /api/devices/{id}- Update device configurationGET /api/devices/{id}/health- Device health statusGET /api/devices/{id}/temperature- Current temperature readingsGET /api/devices/{id}/history- Historical temperature dataPOST /api/sync- Manually trigger data synchronizationGET /api/auth/thermoworks/status- Check ThermoWorks connection status
Port: 8080 Database: InfluxDB + Redis Purpose: Real-time temperature data collection and historical analysis
Key Endpoints:
GET /api/temperature/current/{device_id}- Current temperature readingGET /api/temperature/history/{device_id}- Historical data with aggregationPOST /api/temperature/batch- Batch temperature data storageGET /api/temperature/stats/{device_id}- Temperature statisticsGET /api/temperature/stream/{device_id}- Real-time SSE streamGET /api/temperature/alerts/{device_id}- Temperature alerts
Port: 3000 Purpose: React-based web interface for temperature monitoring
Key Features:
- Real-time temperature charts
- Multiple probe visualization
- Device selection and configuration
- Historical data viewing
- Responsive design for mobile and desktop
- Kubernetes 1.24+ with RBAC enabled
- Helm 3.0+ for package management
- ArgoCD for GitOps deployment (optional)
- Cilium CNI for advanced networking (recommended)
- PostgreSQL 13+ for device management
- InfluxDB 1.8+ for time-series data
- Redis 6.0+ for caching and streaming
- ThermoWorks Cloud API account and API key
- Home Assistant instance with Long-Lived Access Token
git clone https://github.com/lordmuffin/grill-stats.git
cd grill-stats# Copy and edit environment configuration
cp kubernetes/configmap.yaml.example kubernetes/configmap.yaml
# Update secrets with your API keys
kubectl apply -f kubernetes/configmap.yaml# Create namespace and RBAC
kubectl apply -k kustomize/overlays/dev
# Verify deployment
kubectl get pods -n grill-stats-dev# Create namespace and RBAC
kubectl apply -f kubernetes/namespace.yaml
# Deploy database services
kubectl apply -f kubernetes/postgresql.yaml
kubectl apply -f kubernetes/influxdb.yaml
kubectl apply -f kubernetes/redis.yaml# Deploy core services
kubectl apply -f kubernetes/device-service.yaml
kubectl apply -f kubernetes/temperature-service.yaml
# Verify deployment
kubectl get pods -n grill-stats# Port forward for local access
kubectl port-forward -n grill-stats svc/device-service 8080:8080
kubectl port-forward -n grill-stats svc/temperature-service 8081:8080
kubectl port-forward -n grill-stats svc/web-ui 3000:3000
# Test endpoints
curl http://localhost:8080/health
curl http://localhost:8081/healthTHERMOWORKS_CLIENT_ID: "your-thermoworks-client-id"
THERMOWORKS_CLIENT_SECRET: "your-thermoworks-client-secret"
THERMOWORKS_REDIRECT_URI: "http://localhost:8080/api/auth/thermoworks/callback"
HOMEASSISTANT_URL: "http://homeassistant:8123"
HOMEASSISTANT_TOKEN: "your-long-lived-access-token"
DB_USERNAME: "grill_monitor"
DB_PASSWORD: "secure-database-password"
REDIS_PASSWORD: "redis-authentication-password"
SECRET_KEY: "secure-random-secret-key-for-flask-sessions"# Sync intervals and thresholds
THERMOWORKS_POLLING_INTERVAL: "60" # 1 minute
TEMPERATURE_THRESHOLD_HIGH: "250" # Β°F
TEMPERATURE_THRESHOLD_LOW: "32" # Β°F
# Database connections
DB_HOST: "postgresql-service"
REDIS_HOST: "redis-service"
INFLUXDB_HOST: "influxdb-service"- CPU Requests: 100m per service
- Memory Requests: 128Mi-512Mi per service
- Storage: 10Gi for PostgreSQL, 20Gi for InfluxDB
- Replicas: 2 per service for high availability
The project includes a comprehensive mock data service for ThermoWorks integration, providing simulated device data for development and testing.
- Realistic simulation of ThermoWorks devices and temperature patterns
- Pre-configured devices with multiple probe types
- Dynamic temperature changes that follow cooking profiles
- Simulated cooking events like lid opening and temperature adjustments
View Mock Data Service Documentation
POST /api/devices/discover
Content-Type: application/json
Response:
{
"status": "success",
"data": {
"devices": [
{
"device_id": "tw_12345",
"name": "Grill Monitor",
"model": "Signals",
"firmware_version": "1.2.3",
"last_seen": "2024-01-01T00:00:00Z",
"battery_level": 85,
"signal_strength": 95,
"is_online": true
}
],
"count": 1
}
}GET /api/devices/{device_id}/health
Response:
{
"status": "success",
"data": {
"device_id": "tw_12345",
"health": {
"battery_level": 85,
"signal_strength": 95,
"status": "online",
"last_seen": "2024-01-01T12:00:00Z"
}
}
}GET /api/devices/{device_id}/temperature?probe_id=probe1
Response:
{
"status": "success",
"data": {
"readings": [
{
"device_id": "tw_12345",
"probe_id": "probe1",
"temperature": 225.5,
"unit": "F",
"timestamp": "2024-01-01T12:00:00Z",
"battery_level": 85,
"signal_strength": 95
}
],
"count": 1,
"source": "api"
}
}GET /api/devices/{device_id}/history?start_time=2024-01-01T00:00:00Z&end_time=2024-01-02T00:00:00Z&limit=100
Response:
{
"status": "success",
"data": {
"history": [
{
"device_id": "tw_12345",
"probe_id": "probe1",
"temperature": 225.5,
"unit": "F",
"timestamp": "2024-01-01T12:00:00Z"
}
],
"count": 24,
"query": {
"device_id": "tw_12345",
"start_time": "2024-01-01T00:00:00Z",
"end_time": "2024-01-02T00:00:00Z",
"limit": 100
}
}
}- Python 3.11 or higher
- Docker and Docker Compose
- Git
# Clone repository
git clone https://github.com/lordmuffin/grill-stats.git
cd grill-stats
# Setup Python virtual environment (using provided script)
./setup-venv.sh
# Activate the virtual environment
source venv/bin/activate
# Setup environment variables
cp .env.example .env
# Edit .env with your credentials
# Run the application
python app.py# Clone repository
git clone https://github.com/lordmuffin/grill-stats.git
cd grill-stats
# Setup environment variables
cp .env.example .env
# Edit .env with your credentials
# Run the monolithic application with all dependencies
docker-compose up --build
# To run microservices version instead
docker-compose --profile microservices up --buildYou need to configure the following environment variables in your .env file:
# ThermoWorks API
THERMOWORKS_API_KEY=your_api_key
THERMOWORKS_CLIENT_ID=your-client-id
THERMOWORKS_CLIENT_SECRET=your-client-secret
THERMOWORKS_REDIRECT_URI=http://localhost:8080/api/auth/thermoworks/callback
# Home Assistant
HOMEASSISTANT_URL=http://your-ha-instance:8123
HOMEASSISTANT_TOKEN=your-long-lived-token
The project is configured with several development tools:
- flake8: Code linting and style checking
- black: Code formatting
- isort: Import sorting
- mypy: Static type checking
You can run these tools with the following commands:
# Lint code
flake8 .
# Format code
black .
# Sort imports
isort .
# Type checking
mypy .# Device Service
cd services/device-service
python main.py
# Temperature Service
cd services/temperature-service
python main.py
# Web UI
cd services/web-ui
npm install
npm start# Apply all manifests
kubectl apply -f kubernetes/
# Apply with Kustomize for environment-specific configs
kubectl apply -k kustomize/overlays/dev # Development environment
kubectl apply -k kustomize/overlays/staging # Staging environment
kubectl apply -k kustomize/overlays/prod # Production environment
# Monitor deployment
kubectl get pods -n grill-stats -w
# View logs
kubectl logs -f deployment/device-service -n grill-stats# Create ArgoCD application
kubectl apply -f argocd/application.yaml
# Sync application
argocd app sync grill-statsgrill-stats/
βββ services/
β βββ device-service/
β β βββ main.py
β β βββ thermoworks_client.py
β β βββ requirements.txt
β βββ temperature-service/
β β βββ main.py
β β βββ temperature_manager.py
β β βββ requirements.txt
β βββ web-ui/
β β βββ src/
β β β βββ components/
β β β β βββ RealTimeChart.jsx
β β β β βββ TemperatureDashboard.jsx
β β β βββ utils/
β β β βββ api.js
β β βββ package.json
βββ kubernetes/
β βββ namespace.yaml
β βββ configmap.yaml
β βββ device-service.yaml
β βββ temperature-service.yaml
βββ kustomize/
β βββ base/
β β βββ namespace/
β β βββ databases/
β β βββ core-services/
β β βββ ingress/
β β βββ operators/
β βββ overlays/
β βββ dev/
β βββ staging/
β βββ prod/
βββ tests/
βββ docs/
βββ README.md
- Create service directory in
services/ - Implement service with health check endpoint
- Add Kubernetes manifests
- Update network policies
- Add to CI/CD pipeline
# Run unit tests
python -m pytest tests/
# Integration tests
kubectl apply -f tests/integration/
# Load testing
artillery run tests/load/temperature-service.ymlAll services expose /health endpoints for:
- Liveness Probes: Service is running
- Readiness Probes: Service can handle traffic
- Database Connectivity: Backend service health
- OpenTelemetry: Distributed tracing and metrics
- Prometheus: Metrics collection and alerting
- Grafana: Visualization and dashboards
- Structured Logging: JSON logs with correlation IDs
- Response Time: p95 < 100ms for current temperature
- Throughput: 1000+ requests/second per service
- Error Rate: < 0.1% for all endpoints
- Data Freshness: Temperature data < 5 minutes old
This platform replaces the original monolithic Flask application (app.py) with distributed microservices:
- Scalability: Independent scaling per service
- Reliability: Fault isolation and circuit breakers
- Maintainability: Clear service boundaries
- Performance: Specialized databases for each use case
- Observability: Distributed tracing and monitoring
- API Compatibility: Existing endpoints maintained
- Data Migration: Automatic migration scripts
- Gradual Rollout: Blue-green deployment support
- Fork the repository
- Create feature branch:
git checkout -b feature/new-service - Run tests:
make test - Submit pull request with clear description
We implement strict branch protection rules for quality control and stability:
- Requires 2 approved reviews before merging
- Enforces passing status checks: tests, builds, syntax checks
- Prevents force pushes
- Prevents branch deletion
- Restricts merging to maintainers team
- Requires 1 approved review before merging
- Enforces passing status checks: tests, builds
- Prevents force pushes
- Prevents branch deletion
- Allows merging by developers team
- Enforces passing tests before merging
- Allows development flexibility while ensuring code quality
- Python: PEP 8 with black formatting
- Docker: Multi-stage builds with security scanning
- Kubernetes: Resource limits and security contexts
- Documentation: OpenAPI specs for all APIs
This project is licensed under the MIT License - see the LICENSE file for details.
- Create issues for bug reports or feature requests
- Check existing issues before creating new ones
- Provide detailed reproduction steps
- Discussions for questions and ideas
- Contributions welcome for all skill levels
- Code review and mentoring available
- β User Authentication with login/logout functionality
- β Account security with failed login tracking and lockout protection
- β Route protection with login requirements
- β User-friendly dashboard interface
- β Device Management Service with OAuth2 ThermoWorks integration
- β Real-time temperature monitoring with Chart.js visualization
- β Kubernetes Kustomize configurations for multi-environment deployment
- β Detailed API documentation with OpenAPI/Swagger
- β Robust error handling and connection status tracking
- β Device Management Service with PostgreSQL
- β Temperature Data Service with InfluxDB + Redis
- β Kubernetes manifests with security policies
- β OpenTelemetry instrumentation
- β Multi-agent implementation framework
- π Home Assistant Integration Service
- π RFX Gateway support for direct probe connectivity
- β³ API Gateway with Kong/Nginx
- β³ Notification Service with multi-channel alerts
- β³ Data Processing Service with analytics
- β³ Mobile application with push notifications
Built with β€οΈ for the grilling community