A scalable equipment failure prediction system built with Dask, FastAPI, and Streamlit.
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Streamlit │────▶│ FastAPI │────▶│ Dask Cluster│
│ Dashboard │ │ /predict │ │ (4 workers) │
│ :8501 │ │ /monitor │ │ :8787 │
└──────────────┘ └──────┬───────┘ └──────────────┘
│
┌──────▼───────┐
│ src/ │
│ data/ │ Core business logic
│ models/ │ (preprocessing,
│ monitoring/ │ training, alerting)
│ optimization│
└──────────────┘
micromamba create -n bigdata -f environment.yml -y
micromamba activate bigdata
pip install fastapi uvicorn[standard]kaggle datasets download -d shashanknecrothapa/machine-failure-predictions -p data/raw/ --unzippython main.pyThis runs the full pipeline: load → preprocess → feature engineering → train → evaluate → save.
make serve
# or: uvicorn api.server:app --host 0.0.0.0 --port 8000make dashboard
# or: streamlit run dashboard/app.py --server.port 8501make stream
# or: python scripts/simulate_stream.pycd deployment
cp .env.example .env
docker compose up --build -dServices:
- API: http://localhost:8000 (docs at /docs)
- Dashboard: http://localhost:8501
- Dask Dashboard: http://localhost:8787
bigdata/
├── src/ # Core business logic (BACKBONE)
│ ├── config.py # Configuration loader
│ ├── data/
│ │ ├── loader.py # Dask data loading
│ │ ├── preprocessing.py # Cleaning, encoding, scaling
│ │ └── feature_engineering.py# Feature extraction
│ ├── models/
│ │ ├── trainer.py # Model training pipeline
│ │ ├── evaluator.py # Metrics & visualization
│ │ └── registry.py # Model save/load
│ ├── monitoring/
│ │ ├── stream.py # Streaming simulation
│ │ └── alerting.py # Alert management
│ └── optimization/ # Dask performance tuning
├── api/ # FastAPI server
│ ├── server.py # App entrypoint
│ ├── schemas.py # Request/response models
│ └── routes/ # Endpoint handlers
├── dashboard/
│ └── app.py # Streamlit UI
├── scripts/ # CLI tools
├── config/config.yaml # All settings
├── deployment/ # Docker configs
├── main.py # E2E pipeline orchestrator
├── Makefile # Convenience commands
└── requirements.txt
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Health check |
| POST | /predict |
Single prediction |
| POST | /predict/batch |
Batch prediction |
| GET | /monitor/status |
Stream status |
| POST | /monitor/start |
Start streaming |
| POST | /monitor/stop |
Stop streaming |
| WS | /ws/stream |
Live WebSocket feed |
All settings in config/config.yaml. Override with environment variables:
DASK_N_WORKERS— number of Dask workersDASK_MEMORY_LIMIT— per-worker memory limitAPI_PORT— FastAPI portAPI_URL— API URL for dashboard