Skip to content

AkashAkuthota/AI-Debugging-Copilot-for-Distributed-Systems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

AI Debugging Copilot for Distributed Systems

๐Ÿ“Œ Overview

This project is a production-style AI backend system designed to help developers debug distributed systems by combining:

  • Document-based Retrieval (RAG)
  • Real-time Log Ingestion (upcoming)
  • LLM-based Root Cause Analysis

The system retrieves relevant context from documents (and later logs), and uses an LLM to generate accurate, grounded debugging explanations and fix suggestions.


๐Ÿง  Problem Statement

Debugging distributed systems is difficult because:

  • Logs are noisy and scattered
  • Errors lack context
  • Documentation is underutilized

This system solves that by:

Combining logs + documentation + semantic search โ†’ to explain issues and suggest fixes


โš™๏ธ Current Features (Phase 1)

โœ… Core AI Pipeline

  • Retrieval-Augmented Generation (RAG)
  • Semantic search using embeddings
  • Context-aware response generation

โœ… Backend Architecture

  • FastAPI-based modular backend
  • Clean separation of layers (API, retrieval, service, cache)

โœ… Vector Database

  • Qdrant (persistent via Docker)

  • Rich payload metadata:

    • user_id (multi-tenancy ready)
    • chunk tracking
    • embedding versioning

โœ… LLM Reliability

  • Retry mechanism with exponential backoff
  • Timeout protection
  • Safe fallback responses

โœ… Caching

  • Redis-based response caching
  • Reduces latency and cost

โœ… Security

  • API key-based authentication (middleware)
  • Secure request validation

โœ… Rate Limiting

  • Redis-based per-key rate limiting
  • Prevents API abuse

๐Ÿ—๏ธ Architecture

๐Ÿ”น High-Level Flow

Client โ†’ FastAPI API Layer โ†’ Middleware Layer (Auth + Rate Limiting) โ†’ Service Layer (LLM Orchestration) โ†’ Retrieval Layer (Qdrant Vector Search) โ†’ Cache Layer (Redis) โ†’ LLM (OpenAI API)


๐Ÿ”น Detailed Request Lifecycle

  1. Client Request

    • User sends query to /api/ask
  2. Middleware Layer

    • API Key Authentication
    • Rate Limiting (Redis-based)
  3. Cache Layer (Redis)

    • Checks for cached response
    • Returns immediately if available
  4. Retrieval Layer (RAG)

    • Converts query โ†’ embedding
    • Searches similar chunks in Qdrant
    • Filters based on similarity threshold
    • Builds contextual input
  5. LLM Service Layer

    • Constructs structured prompt (context + query)
    • Calls OpenAI API with retry & timeout handling
  6. Response Processing

    • Formats response (answer, confidence, source)
    • Stores result in Redis cache
  7. Response Returned to Client


๐Ÿ”น Data Storage Design

  • Qdrant (Vector Database)

    • Stores embeddings + metadata payload
    • Enables semantic search and filtering
  • Redis

    • Used for caching responses
    • Used for rate limiting counters

๐Ÿ”น Key Design Principles

  • Modular architecture with clear separation of concerns
  • Config-driven system behavior
  • Fault-tolerant LLM integration (retry + fallback)
  • Scalable vector-based retrieval
  • Secure and rate-limited API access

๐Ÿ› ๏ธ Tech Stack

  • Python โ€” Core language
  • FastAPI โ€” Backend API framework
  • Qdrant โ€” Vector database for semantic search
  • Redis โ€” Caching and rate limiting
  • OpenAI API โ€” LLM inference
  • Docker โ€” Containerized services

๐Ÿš€ How to Run Locally

1. Clone Repository

git clone https://github.com/your-username/your-repo.git
cd your-repo

2. Setup Environment

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

3. Create .env File

APP_API_KEY=your_secret_key
OPENAI_API_KEY=your_openai_key

QDRANT_HOST=localhost
QDRANT_PORT=6333

REDIS_URL=redis://localhost:6379

4. Start Services

Qdrant

docker run -p 6333:6333 qdrant/qdrant

Redis

redis-server

5. Run Application

uvicorn app.main:app --reload

๐Ÿงช Example API Usage

Endpoint

POST /api/ask

Headers

x-api-key: your_secret_key
Content-Type: application/json

Request Body

{
  "query": "What backend technologies are used?"
}

๐Ÿ“Œ Example Response

{
  "answer": "The backend technologies include Python, FastAPI, Redis...",
  "confidence": "medium",
  "source": "rag_docs"
}

๐Ÿ”ฎ Upcoming Features (Phase 2+)

  • ๐Ÿ“Š Log ingestion system (/ingest-log)
  • ๐Ÿง  Incident detection (error patterns)
  • ๐Ÿ” Multi-source retrieval (logs + docs)
  • โšก Hybrid search (vector + keyword)
  • ๐Ÿ“ˆ Observability (Prometheus + Grafana)
  • ๐Ÿ‘ฅ Multi-user API key system
  • โ˜๏ธ Cloud deployment (AWS)
  • ๐Ÿ” CI/CD pipeline

๐ŸŽฏ Goal

To build a production-grade AI backend system that demonstrates:

  • Backend engineering expertise
  • Scalable system design
  • Real-world AI/LLM integration

๐Ÿ‘จโ€๐Ÿ’ป Author

Akash Akuthota Backend Developer (Python | FastAPI | AI Systems)

About

AI-powered backend system for debugging distributed systems using RAG, semantic search, and LLM-based root cause analysis.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages