Skip to content

Repository files navigation

NeuralOps

NeuralOps

Autonomous AIOps platform that monitors microservices, detects anomalies with deep learning, and self-heals infrastructure β€” without human intervention.

Python TypeScript FastAPI PyTorch Kubernetes Kafka Terraform License: MIT

Overview Β· Architecture Β· Tech Stack Β· Quick Start Β· ML Model Β· Kubernetes Β· CI/CD


πŸ“Œ Overview

Modern distributed systems run hundreds of microservices. When one degrades, a DevOps engineer gets paged at 2 AM, manually investigates logs, and applies a fix. This is reactive, slow, and doesn't scale.

NeuralOps implements the full AIOps lifecycle:

Stage What Happens
πŸ”­ Observe 5 FastAPI microservices emit Prometheus metrics
🌊 Stream Prometheus β†’ Kafka bridge delivers a real-time metrics stream
🧠 Detect An LSTM Autoencoder learns normal behaviour and flags deviations
πŸ”” Alert Anomaly scores are published to a Kafka topic and the dashboard
πŸ”§ Remediate A rule-based engine restarts, scales, or rolls back affected pods
πŸ“Š Track MLflow logs every experiment; Grafana visualises everything
πŸ”„ Adapt Evidently AI detects data drift daily and triggers auto-retraining

Every component in this project mirrors what Google, Netflix, and Datadog run at scale.


πŸ— Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          NeuralOps Pipeline                          β”‚
β”‚                                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  /metrics  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  exporter  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  5Γ— FastAPI  │──────────▢│ Prometheus │───────────▢│  Kafka  β”‚  β”‚
β”‚  β”‚  Microsvcs   β”‚           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β”‚ Stream  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                     β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜  β”‚
β”‚                                                            β”‚        β”‚
β”‚                                                     metrics-stream  β”‚
β”‚                                                            β”‚        β”‚
β”‚                                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”‚
β”‚                                                    β”‚     LSTM     β”‚ β”‚
β”‚                                                    β”‚ Autoencoder  β”‚ β”‚
β”‚                                                    β”‚  (PyTorch)   β”‚ β”‚
β”‚                                                    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                            β”‚        β”‚
β”‚                                                     anomaly-alerts  β”‚
β”‚                                                            β”‚        β”‚
β”‚                                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”‚
β”‚                                                    β”‚ Remediation  β”‚ β”‚
β”‚                                                    β”‚   Engine     β”‚ β”‚
β”‚                                                    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                            β”‚        β”‚
β”‚                                           restart / scale / rollbackβ”‚
β”‚                                                            β”‚        β”‚
β”‚                                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”‚
β”‚                                                    β”‚  Kubernetes  β”‚ β”‚
β”‚                                                    β”‚   Cluster    β”‚ β”‚
β”‚                                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  Evidently Drift Monitor  (daily CronJob)                    β”‚   β”‚
β”‚  β”‚  training dist. vs production β†’ auto-retrain if drifted      β”‚   β”‚
β”‚  β”‚  new model promoted only if F1 improves β†’ ArgoCD deploys     β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ›  Tech Stack

Technology Role Design Rationale
FastAPI Microservices Async-first, auto-generated OpenAPI docs, Pydantic validation β€” faster than Flask for I/O-bound services
Prometheus Metrics collection Pull-based scraping, native Kubernetes integration, powerful PromQL
Apache Kafka Metrics streaming Durable, replayable event log β€” decouples producers from consumers in a way SQS/RabbitMQ cannot
PyTorch LSTM Autoencoder Anomaly detection Learns temporal patterns across sliding windows; simple static thresholds miss gradual degradation
MLflow Experiment tracking & model registry Open-source, self-hostable, integrates natively with PyTorch
Evidently AI Data drift detection Purpose-built for ML monitoring with built-in statistical tests
Kubernetes Orchestration Industry standard; enables self-healing via native pod restart and HPA
Terraform Infrastructure as Code Declarative, state-managed provisioning with a rich provider ecosystem
ArgoCD GitOps deployments Git as the single source of truth, automatic sync, full audit trail
GitHub Actions CI/CD Native to GitHub β€” no separate server to maintain
Grafana Observability dashboards Best-in-class time-series visualisation

Languages: Python 60.7% Β· TypeScript 20.2% Β· HCL 7.6% Β· JavaScript 4.2% Β· Makefile 2.8% Β· CSS 2.3%


πŸ“ Project Structure

