Skip to content

tejasbhor/migrationguard-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

MigrationGuard AI

๐Ÿค– Production-grade agentic AI system for autonomous issue detection and resolution during e-commerce platform migrations.

Tests Coverage Python License

๐ŸŽฏ What Makes This Agentic?

This system demonstrates proper agent behavior that goes far beyond a single LLM call:

โœ… State Management - Persistent state across the observe-reason-decide-act loop
โœ… Multi-Step Reasoning - Pattern detection โ†’ Root cause โ†’ Risk assessment โ†’ Action planning
โœ… Tool Orchestration - 8+ specialized tools working together autonomously
โœ… Feedback Loops - Learning from outcomes and adapting behavior
โœ… Safety Controls - Multiple layers including safe mode, circuit breakers, and human oversight

๐Ÿš€ Quick Start

Get the complete system running in under 10 minutes:

cd migrationguard-ai
setup.cmd                              # Start infrastructure
uv run python demo_agent_system.py    # Run demo

See it in action: The demo showcases authentication error detection โ†’ pattern analysis โ†’ root cause reasoning โ†’ automated ticket creation with full state tracking and feedback loops.

๐Ÿ“– Detailed Guide: QUICKSTART.md

๐Ÿ—๏ธ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      AGENT ORCHESTRATOR                          โ”‚
โ”‚                   (Observe-Reason-Decide-Act Loop)              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚                     โ”‚                     โ”‚
        โ–ผ                     โ–ผ                     โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   OBSERVE    โ”‚      โ”‚    REASON    โ”‚     โ”‚   DECIDE     โ”‚
โ”‚              โ”‚      โ”‚              โ”‚     โ”‚              โ”‚
โ”‚ โ€ข Signal     โ”‚      โ”‚ โ€ข Pattern    โ”‚     โ”‚ โ€ข Risk       โ”‚
โ”‚   Ingestion  โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ–ถ  Detection   โ”‚โ”€โ”€โ”€โ”€โ”€โ–ถ  Assessment  โ”‚
โ”‚ โ€ข Normalize  โ”‚      โ”‚ โ€ข Root Cause โ”‚     โ”‚ โ€ข Action     โ”‚
โ”‚ โ€ข Track      โ”‚      โ”‚   Analysis   โ”‚     โ”‚   Selection  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                   โ”‚
                                                   โ–ผ
                                           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                           โ”‚     ACT      โ”‚
                                           โ”‚              โ”‚
                                           โ”‚ โ€ข Execute    โ”‚
                                           โ”‚ โ€ข Track      โ”‚
                                           โ”‚ โ€ข Learn      โ”‚โ—€โ”€โ”
                                           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
                                                   โ”‚          โ”‚
                                                   โ–ผ          โ”‚
                                           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
                                           โ”‚   FEEDBACK   โ”‚  โ”‚
                                           โ”‚     LOOP     โ”‚โ”€โ”€โ”˜
                                           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โœจ Key Features

๐Ÿ” Intelligent Observation

  • Multi-source signal ingestion (API errors, support tickets, webhooks)
  • Real-time normalization and enrichment
  • Time-series storage with TimescaleDB

๐Ÿง  Advanced Reasoning

  • Pattern detection across signals using Elasticsearch
  • Root cause analysis with Google Gemini 2.5 Flash (+ rule-based fallback)
  • Evidence gathering and confidence scoring (75-92% confidence)

โš–๏ธ Risk-Aware Decision Making

  • Automated risk assessment (low/medium/high)
  • Approval requirements for high-risk actions
  • Safety controls (safe mode, circuit breakers)

โšก Safe Action Execution

  • Rate limiting and retry logic
  • Graceful degradation on failures
  • Comprehensive audit trail

๐Ÿ”„ Continuous Learning

  • Outcome tracking and analysis
  • Confidence calibration from results
  • Adaptive behavior based on feedback

๐Ÿ›ก๏ธ Multiple Safety Layers

  • Safe Mode: Automatic activation on critical errors
  • Circuit Breakers: Fault tolerance for external services
  • Graceful Degradation: Fallback mechanisms (Claude โ†’ rules, Elasticsearch โ†’ PostgreSQL, Kafka โ†’ Redis)
  • Human Oversight: Approval workflows and manual controls

