AI-powered waste management and carbon tracking system with automatic model training and deployment.
# Install dependencies
make install
# Run API locally
make dev
# API available at http://localhost:8000
# Run full stack (API + MLflow + Database)
make compose
# API: http://localhost:8000
# MLflow: http://localhost:5000
# Docs: http://localhost:8000/docs# 1. Sign up at https://render.com
# 2. Connect GitHub repo
# 3. Add GitHub secret: RENDER_DEPLOY_HOOK
# 4. Push code
git push origin main
# ✨ Auto-deploys in ~10 minutes!Three ML Models in One API:
- 🎯 Vision Model (YOLO v8) - Detects waste objects in images
- ⚖️ Weight Estimator (sklearn) - Estimates waste weight from bounding boxes
- 🌱 Lifestyle Model (sklearn) - Predicts carbon emissions from user habits
latest_ecoguard/
├── app.py # FastAPI application
├── predictor.py # Model predictor class
├── Dockerfile # Container configuration
├── docker-compose.yml # Local development stack
├── render.yaml # Render deployment config
│
├── .github/workflows/
│ └── deploy-render.yml # Auto-deployment on push
│
├── mlops/ # ML utilities
│ ├── model_registry.py # MLflow integration
│ ├── monitoring.py # Metrics & monitoring
│ ├── train_pipeline.py # Model training
│ └── config.py # Configuration
│
├── tests/ # Test suites
│ ├── test_api.py # API tests
│ ├── test_load.py # Load testing
│ └── test_mlflow.py # MLflow tests
│
├── vision_model/ # YOLO model
├── weight_model/ # Weight estimator
├── lifestyle_model/ # Lifestyle model
│
└── Documentation:
├── RENDER_DEPLOYMENT_GUIDE.md # Render setup guide
├── RENDER_SECRETS_SETUP.md # GitHub secrets config
└── RENDER_QUICK_REFERENCE.md # Commands cheat sheet
GET /- API informationGET /health- Health checkGET /metrics- Prometheus metrics
POST /api/vision/detect- Detect waste objectsPOST /api/weight/estimate- Estimate weight from bboxPOST /api/carbon/calculate- Calculate carbon emissionsPOST /api/lifestyle/predict- Predict lifestyle emissionsWS /api/sensor/stream- Real-time sensor dataPOST /api/user/log-action- Log user actions
- Swagger UI:
/docs - ReDoc:
/redoc
make help # Show all commands
# Testing
make test # Run all tests
make test-fast # Run tests (fail fast)
make test-load # Load testing
# Code Quality
make lint # Linting & type checks
make format # Auto-format code
make clean # Clean artifacts
# Local Servers
make dev # Run API with auto-reload
make compose # Start full stack
make compose-down # Stop stack
make mlflow # Start MLflow UI
make logs # View API logs
# Docker
make docker # Build Docker image
make docker-run # Run container
make docker-stop # Stop container# Just push code - everything else is automatic!
git push origin main
# Triggers:
# 1. GitHub Actions runs tests
# 2. If passing, triggers Render webhook
# 3. Render auto-builds & deploys
# 4. GitHub verifies health endpoint
# Monitor at: https://dashboard.render.com- Read: RENDER_DEPLOYMENT_GUIDE.md
- Setup Secrets: RENDER_SECRETS_SETUP.md
- Commands Ref: RENDER_QUICK_REFERENCE.md
Create .env from .env.example:
cp .env.example .envKey variables:
ENVIRONMENT=production
LOG_LEVEL=INFO
SECRET_KEY=<secure-random-string>
CORS_ORIGINS=https://yourdomain.com
MLFLOW_TRACKING_URI=http://mlflow:5000
✅ Three ML Models - Vision, weight, lifestyle predictions ✅ Auto-Deployment - Push → Auto-test → Auto-deploy to Render ✅ Model Versioning - MLflow registry with champion tracking ✅ Monitoring - Prometheus metrics + dashboards ✅ Testing - Unit, integration, and load tests ✅ Health Checks - Automatic health monitoring ✅ API Documentation - Interactive Swagger UI ✅ Local Development - Docker Compose full stack
- Vision detection: ~200-400ms
- Weight estimation: ~50-100ms
- Lifestyle prediction: ~50-100ms
- Total latency: < 500ms per request
# Unit & Integration Tests
pytest tests/ -v --cov=.
# Load Testing (concurrent requests)
pytest tests/test_load.py -v
# View coverage report
open htmlcov/index.htmlmake compose
# MLflow: http://localhost:5000
# API: http://localhost:8000/docshttps://dashboard.render.com/services
View:
- Deployment status
- Real-time logs
- CPU/Memory metrics
- Request counts
Models can be retrained automatically each week. See mlops/train_pipeline.py
python mlops/train_pipeline.py# Check locally
make dev
# Check logs
make logs
# Verify requirements.txt has all dependencies
pip install -r requirements.txt# Test model imports
python -c "from predictor import ModelPredictor; p = ModelPredictor()"
# Check model files exist
ls models/
ls vision_model/
ls weight_model/
ls lifestyle_model/# Run with verbose output
pytest tests/ -vv
# Check for missing dependencies
pip install -r requirements-dev.txtDevelopment: Free (local or Render free tier) Production: $12/month (Render Starter plan)
Free tier may sleep if inactive. Starter plan guarantees uptime.
Git Repo
↓
GitHub Actions (Tests)
↓
Render Webhook Trigger
↓
Render Auto-Build
↓
Load Models
↓
✨ Live API
| File | Purpose |
|---|---|
app.py |
FastAPI server |
predictor.py |
Model predictor class |
Dockerfile |
Container image |
render.yaml |
Render config |
.github/workflows/deploy-render.yml |
Auto-deploy workflow |
mlops/model_registry.py |
MLflow integration |
mlops/monitoring.py |
Metrics & monitoring |
tests/test_api.py |
API tests |
- Setup: RENDER_DEPLOYMENT_GUIDE.md
- GitHub Secrets: RENDER_SECRETS_SETUP.md
- Quick Commands: RENDER_QUICK_REFERENCE.md
- API Docs: http://localhost:8000/docs (when running)
- PyTorch (YOLO v8)
- Scikit-learn
- MLflow
- FastAPI
- Uvicorn
- Pydantic
- Docker
- Render
- GitHub Actions
- Pytest
- Coverage
- Prometheus
- MLflow UI
| Link | Purpose |
|---|---|
make help |
Show all commands |
/docs |
Interactive API docs |
https://dashboard.render.com |
Deployment dashboard |
.github/workflows/deploy-render.yml |
Auto-deploy config |
render.yaml |
Service config |
- Check RENDER_QUICK_REFERENCE.md
- Review logs:
- Local:
make logs - Render: Dashboard → Logs
- Local:
- Test locally first:
make devcurl http://localhost:8000/health
- Check GitHub Actions:
- Create feature branch
- Make changes
- Run tests:
make test - Format code:
make format - Push to branch
- Create Pull Request
Tests + linting must pass before deployment.
MIT License - see LICENSE file
✅ Production Ready
- Auto-deployment working
- All tests passing
- Models loading correctly
- Monitoring in place
Ready to deploy? → Push to main and watch it go live! 🚀
git push origin main
# ✨ Auto-deploys in ~10 minutes
# Monitor at https://dashboard.render.com