neuralops/
β”œβ”€β”€ frontend/                     # React + TypeScript observability dashboard
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/           # ServiceCard, LiveChart, AnomalyScorePanel, …
β”‚   β”‚   β”œβ”€β”€ App.tsx               # Main app β€” 4 tabs
β”‚   β”‚   β”œβ”€β”€ api.ts                # API client (auto-falls back to mock data)
β”‚   β”‚   β”œβ”€β”€ mockData.ts           # Offline demo data
β”‚   β”‚   └── types.ts              # Shared TypeScript types
β”‚   β”œβ”€β”€ api-gateway/
β”‚   β”‚   └── main.py               # FastAPI gateway β€” aggregates Prometheus, MLflow, audit logs
β”‚   β”œβ”€β”€ Dockerfile                # Multi-stage: build β†’ nginx
β”‚   └── nginx.conf
β”‚
β”œβ”€β”€ services/                     # 5Γ— FastAPI microservices + shared base
β”‚   β”œβ”€β”€ base_service.py           # Shared Prometheus metrics + chaos mode
β”‚   β”œβ”€β”€ user-service/
β”‚   β”œβ”€β”€ order-service/
β”‚   β”œβ”€β”€ payment-service/          # Intentionally higher latency (chaos demo)
β”‚   β”œβ”€β”€ inventory-service/
β”‚   β”œβ”€β”€ notification-service/
β”‚   └── Dockerfile.template
β”‚
β”œβ”€β”€ ml/
β”‚   β”œβ”€β”€ model.py                  # LSTM Autoencoder (PyTorch)
β”‚   β”œβ”€β”€ data_generator.py         # Synthetic training data
β”‚   β”œβ”€β”€ train.py                  # Training loop + MLflow experiment logging
β”‚   β”œβ”€β”€ inference_server.py       # FastAPI /predict endpoint
β”‚   └── kafka_consumer.py         # Reads metrics-stream, publishes anomaly alerts
β”‚
β”œβ”€β”€ streaming/
β”‚   β”œβ”€β”€ metrics_exporter.py       # Prometheus β†’ Kafka bridge
β”‚   └── consumer_debug.py         # Debug: print all Kafka messages
β”‚
β”œβ”€β”€ remediation/
β”‚   └── engine.py                 # Rule-based Kubernetes auto-remediation
β”‚
β”œβ”€β”€ drift/
β”‚   β”œβ”€β”€ drift_detector.py         # Evidently drift reports + retrain trigger
β”‚   └── retrain.py                # Automated retraining pipeline
β”‚
β”œβ”€β”€ infra/
β”‚   β”œβ”€β”€ terraform/                # EKS, VPC, S3, Kafka, Prometheus, ArgoCD
β”‚   β”œβ”€β”€ helm/neuralops/           # Helm chart for all components
β”‚   └── argocd/                   # ArgoCD Application manifests
β”‚
β”œβ”€β”€ monitoring/
β”‚   β”œβ”€β”€ prometheus/prometheus.yml
β”‚   └── grafana/dashboards/neuralops-overview.json
β”‚
β”œβ”€β”€ .github/workflows/
β”‚   β”œβ”€β”€ ci.yml                    # PR: lint + test + build
β”‚   └── cd.yml                    # main: build β†’ push β†’ update Helm values
β”‚
β”œβ”€β”€ docker-compose.full.yml       # Full local stack
β”œβ”€β”€ Makefile                      # Convenience targets
└── .env.example

⚑ Quick Start

Prerequisites


1 Β· Start the full stack

git clone https://github.com/Aashish-Chandr/neuralops.git
cd neuralops
cp .env.example .env          # edit as needed
docker-compose -f docker-compose.full.yml up --build

Once running, the following endpoints are available:

Service URL
πŸ–₯ Frontend Dashboard http://localhost:3001
πŸ”€ API Gateway (docs) http://localhost:8090/docs
πŸ‘€ User Service http://localhost:8001/docs
πŸ“¦ Order Service http://localhost:8002/docs
πŸ’³ Payment Service http://localhost:8003/docs
πŸ—„ Inventory Service http://localhost:8004/docs
πŸ”” Notification Service http://localhost:8005/docs
πŸ“ˆ Prometheus http://localhost:9090
πŸ“Š Grafana http://localhost:3000 (admin / neuralops-admin)
πŸ§ͺ MLflow http://localhost:5000
πŸ€– Inference Server http://localhost:8080/docs

2 Β· Frontend dev mode (hot reload)

cd frontend
npm install
npm run dev        # http://localhost:3001

The dashboard operates in demo mode (mock data) when the backend is offline and automatically switches to live data when services are up.


3 Β· Train the anomaly detection model

cd ml
pip install -r requirements.txt
python train.py --epochs 50 --hidden 64 --latent 16

Results are logged to MLflow at http://localhost:5000.


4 Β· Trigger chaos mode

# Inject chaos into the payment service
CHAOS_PAYMENT=true docker-compose -f docker-compose.full.yml up payment-service