๐Ÿงช Test Coverage

200+ Tests with 85%+ Coverage

  • โœ… 150+ Unit Tests (core components, services, integrations)
  • โœ… 50+ Property-Based Tests (RBAC, redaction, API, decisions, patterns)
  • โœ… Integration Tests (error handling, end-to-end flows)
  • โœ… All tests passing with comprehensive coverage
uv run pytest tests/unit/ -v

๐Ÿ› ๏ธ Technology Stack

Core

  • Backend: Python 3.11+, FastAPI, Pydantic
  • AI: Google Gemini 2.5 Flash (FREE tier, 15 req/min) with rule-based fallback
  • Agent Framework: Custom orchestration with state management and feedback loops

Infrastructure

  • Database: PostgreSQL + TimescaleDB (time-series)
  • Cache: Redis (caching, rate limiting, buffering)
  • Search: Elasticsearch (pattern matching, full-text search)
  • Streaming: Apache Kafka (event streaming, async processing)

Monitoring

  • Metrics: Prometheus + Grafana
  • Logs: Structured logging with ELK stack support
  • Visualization: Kibana for log exploration

Deployment

  • Containers: Docker + Docker Compose
  • Orchestration: Kubernetes-ready
  • CI/CD: GitHub Actions ready

๐Ÿ“Š Demo Scenarios

Scenario 1: Authentication Errors

Input: 3 signals (2 API 401 errors + 1 support ticket)

Agent Behavior:

  1. ๐Ÿ”ญ Observe: Ingest and normalize signals
  2. ๐Ÿ” Detect: Identify auth failure pattern (confidence: 0.85)
  3. ๐Ÿง  Reason: Analyze root cause โ†’ "authentication_error"
  4. โš–๏ธ Decide: Select "create_support_ticket" (risk: low)
  5. โšก Act: Create ticket with troubleshooting steps
  6. ๐Ÿ”„ Learn: Track outcome, calibrate confidence

Output: Support ticket created with authentication guidance

Scenario 2: Safe Mode Activation

Trigger: Confidence drift detected (expected: 0.90, actual: 0.75)

Agent Behavior:

  1. ๐Ÿ›ก๏ธ Safe mode automatically activated
  2. โธ๏ธ All actions require human approval
  3. ๐Ÿ“‹ Actions queued for review
  4. ๐Ÿ”” Operator notified
  5. โœ… Manual deactivation by authorized operator

๐Ÿ“š Documentation

๐ŸŽฏ Prerequisites

๐Ÿ”ง Installation

Automated Setup (Windows)

cd migrationguard-ai
setup.cmd

This will:

  • โœ… Start all infrastructure services (PostgreSQL, Redis, Kafka, Elasticsearch)
  • โœ… Run database migrations
  • โœ… Create Kafka topics and Elasticsearch indices
  • โœ… Verify connectivity

Manual Setup

REM 1. Start infrastructure
docker-compose up -d

REM 2. Wait for services (30 seconds)
timeout /t 30

REM 3. Check connectivity
uv run python scripts/check_infrastructure.py

REM 4. Run migrations
uv run alembic upgrade head

REM 5. Setup Kafka and Elasticsearch
uv run python scripts/setup_infrastructure.py

๐ŸŽฎ Running the System

Run the Demo

See the complete agent in action:

uv run python demo_agent_system.py

Run Tests

uv run pytest tests/unit/ -v

Start the API Server

uv run uvicorn src.migrationguard_ai.api.app:app --reload

API available at: http://localhost:8000
API docs: http://localhost:8000/docs

Start the Frontend (Optional)

cd frontend
npm install
npm run dev

Frontend available at: http://localhost:3000

๐Ÿ” Access Services

Service URL Credentials
API http://localhost:8000 -
API Docs http://localhost:8000/docs -
Grafana http://localhost:3001 admin/admin
Kibana http://localhost:5601 -
Prometheus http://localhost:9090 -
Elasticsearch http://localhost:9200 -

๐Ÿ“ Project Structure

