A distributed, AI-powered fraud detection system with intelligent operational management.
ATLAS implements a fraud detection platform that combines real-time transaction processing, AI-assisted operational management, and automated scaling capabilities. The system is designed for high-reliability environments with strict safety and observability requirements.
- API Gateway: FastAPI-based ingress point with rate limiting and metrics
- Kafka Message Broker: Event-driven communication backbone
- Transaction Client: Transaction generator for testing
- Evaluation System: Kafka consumer with fraud detection logic
- PostgreSQL Database: Transaction storage and analysis
- Prometheus Monitoring: Metrics collection and alerting
- Scaling Agent: Centralized autoscaling orchestration for Kubernetes and MCP/HTTP operator workflows
- Operational Safety: Human-in-the-loop decision making
- Metrics-Driven Actions: Automated responses to system conditions
- MCP Tooling: Local stdio-based tool server for Prometheus and Kubernetes operations
- Transaction Ingestion: Real-time transaction processing via REST API
- Event Streaming: Kafka-based decoupling for scalability
- Fraud Analysis: AI-powered evaluation with historical context
- Database Storage: PostgreSQL for transaction persistence
- Auto-Scaling: Feed-forward orchestration scales the full processing pipeline from a global ingress load indicator
- Load Monitoring: Real-time metrics from Prometheus
- Safety Boundaries: Configurable thresholds with human oversight
- Operational Visibility: Comprehensive logging and alerting
flowchart LR
Client[Client]
APIGateway[API Gateway]
Kafka
Enrichment[1. Enrichment System]
Scoring[2. Scoring System]
Notification[3. Notification System]
Redis[Redis]
Postgres[PostgreSQL]
Client -->|transaction POST| APIGateway
APIGateway -->|raw-transactions| Kafka
Kafka --> Enrichment
Enrichment -->|enriched-transactions| Kafka
Kafka --> Scoring
Scoring -->|scored-transactions| Kafka
Scoring --> Redis
Scoring --> Notification
Kafka --> Postgres
Notification -.->|notifications| Client
classDef infra fill:#111827,stroke:#9ca3af,color:#e5e7eb;
class Kafka,Postgres,Redis infra;
API Gateway (gateway/gateway.py)
- FastAPI-based entry point exposing
/api/v1/transactions(POST) - Health probes:
/health/live(liveness),/health/ready(readiness with Kafka check) - Prometheus metrics exposed on
/metrics - Rate limiting and graceful degradation: Readiness probe holds traffic until Kafka is ready
- Exponential backoff retry logic for Kafka connection
1. Enrichment System (enrichment-system/enrichment_system.py)
- Consumes JSON from
raw-transactionstopic - Performs GeoIP localization using MaxMind GeoLite2 database (
FastIPLocator) - Extracts payment details, user context, and transaction metadata
- Produces enriched payloads to
enriched-transactionstopic - Health probes:
localhost:8080/healthandlocalhost:8080/ready
2. Scoring System (scoring-system/scoring.py)
- Consumes JSON from
enriched-transactionstopic - Uses Confluent Schema Registry for Avro serialization
- Maintains Redis-backed state for user risk history and transaction patterns
- Risk evaluation engine computes fraud probability and assigns risk levels
- Produces Avro-serialized records to
scored-transactionstopic - Health probes:
localhost:8080/healthandlocalhost:8080/ready
3. Notification System (notification-system/notification_broker.py)
- Consumes Avro-serialized messages from
scored-transactionstopic - Defensive decoding: Attempts Avro deserialization, falls back to UTF-8 with replacement for corrupted bytes
- Publishes notifications to
transaction-notificationstopic for downstream consumers - Graceful handling of encoding mismatches and mixed-format messages
Data Storage
- PostgreSQL: Persists transaction history via Kafka Connect sink (JDBC connector)
- Redis: Maintains in-memory state for scoring engine (user profiles, pattern cache)
- Kafka: Durable event log for transaction pipeline (retention configurable)
| Topic | Producer | Consumer(s) | Format | Retention |
|---|---|---|---|---|
raw-transactions |
API Gateway | Enrichment System | JSON | 7 days |
enriched-transactions |
Enrichment System | Scoring System | JSON | 7 days |
scored-transactions |
Scoring System | Notification System, Kafka Connect Sink | Avro | 7 days |
transaction-notifications |
Notification System | Client subscribers | JSON | 3 days |
Redis (atlas-redis)
- State management for scoring engine
- User risk profiles and historical patterns
- Connection pooling and timeouts configured
PostgreSQL (atlas-postgres)
- Transaction history storage
- Indexed on
transaction_id,user_id,timestamp - Initialized with schema from
postgres/init.sql - Credentials managed via Kubernetes secrets
Schema Registry (schema-registry)
- Avro schema versioning and validation
- Used by scoring system for serialization
- Used by notification system for deserialization
Prometheus Metrics
- API Gateway: HTTP request rate, latency, error rates (via
prometheus-fastapi-instrumentator) - Scaling Agent: Deployment replica counts, RPS measurements
- All services: Kubernetes pod metrics (CPU, memory, restarts)
Alert Rules (k8s/plt-layer/prometheus-rules.yaml)
HighErrorRate: Error rate > 5% for 2 minutes (critical)HighLatency: p90 latency > 2s for 2 minutes (warning)CPUSaturation: CPU usage > 85% of limit (warning)PodCrashLooping: Pod restarted > 2.5x in 3 minutes (critical)- All alerts trigger with
trigger: agent_srelabel for Guardian routing
Health Probes Pattern
- Liveness (
/health/live): Always returns 200; indicates pod is alive - Readiness (
/health/ready): Returns 503 if critical dependencies (Kafka, PostgreSQL) are unavailable; gates traffic admission
Each microservice has an HPA configured with CPU-based scaling:
api-gateway: 1–2 replicas, 60% CPU targetenrichment-system: 1–2 replicas, 60% CPU targetscoring-system: 1–2 replicas, 60% CPU targetnotification-system: 1–2 replicas, 60% CPU target
Scaling behaviors:
- Scale-up: Immediate, up to 100% per minute
- Scale-down: 120-second stabilization window to prevent flapping
ClusterIP Services
api-gateway:8000- REST endpoint for transaction ingestionenrichment-system:8080- Health probes (internal)scoring-system:8080- Health probes (internal)notification-system:8080- Health probes (internal)atlas-kafka-broker:9092- Kafka bootstrap serversatlas-redis-master:6379- Redis state storeatlas-postgres-postgresql:5432- PostgreSQL databaseschema-registry:8081- Confluent Schema Registry
Ingress Routes (NGINX Controller required)
http://fraud-api.127.0.0.1.nip.io→api-gateway:8000(transaction API)http://locust.127.0.0.1.nip.io→locust-master-ui:8089(load testing UI)http://guardian-report.127.0.0.1.nip.io→atlas-guardian-dashboard-service:8501(incident dashboard)
Pod Naming Convention
{deployment-name}-{hash}-{pod-id}(e.g.,api-gateway-abc123-xyz789)
ConfigMap: fraud-detection-config
- Shared environment variables across all compute-layer deployments
- Contains Kafka broker, Redis, PostgreSQL connection strings
- Mounted as
envFromin pod specs
Secrets
-
llm-credentials:LLM_API_KEY(auto-created by deploy.sh; use the following command manually when deploying via API)kubectl create secret generic llm-credentials --from-literal=LLM_API_KEY="YOUR_API_KEY" --dry-run=client -o yaml | kubectl apply -f -
-
postgres-credentials:DATABASE_URL(auto-created by deploy.sh)
Use the chaos agent to run controlled experiments against a target deployment. Two examples below target the api-gateway deployment.
- Throttle CPU limits to 50m (resource starvation):
curl -X POST http://127.0.0.1:8001/trigger-chaos \
-H "Content-Type: application/json" \
-d '{
"target_deployment": "api-gateway",
"objective": "Use resource starvation only. Apply throttle_cpu_limits strictly to 50m on the target deployment."
}'- Crash simulation: kill one random pod in the target deployment:
curl -X POST http://127.0.0.1:8001/trigger-chaos \
-H "Content-Type: application/json" \
-d '{
"target_deployment": "api-gateway",
"objective": "Use crash simulation only. Kill one random pod in the target deployment."
}'These calls assume you have kubectl port-forward svc/atlas-chaos-service 8001:8001 running locally or that the chaos agent is reachable at 127.0.0.1:8001.
grafana-mcp-credentials: Grafana API token (auto-created during deployment)
All deployments follow Kubernetes best practices:
- Requests: CPU and memory guaranteed for scheduling
- Limits: CPU and memory caps to prevent node starvation
- Example (API Gateway):
- Request: 100m CPU, 128Mi memory
- Limit: 500m CPU, 512Mi memory
atlas-kafka-controller: Kafka brokers (ordered pod identity, stable storage)atlas-postgres-postgresql: PostgreSQL primary (stable DNS, persistent volume)atlas-redis-master: Redis instance (ordered pod identity)
For local testing with deploy_kind.sh:
- Cluster Name:
fraud-detection-lab - Config File:
k8s/kind-config.yaml - NGINX Ingress: Auto-installed from upstream Kubernetes Ingress repo
- Node Port Exposure: Kind automatically maps container ports for nip.io routing
- Target Scale: Production fraud detection systems processing high transaction volumes
- Operational Priorities: Correctness, safety, auditability, automated remediation
- SLA: 99.99% uptime target, sub-second response times for transaction ingestion
- Orchestrator Runtime: Consolidated scaling into a single-loop, multi-deployment LangGraph workflow that evaluates
api-gateway,scoring-system,enrichment-system, andnotification-systemsequentially - Tooling Separation: The scaling runtime keeps the MCP tool server local and speaks to Kubernetes and Prometheus through typed tool calls
- Alerting Resilience: The notification service was refactored to handle Avro-serialized scored events with graceful fallback decoding for local and mixed-format environments
- Operational Guardrails: Safety checks, approval gates, and replica limits are enforced in the scaling path to keep automated actions auditable
- Human-Approved Scaling: The Guardian now requires an approved request before
/approvals/{id}/executewill scale a workload, and temporary HPA max-replica increases are recorded withguardian.temp_*annotations so the cluster can revert back to normal HPA control when load drops - Ingress & Load Testing: Locust ingress routing was fixed to ensure traffic balances across the API gateway pods via the NGINX ingress controller
- Autoscaling Fixes: HPA behavior was corrected and Kafka partitioning tuned so consumers can run in parallel without stalling
- Observability Hygiene: Prometheus alert rules were adjusted to reduce startup noise, and dashboard fields were reformatted for readability
- Guardian Tooling: New MCP tool support for Kubernetes pod status plus alert visualization and trend reporting enhancements
- Client Experience: Added a home-banking demo UI with WebSocket-driven fraud status updates
- Docker & Docker Compose
- Python 3.11+
- 16GB RAM minimum
# Start the local stack for development
docker compose up --build
# Access points
# - API Gateway: http://localhost:8000
# - Prometheus: http://localhost:9090
# - Scaling Agent HTTP API: http://localhost:8001
# - Scaling Agent metrics: http://localhost:8002/metricsThe production-style deployment path uses Kubernetes and the repository deploy scripts, not Docker Compose alone.
Use deploy.sh to launch the full pipeline on a Kubernetes cluster:
bash deploy.sh --buildThis script builds the service images, deploys the data layer, installs the platform observability stack, applies the application manifests, creates required secrets, and waits for rollouts to complete.
Useful options:
--skip-data-layerto reuse existing Kafka, Redis, and PostgreSQL services--skip-pltto reuse the monitoring stack--skip-app-layerto deploy only the infrastructure layers--skip-locustto skip the load-testing resources--namespace <name>to target a different Kubernetes namespace
For local kind clusters, use:
bash deploy_kind.sh --build# Send test transaction
curl -X POST http://localhost:8000/api/v1/transactions \
-H "Content-Type: application/json" \
-d '{"transaction_id": "test-123", "timestamp": "2026-03-23T10:00:00Z", "channel": "web", "transaction_type": "payment", "payment_details": {"amount": 100.0, "currency": "EUR", "payment_method": "credit_card"}, "user_id": 123}'Use locust/locustfile.py to stress the FastAPI gateway endpoint /api/v1/transactions.
- Runs as Docker service
transaction-client(when usingdocker-compose.yml) - Generates continuous traffic to
/api/v1/transactionsat a configurable rate - Independent of Locust; provides baseline load even without explicit load testing
- Useful for continuous validation during development
- The Docker service
transaction-clientand Locust are independent traffic generators. - If you do not start Locust, the system still receives traffic from
transaction-client(if running in Compose). - If you run both together, the gateway receives combined traffic.
# Start platform services
docker compose up -d --build
# Install Locust locally (one-time)
pip install locust
# Start Locust UI
locust -f locust/locustfile.py --host=http://localhost:8000Open the Locust UI at http://localhost:8089.
docker run --rm -it --network host -v "$PWD":/mnt/locust locustio/locust \
-f /mnt/locust/locust/locustfile.py --host=http://localhost:8000Use this option when ATLAS is deployed on Kubernetes.
Prerequisites:
- NGINX Ingress Controller installed and running in the cluster
- Ingress resource
api-gateway-ingressapplied
Run Locust against the ingress host:
locust -f locust/locustfile.py --host=http://fraud-api.127.0.0.1.nip.ioQuick verification before starting Locust:
python3 - <<'PY'
import urllib.request
with urllib.request.urlopen('http://fraud-api.127.0.0.1.nip.io/health/live', timeout=3) as r:
print(r.status)
print(r.read().decode())
PYIf ingress is not available yet, use temporary port-forward fallback:
kubectl port-forward -n default svc/api-gateway 8000:8000
locust -f locust/locustfile.py --host=http://localhost:8000locust -f locust/locustfile.py --host=http://localhost:8000 --headless -u 100 -r 10 -t 5m# Keep all services but disable the mock transaction client
docker compose up -d --build --scale transaction-client=0The platform uses the agents-devops SRE Guardian runtime for alert intake, investigation, remediation reasoning, and post-mortem reporting, combined with the Trend Reporting Agent for incident pattern analysis.
The guardian workflow is built around an explicit control loop with tool-call execution, human-approval checkpoints, and deployment-by-deployment reasoning so that actions remain explainable and reviewable.
- Runs from
agents-devops/main_agent_guardian.py - Exposes a FastAPI webhook on port
8000 - Spawns
agents-devops/k8s_mcp.pylocally over stdio for Kubernetes control - Investigates alerts with Grafana MCP and executes remediation reasoning with LangGraph
- Kubernetes deployment is defined in
k8s/app-layer/agent-guardian.yaml, which bundles the ServiceAccount, RoleBinding, initContainer wait-for-Grafana-MCP step, budget env vars, and the dashboard sidecar deployment
- Multi-process orchestration via
agents-devops/entrypoint.sh:uvicorn main_agent_guardian:appon port8000(FastAPI webhook)python src/agent_trend/health_server.pyon port8002(liveness + readiness probes)streamlit run src/agent_trend/dashboard.pyon port8501(interactive post-mortem dashboard)
- Dashboard features:
- Real-time incident visualization via Streamlit
- Trend analysis with LLM-generated insights
- Exposed through Kubernetes ingress at
http://guardian-report.127.0.0.1.nip.io
The Chaos Agent serves as the Red Team within ATLAS, executing controlled chaos experiments to validate the resilience of the platform and the effectiveness of the Guardian's automated remediation.
- Runtime: Runs from
agents-chaos/main_chaos_agent.py - FastAPI Interface: Exposes
/trigger-chaosendpoint for on-demand resilience testing - Execution Model: Four-phase chaos engineering workflow orchestrated by LangGraph:
- Discovery: Enumerate target deployments and system state
- Planning: Design targeted failure scenarios with clear objectives
- Execution: Apply controlled disruptions (pod termination, resource starvation, network delays)
- Analysis: Collect remediation responses and produce formal Markdown reports
- MCP Tool Ecosystem: Kubernetes operations (
kill_random_pod,get_target_deployments, network policies) exposed via local stdio MCP server - Output: Structured incident reports detailing experiment outcomes, detection latency, and remediation effectiveness
# Trigger a chaos experiment against a specific deployment
curl -X POST http://localhost:8000/trigger-chaos \
-H "Content-Type: application/json" \
-d '{"target_deployment": "api-gateway", "objective": "Verify auto-scaling response to pod failures"}'Guardian Runtime Variables:
TARGET_DEPLOYMENTS: Kubernetes deployments to monitor (default:api-gateway,scoring-system,enrichment-system,notification-system)NAMESPACE: Kubernetes namespace (default:default)LM_STUDIO_URL/LLM_API_URL: OpenAI-compatible LLM endpointLLM_MODEL/LM_MODEL: Model name to use (e.g.,gpt-4,google/gemma-3-12b)LLM_API_KEY: API key (or "local-no-key" for local models)DATABASE_URL: PostgreSQL connection string (required)BUDGET_MAX_REPLICAS: per-deployment ceiling used to derive the default global budgetTOTAL_REPLICA_BUDGET: maximum allowed replica sum across all target deploymentsEMERGENCY_MAX_REPLICAS: absolute upper bound for emergency actions, clamped to the configured budgetMAX_TOOL_STEPS: Maximum reasoning steps per incident (default:10)RPS_REPLICA_THRESHOLDS: Comma-separated RPS thresholds for scaling bands (default:5,15,30,60)REPORTS_DIR: Output directory for incident reports
Chaos Agent Runtime Variables:
TARGET_DEPLOYMENTS: Kubernetes deployments eligible for chaos experiments (default:api-gateway,scoring-system,enrichment-system,notification-system)LM_STUDIO_URL/LLM_API_URL: OpenAI-compatible LLM endpoint for the chaos reasoning loopLLM_MODEL: Model name for chaos planning and analysisLLM_API_KEY: API key for the chaos LLMMAX_TOOL_STEPS: Maximum steps in the chaos experiment workflow (default:6)REQUEST_TIMEOUT_SECONDS: Timeout for individual chaos tool calls (default:90)LOG_LEVEL: Logging level (default:INFO)
Validation:
- Guardian:
DATABASE_URLand eitherLLM_API_URLorLM_STUDIO_URLare required at startup - Guardian scaling actions are blocked when the projected total replica usage exceeds
TOTAL_REPLICA_BUDGET - Chaos Agent:
LLM_API_URLorLM_STUDIO_URLrequired for LLM reasoning - Missing required variables cause immediate failure with clear error messages
- Config validation runs at module import time
- FastAPI accepts Alertmanager webhooks immediately and processes firing alerts in background tasks
- Duplicate alerts are deduplicated with
ALERT_DEDUP_WINDOW_SECONDS, and concurrent runs for the same deployment are serialized with an in-flight lock - Reports are written to
reports/incidents/and upserted by incident key, so repeated alerts update the same incident record - Incident reports store
incident_id,post_mortem_path, and structured execution details for later review - The dashboard is exposed through ingress at
http://guardian-report.127.0.0.1.nip.io - The webhook endpoint stays internal to the cluster at
http://atlas-guardian-service.default.svc.cluster.local:8000/webhook - Health probes on port
8002allow Kubernetes to monitor pod readiness and restart unhealthy instances
LM_STUDIO_URL,LMSTUDIO_BASE_URL, orLLM_API_URLpoint to the OpenAI-compatible local model serverLM_MODELorLMSTUDIO_MODELshould match the exact model name exposed by LM Studio, such asgoogle/gemma-3-12b- The Kubernetes manifest uses
http://host.docker.internal:1234/v1in Docker Desktop - Invalid model output is handled safely inside the client loop
- Update
deploy.shwhen the Kubernetes launch sequence changes - Update
deploy_kind.shwhen the kind-specific launch sequence changes - Update
agents-devops/k8s_mcp.pywhen you need new Kubernetes tools - Update
agents-devops/src/agent_trend/trend_analyzer.pyfor incident trend analysis logic - Update
agents-devops/src/agent_trend/dashboard.pyfor dashboard UI changes - Update
agents-devops/entrypoint.shwhen changing process orchestration (uvicorn, health server, streamlit) - Update
k8s/app-layer/agent-trend-report.yamlfor Kubernetes deployment configuration - Update
agents-chaos/chaos_mcp.pyto add new chaos operations or Kubernetes tools - Update
agents-chaos/src/agent_chaos/prompts.pyfor new chaos strategies or target profiles - Update
k8s/app-layer/agent-chaos.yamlfor chaos agent deployment configuration
Tools exposed to the Guardian reasoning loop for autonomous decision-making:
get_rps- Query Prometheus for global ingress RPS via PromQL, returns float valueget_current_replicas- Fetch current replica count for a deploymentset_replicas- Update replica count for a deployment (respectsMIN_REPLICAS/MAX_REPLICASguardrails)get_scaling_recommendation- Combine current load and replica state into a suggested action (SCALE_UP, SCALE_DOWN, HOLD)get_workload_health- Query Prometheus for workload health metrics (error rates, latency, CPU)get_hpa_limits- Read HPA limits together with the configured budget and emergency ceilingsget_budget_state- Inspect global replica usage, remaining budget, and per-deployment costsplan_budget_allocation- Compute a budget-safe allocation plan before scaling up a target deploymentexecute_budget_allocation- Apply the allocation plan atomically with rollback safeguardsset_hpa_max_replicas- Update the HPA ceiling for a deployment when pressure dropsrestore_cpu_limits- Restore CPU limits when the verdict is infrastructure-related rather than scaling-related
All tools return structured JSON responses with validation and error handling.
Tools for executing controlled failure injection:
get_target_deployments- List eligible Kubernetes deployments for chaos experimentskill_random_pod- Terminate a random pod in a target deployment (simulates pod crash)inject_network_delay(future) - Add latency to pod network interfacestarve_resources(future) - Reduce CPU/memory allocation temporarily
The Guardian agent integrates with Grafana MCP server for operational context:
- Query dashboards for current system state
- Retrieve alerts and annotation history
- Correlate incident timing with deployed changes
Transaction input (to API Gateway):
{
"transaction_id": "string (UUID)",
"timestamp": "ISO 8601 datetime",
"channel": "string (web, mobile, atm, etc.)",
"transaction_type": "string (payment, withdrawal, transfer, etc.)",
"user_id": "integer",
"ip_address": "IPv4 or IPv6 (optional)",
"payment_details": {
"amount": "float",
"currency": "ISO 4217 code",
"payment_method": "string (credit_card, debit_card, wallet, etc.)"
}
}Enriched transaction (internal):
- All fields from input
country_code: Derived from GeoIP lookup onip_addresscity: Derived from GeoIP lookupclient_ip: Extracted fromip_address
Scored transaction (Avro serialized):
{
"transaction_id": "string",
"timestamp": "long (millis since epoch)",
"risk_score": "int (0-100)",
"risk_level": "string (low, medium, high, critical)",
"payload": "string (JSON-encoded full transaction)"
}
# Rebuild Docker image with entrypoint.sh
docker build -t atlas/agent-guardian:latest agents-devops
# Apply Kubernetes manifests (ServiceAccount, RBAC, Deployments, Services)
kubectl apply -f k8s/app-layer/agent-guardian.yaml
kubectl apply -f k8s/app-layer/agent-trend-report.yaml
kubectl apply -f k8s/app-layer/ingress.yaml
# Trigger rollout with new image
kubectl rollout restart deployment/atlas-guardian-agent
kubectl rollout status deployment/atlas-guardian-agent --timeout=120s
# Verify all pods ready
kubectl get pods -l app=atlas-guardian-agent -l app=atlas-guardian-dashboard
# Access dashboard
echo "Dashboard: http://guardian-report.127.0.0.1.nip.io"Check logs for startup errors:
kubectl logs deployment/atlas-guardian-dashboard -f | grep -E "(ERROR|WARN|health)"Verify health probes working:
kubectl port-forward svc/atlas-guardian-dashboard-service 8002:8002
curl -v http://localhost:8002/health # Liveness
curl -v http://localhost:8002/ready # Readiness (checks DB)Restart unhealthy pod:
kubectl delete pod -l app=atlas-guardian-dashboard- Prometheus: http://localhost:9090
- API Gateway Metrics: http://localhost:8000/metrics
- Health Checks: Built into all services
- Transaction processing rate
- System resource utilization
- Container scaling events
- Error rates and latency
- Critical scaling decisions require human approval
- Automated actions are logged and auditable
- Rollback capabilities for failed operations
- Resource limits prevent runaway scaling
- Health checks ensure service availability
- Circuit breakers for fault isolation
https://docs.google.com/presentation/d/1HlnA7TAynb4Y-V4erjQDsLTQypRxanFz-kMEbn7uesU/edit?usp=sharing