Watch the Grafana dashboard β€” anomaly scores will climb and the remediation engine will respond automatically.


5 Β· Inspect the Kafka pipeline

cd streaming
pip install -r requirements.txt
python consumer_debug.py      # prints all messages from metrics-stream

🧠 ML Model

LSTM Autoencoder

The model is trained only on normal operating data. At inference, a high reconstruction error signals an anomaly.

Input  β†’  (batch, 60, 5)        60-step sliding window Γ— 5 features
                                 [cpu%, memory%, latency_p99_ms, error_rate%, rps]
         β”‚
         β–Ό
Encoder  β†’  2-layer LSTM  β†’  Linear projection  β†’  16-dim latent vector
         β”‚
         β–Ό
Decoder  β†’  Repeat latent  β†’  2-layer LSTM  β†’  Linear projection  β†’  Reconstruction
         β”‚
         β–Ό
Loss     β†’  MSE reconstruction error

Anomaly threshold: 95th percentile of reconstruction errors observed on the training set. Anything above this at inference time is flagged as anomalous.

MLflow tracking: Every training run logs hyperparameters, train/val loss curves, the computed threshold, and precision/recall/F1 scores. The best model is registered under neuralops-lstm-autoencoder in the Model Registry.


πŸ”§ Remediation Engine

When an anomaly alert lands, the engine applies a rule-based decision tree and acts on Kubernetes:

Observed Pattern Automated Action
High error rate + low RPS Restart pod β€” suspected crash loop
High CPU + high memory + high latency Scale up replicas β€” suspected overload
High errors + normal latency Rollback deployment β€” suspected bad release

After each action the engine waits 5 minutes, re-evaluates service health, and if the issue persists it escalates via Slack webhook.


πŸ“‰ Drift Detection & Auto-Retraining

A Kubernetes CronJob runs Evidently AI daily:

  1. Compares the training-time feature distribution against the last 24 h of production metrics.
  2. If > 30 % of features show statistically significant drift, the retraining pipeline is triggered.
  3. The newly trained model is promoted to Production in the MLflow registry only if its F1 score improves over the current champion.
  4. ArgoCD detects the updated model reference in helm/values.yaml and deploys automatically.

☸️ Kubernetes Deployment

Local β€” Minikube

minikube start --memory=8192 --cpus=4
 
# Install ArgoCD
kubectl create namespace argocd
kubectl apply -n argocd \
  -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
 
# Deploy NeuralOps
helm install neuralops infra/helm/neuralops/ \
  -n neuralops --create-namespace
 
# Hand off to GitOps
kubectl apply -f infra/argocd/app-neuralops.yaml

Cloud β€” AWS EKS

cd infra/terraform
terraform init
terraform plan  -var="environment=prod"
terraform apply

Terraform provisions: EKS cluster Β· VPC Β· S3 (artifact storage) Β· MSK (Kafka) Β· Prometheus Β· ArgoCD.


πŸ”„ CI/CD Pipeline

Pull Request opened
  └─▢  flake8 lint  β†’  pytest  β†’  docker build (no push)
 
Merge to main
  └─▢  Build & push images to GHCR  (tagged with commit SHA)
         └─▢  Update image tags in helm/values.yaml
                └─▢  ArgoCD detects diff  β†’  auto-deploys to cluster

βš™οΈ Environment Variables

Variable Default Description
CHAOS_MODE false Enable fault injection in microservices
KAFKA_BOOTSTRAP_SERVERS localhost:9092 Kafka broker address
PROMETHEUS_URL http://localhost:9090 Prometheus API base URL
MLFLOW_TRACKING_URI http://localhost:5000 MLflow tracking server URL
DRIFT_THRESHOLD 0.3 Fraction of drifted features required to trigger retraining
VERIFY_WAIT_SECONDS 300 Seconds to wait before verifying post-remediation health
SLACK_WEBHOOK_URL (empty) Slack incoming webhook URL for escalation alerts

Copy .env.example to .env and override as needed before starting the stack.


πŸ—Ί Roadmap

  • Add LLM-assisted root-cause explanation surfaced in the dashboard
  • Extend LSTM model to multivariate cross-service correlations
  • Support GKE and AKS alongside EKS in Terraform
  • Prometheus Alertmanager integration as a secondary alert channel
  • Demo video walkthrough

🀝 Contributing

Contributions, issues, and feature requests are welcome!

# Fork the repo, then:
git checkout -b feature/my-feature
git commit -m "feat: add my feature"
git push origin feature/my-feature
# Open a Pull Request

Please ensure flake8 passes and relevant tests are added before opening a PR.


πŸ“„ License

Distributed under the MIT License. See LICENSE for details.


Built by Aashish Chandr · Give it a ⭐ if you found it useful!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages