This document provides a practical, streamlined guide for running the complete recommendation system in production, including initial setup, data collection, training, container deployment, monitoring, and provenance tracking.
git clone <repo-url>
cd group-project-f25-deploy-hard/movie_recommendation_datapython3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python setup.pyThis creates necessary directories, configuration files, and prepares the project structure.
The system trains on event streams from Kafka. You must open an SSH tunnel first.
ssh -L 9092:localhost:9092 tunnel@128.2.220.241 -Npython data_processing/data_collection_system.py --duration-hours 0.05This pulls recommendation events, watches, and ratings into:
data/collected/movie_data.db
This SQLite file becomes your training dataset.
python -m pipeline.cli run-all --evaluateThis executes:
- Preprocessing
- Matrix Factorization training
- Data drift check
- Offline evaluation (RMSE, MAE, Precision@K)
models/matrix_factorization_model.pkl
models/baseline_metrics.json
reports/eval_<timestamp>.json
docker-compose builddocker-compose up -d| Component | Port | Description |
|---|---|---|
| Backend v1 | 8082 | Model inference API |
| Backend v2 | 8082 | A/B testing alternate model |
| Load Balancer | 8082 | Splits traffic between v1/v2 |
| Prometheus | 9090 | Metrics scraping backend |
| Grafana | 3000 | Monitoring UI |
| Telemetry Monitor | 9100 | Drift + quality metrics |
Backend containers load models directly from:
./models:/app/models
Grafana runs automatically at:
http://<vm-ip>:3000
A dashboard monitors:
- Availability via
telemetry_recommendation_status_total - Latency via
lb_request_latency_seconds_bucket - Online accuracy via watch-hit and rating-hit metrics
- Data drift via telemetry_drift_overall_score and drift recommendation code
- Traffic split for A/B testing
Prometheus scrapes rules from:
prometheus.yml
telemetry.rules.yml
Alerts trigger when:
- Availability drops below threshold
- Drift score exceeds allowed bounds
- Error rate increases abnormally
Every component logs the model_id used:
serve.pyexposes it in/healthand inX-Model-IDresponse headers- Telemetry consumer stores
model_idin every event - Retraining pipeline creates versioned artifacts under:
models/releases/<model_id>/ - Model promotions update:
models/current_model.txt
This ensures every prediction, evaluation, and metric is traceable to:
- Model version
- Dataset version
- Pipeline version
Run retraining:
python scripts/run_retrain.pyBackend automatically reloads models through:
POST /admin/reload-model
or via retraining script automation.
docker-compose down
docker-compose up -d --buildBackend containers stay lightweight because only model artifacts, not training data, are mounted in.
pytest tests/ --cov --cov-report=termExpect: ~73 passing tests and ~45% overall coverage (≥85% for core models).
curl http://localhost:8082/health
curl "http://localhost:8082/recommend/12345"This README serves as the authoritative guide for running, deploying, monitoring, and retraining your production recommendation system end-to-end.