- Docker Desktop for Windows
- PowerShell 5.1 or higher
- 8GB RAM minimum (16GB recommended)
- 20GB free disk space
- Clone the repository:
git clone https://github.com/yassnemo/iot-data-and-anomaly-detection-ml-system.git
cd iot-data-and-anomaly-detection-ml-system- Enable PowerShell script execution (if needed):
# Check current policy
Get-ExecutionPolicy
# If Restricted, set to RemoteSigned for current user
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser- Run setup:
.\scripts\setup.ps1Execute the end-to-end demo:
.\scripts\run_demo.ps1This will:
- Start all services (Kafka, Spark, MinIO, TF-Serving, Prometheus, Grafana)
- Generate synthetic training data
- Train the LSTM Autoencoder model
- Deploy the model to TF-Serving
- Start the Spark streaming job
- Start the producer (1000 sensors)
- Show detected anomalies
docker-compose up -ddocker-compose exec trainer python src/training/train_model.pydocker-compose exec spark-master spark-submit `
--packages org.apache.spark:spark-sql-kafka-0-10_2.12:3.4.1 `
--master spark://spark-master:7077 `
/app/src/streaming/spark_streaming.pydocker-compose exec producer python src/producer/kafka_producer.py --num-sensors 10000docker-compose exec kafka kafka-console-consumer.sh `
--bootstrap-server localhost:9092 `
--topic anomalies| Service | URL | Credentials |
|---|---|---|
| Grafana | http://localhost:3000 | admin/admin |
| Prometheus | http://localhost:9090 | - |
| MinIO Console | http://localhost:9001 | minioadmin/minioadmin |
| Spark UI | http://localhost:8080 | - |
# Unit tests only
docker-compose run --rm test python -m pytest tests/ -v
# Include integration tests
docker-compose run --rm test python -m pytest tests/ -v --integrationdocker-compose exec kafka kafka-topics.sh --alter `
--bootstrap-server localhost:9092 `
--topic raw-readings `
--partitions 20docker-compose up -d --scale spark-worker=3docker-compose exec producer python src/producer/kafka_producer.py --num-sensors 20000If you get "scripts is disabled on this system" error:
# Option 1: Run with bypass (one-time)
PowerShell -ExecutionPolicy Bypass -File .\scripts\setup.ps1
# Option 2: Change policy for current user (permanent)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserdocker-compose logs -f [service-name]docker-compose restart [service-name]docker-compose down -v
.\scripts\setup.ps1See README.md for detailed tuning guide to achieve 95% detection accuracy.