migrationguard-ai/
โ”œโ”€โ”€ src/migrationguard_ai/
โ”‚   โ”œโ”€โ”€ agent/              # Agent orchestration (state, graph)
โ”‚   โ”œโ”€โ”€ api/                # FastAPI REST API
โ”‚   โ”œโ”€โ”€ core/               # Core components (auth, config, safety)
โ”‚   โ”œโ”€โ”€ db/                 # Database models (SQLAlchemy)
โ”‚   โ”œโ”€โ”€ services/           # Business logic (decision, action, pattern)
โ”‚   โ”œโ”€โ”€ integrations/       # External integrations (support systems)
โ”‚   โ””โ”€โ”€ workers/            # Background workers (pattern detection)
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ unit/               # 150+ unit tests
โ”‚   โ”œโ”€โ”€ integration/        # Integration tests
โ”‚   โ””โ”€โ”€ e2e/                # End-to-end tests
โ”œโ”€โ”€ alembic/                # Database migrations
โ”œโ”€โ”€ scripts/                # Setup and utility scripts
โ”œโ”€โ”€ frontend/               # React dashboard (TypeScript)
โ”œโ”€โ”€ docker-compose.yml      # Infrastructure setup
โ”œโ”€โ”€ demo_agent_system.py    # Complete agent demo
โ””โ”€โ”€ setup.cmd               # Automated setup script

๐Ÿงช Development

Running Tests

REM All tests
uv run pytest tests/unit/ -v

REM With coverage
uv run pytest tests/unit/ --cov=src --cov-report=html

REM Specific test file
uv run pytest tests/unit/test_decision_engine.py -v

REM Property-based tests
uv run pytest tests/unit/test_*_properties.py -v

Code Quality

REM Format code
uv run black src tests

REM Lint code
uv run ruff check src tests

REM Type checking
uv run mypy src

Database Migrations

REM Create migration
uv run alembic revision --autogenerate -m "Description"

REM Apply migrations
uv run alembic upgrade head

REM Rollback
uv run alembic downgrade -1

โš™๏ธ Configuration

All configuration via environment variables in .env file:

# Google Gemini API (FREE tier - get key at https://aistudio.google.com/apikey)
GOOGLE_API_KEY=your-api-key-here

# Database
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=migrationguard
POSTGRES_PASSWORD=changeme

# Redis
REDIS_HOST=localhost
REDIS_PORT=6379

# Kafka
KAFKA_BOOTSTRAP_SERVERS='["localhost:9092"]'

# Elasticsearch
ELASTICSEARCH_HOSTS='["http://localhost:9200"]'

# Agent Configuration
AGENT_CONFIDENCE_THRESHOLD=0.7
AGENT_HIGH_RISK_APPROVAL_REQUIRED=true

๐Ÿ“Š Monitoring & Observability

Metrics (Prometheus)

Exposed at /metrics:

  • Signal ingestion rate
  • Pattern detection latency
  • Decision accuracy
  • Action success rate
  • System resource usage

Logs

Structured JSON logs for:

  • Signal processing
  • Pattern detection
  • Root cause analysis
  • Decision making
  • Action execution
  • Audit trail

Dashboards (Grafana)

Pre-configured dashboards:

  • System health and performance
  • Agent decision metrics
  • Business impact (ticket deflection, resolution time)
  • Infrastructure health

๐Ÿ›‘ Stopping Services

REM Stop all services
docker-compose down

REM Stop and remove all data
docker-compose down -v

๐Ÿ› Troubleshooting

Docker not running

REM Start Docker Desktop, then verify:
docker ps

Services not healthy

REM Check logs:
docker-compose logs [service-name]

REM Restart services:
docker-compose restart

Database connection errors

REM Reset database:
docker-compose down -v
docker-compose up -d postgres
timeout /t 10
uv run alembic upgrade head

Tests failing

REM Verify infrastructure:
uv run python scripts/check_infrastructure.py

REM Run with verbose output:
uv run pytest tests/unit/ -v -s

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests for new functionality
  5. Run code quality checks (black, ruff, mypy)
  6. Commit your changes (git commit -m 'Add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support


Built for the Hackathon | Production-Ready | Fully Tested | Open Source

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors