An implementation-complete, self-healing MLOps platform designed to monitor production models, detect data drift, leverage LLMs to formulate retraining strategies, evaluate candidate models under strict policy guardrails, and promote them automatically.
The platform runs a continuous self-healing loop:
[ Inference Traffic ] ──► [ Inference Logs ]
│
▼
[ Target Registry ] [ Monitoring Scheduler ]
│ │
▼ (computes drift) ▼
[ LLM Strategy Engine ] ◄── [ Drift Alarm Signal ]
│
▼ (formulates retraining configuration)
[ Policy Guardrails ] ──► [ Automation Executor ]
│ │
▼ (if approved) ▼
[ Training Runner ] [ Model Evaluator ] (compares candidates)
│ │
└─────────────────────────┴──► [ Auto-Promotion / Versioning ]
- Dataset Registry: Stores dataset metadata, profiling metrics, and baseline statistics.
- Model Registry: Manages model endpoints, versions, lineage (
parent_version), and operational status (active,staging). - Inference Layer: Serves model endpoints with in-memory TTL caching and logs input/prediction features to PostgreSQL.
- Monitoring Engine: Triggers every 5 minutes to calculate drift scores (PSI and feature shift) and alert on threshold violations.
- LLM Decision Engine: Interfaces with Ollama (
llama3) to analyze drift and formulate structured retraining strategies. - Policy & Guardrails: Evaluates decisions against a 7-checkpoint policy (confidences, cost caps, GPU allocations, time freeze windows, retraining rate limits, production blocks, and severity filters).
- Training Runner & Orchestrator: In-process or Docker-based training pipelines supporting HPO (Optuna), data rebalancing, feature selection, threshold optimization, and ensembling. Fully supports 13 algorithms out-of-the-box:
- Classification: RandomForest, GradientBoosting, AdaBoost, ExtraTrees, LogisticRegression, DecisionTree, SVC, KNN, XGBoost, and LightGBM.
- Regression: LinearRegression, Ridge, Lasso, and regression-only variants of the above tree/ensemble models.
- Model Evaluator: Compares newly trained candidate model metrics against the current active baseline to determine promotion/rollback safety.
- Observability: Exposes real-time Prometheus metrics at
/metrics(decisions, violations, latency histograms, and counts). - Frontend: React-based dashboard visualizing models, training runs, monitoring metrics, drift trends, and policy approvals.
This repository is intended as a demonstration of:
- Designing and implementing a closed-loop, drift-aware MLOps architecture that covers dataset/model registries, monitoring, retraining, and promotion.
- Using an LLM-governed decision loop with explicit policy guardrails (cost, severity, rate limits, freeze windows) to safely automate retraining and deployment.
- Building an end-to-end ML system with FastAPI, PostgreSQL, MinIO, Ollama, and a React dashboard, all orchestrated via Docker Compose.
- Implementing production-style concerns: model versioning, evaluation against baselines, observability with Prometheus, and verification scripts for the training pipeline.
Status: Prototype but fully runnable end-to-end on a single machine using Docker Compose. Intended as a reference architecture / demo, not a hardened production deployment.
- Docker Desktop
- Node.js v20+ (only if running frontend locally without Docker)
- Python 3.12+ (only if running backend locally without Docker)
The easiest way to run the entire system is via Docker Compose. This starts PostgreSQL, MinIO, Ollama (with llama3 automatically pre-pulled), the FastAPI Backend, and the React Frontend.
-
Clone the Repository:
git clone https://github.com/your-username/autonomous-ml-platform.git cd autonomous-ml-platform -
Launch the Services:
docker compose up --build
-
Access the Applications:
- React Dashboard: http://localhost:3000
- FastAPI Swagger Docs: http://localhost:8000/docs
- MinIO Object Console: http://localhost:9001 (User/Password:
minioadmin/minioadmin) - Prometheus Metrics: http://localhost:8000/metrics
If you wish to run the backend and frontend separately for development:
- Navigate to the backend directory:
cd backend - Create and activate a Python virtual environment:
python -m venv venv # On Windows: venv\Scripts\activate # On Linux/macOS: source venv/bin/activate
- Install the pinned dependencies:
pip install -r requirements.txt
- Copy the environment variables template and configure it:
cp .env.example .env
- Run the FastAPI application:
uvicorn app.main:app --reload --host 127.0.0.1 --port 8000
- Navigate to the frontend directory:
cd ../automl-frontend - Install Node modules:
npm install
- Start the Vite development server:
Open http://localhost:5173 in your browser.
npm run dev
To test the self-healing retraining loop:
- Go to the Dataset tab in the dashboard.
- Upload the sample dataset provided in
data/loan_approval_test.csv. - The platform will automatically profile the dataset, calculate baseline distributions, and save it in MinIO.
- Go to the Models tab and register a new model (e.g., name
loan_predictor). - Select your desired algorithm (e.g.,
LightGBMorRandomForestClassifier) from the unified algorithm list. - Upon registration, the backend automatically triggers baseline training (v1) on the uploaded dataset, computes actual performance metrics, and sets the model status to Active.
- Run the traffic simulator script to send normal requests to the active model endpoint:
(This starts healthy, then injects out-of-distribution high-risk candidates to trigger feature drift).
python scripts/simulate_traffic.py --duration 120 --rps 5.0 --drift-start 0.3
- The Monitoring Engine scheduler (runs every 5 mins) will pick up the drifted logs.
- The drift score will exceed the threshold (
0.2). - The LLM Decision Engine generates a retraining configuration.
- The Policy Guardrails checks the confidence and daily costs. If approved, the Automation Executor starts retraining.
- Once a candidate wins (e.g., v2 outperforms the degraded baseline), it is promoted to Active production status automatically!
A comprehensive verification suite is included to validate the core ML training and tuning pipeline in isolation (bypassing the database & MinIO):
- Run Verification:
$env:DATABASE_URL="postgresql+asyncpg://dummy:dummy@localhost:5432/dummy"; $env:MINIO_ENDPOINT="localhost:9000"; $env:MINIO_ACCESS_KEY="dummy"; $env:MINIO_SECRET_KEY="dummy"; $env:MINIO_BUCKET="dummy"; $env:PYTHONIOENCODING="utf-8"; .\venv\Scripts\python.exe verify_algorithms.py
- Coverage: Runs 75 test cases verifying case-insensitive alias mapping, training of all 10 classifiers and 12 regressors, model selector leaderboards, Optuna trial objectives, and parameter isolation during fallback states.