Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🩺 CodeDoctor AI

AI-Powered Repository Analysis & Code Understanding Platform

Understand any GitHub repository using Retrieval-Augmented Generation (RAG), semantic search, and Google Gemini.

Python FastAPI Next.js Google Gemini FAISS

FeaturesArchitectureGetting StartedAPIRoadmap


📸 Preview

Landing Page
Landing Page

Chat Interface
Chat Interface


💻 Run Locally

CodeDoctor AI is currently intended to be run locally.

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • Git
  • Google Gemini API Key

After completing the setup instructions in the Getting Started section:

Note

This project currently runs locally due to the computational requirements of repository indexing and embedding generation. Cloud deployment can be done as per requirements.


✨ What is CodeDoctor AI?

Reading an unfamiliar codebase can take hours. CodeDoctor AI helps developers understand repositories in minutes by letting them ask questions in natural language.

Rather than sending an entire repository to an LLM, CodeDoctor AI:

  1. 📂 Clones the repository
  2. 🔍 Scans the source code
  3. 🧠 Generates semantic embeddings
  4. ⚡ Retrieves only the most relevant code
  5. 🤖 Uses Google Gemini to generate repository-aware answers

This Retrieval-Augmented Generation (RAG) pipeline produces significantly more accurate and context-aware responses than querying an LLM directly.


🚀 Features

📂 Repository Analysis

  • Clone any public GitHub repository
  • Scan supported source files
  • Detect programming languages
  • Build repository embeddings
  • Create FAISS vector indexes

💬 AI Repository Chat

Ask natural-language questions like:

  • "Where is authentication implemented?"
  • "Explain the project architecture."
  • "How does the routing work?"
  • "Which technologies are used?"
  • "Summarize the repository."

🧠 Semantic Search

Retrieves code by meaning, not keywords, using vector embeddings for higher-quality matches.

📚 Source References

Every answer includes the exact files and line numbers used to generate the response.

⚡ Fast Retrieval

Powered by Sentence Transformers + FAISS Vector Search.


🏗️ System Architecture

GitHub Repository
       │
       ▼
Repository Cloner
       │
       ▼
Source Code Scanner
       │
       ▼
Code Chunking
       │
       ▼
SentenceTransformer Embeddings
       │
       ▼
FAISS Vector Index ◄──── User Question Embedding
       │
       ▼
Semantic Similarity Search
       │
       ▼
Relevant Repository Chunks
       │
       ▼
Google Gemini API
       │
       ▼
Context-Aware AI Response
       │
       ▼
Next.js Frontend

⚙️ Tech Stack

Layer Technologies
Frontend Next.js, React, TypeScript, Tailwind CSS, shadcn/ui
Backend FastAPI, Python, GitPython, Uvicorn
AI / Retrieval Google Gemini, SentenceTransformers, FAISS, RAG
Utilities NumPy, python-dotenv, pathlib

🛠️ How It Works

Step Description
1 User submits a public GitHub repository URL
2 Repository is cloned locally
3 Supported source files are scanned
4 Each file is split into overlapping chunks
5 Each chunk is converted into semantic embeddings using SentenceTransformers
6 A FAISS vector index is created
7 The user's question is embedded
8 The most relevant code snippets are retrieved
9 Only those snippets are sent to Google Gemini
10 Gemini generates a repository-aware response with source references

📂 Project Structure

CodeDoctor-AI/
├── backend/
│   ├── app/
│   │   ├── routers/
│   │   ├── services/
│   │   │   ├── clone_service.py
│   │   │   ├── scanner_service.py
│   │   │   ├── chunking_service.py
│   │   │   ├── embedding_service.py
│   │   │   ├── retrieval_service.py
│   │   │   ├── gemini_service.py
│   │   │   ├── rag_service.py
│   │   │   └── model_service.py
│   │   ├── storage/
│   │   └── main.py
│   ├── requirements.txt
│   └── .env
│
├── frontend/
│   ├── src/
│   │   ├── app/
│   │   ├── components/
│   │   ├── ui/
│   │   └── lib/
│   ├── public/
│   ├── package.json
│   └── next.config.ts
│
└── README.md

🚀 Getting Started

1. Clone the Repository

git clone https://github.com/manojkumar260706/CodeDoctor-Ai
cd CodeDoctor-AI

2. Backend Setup

Navigate to the backend directory:

cd backend

Install dependencies:

pip install -r requirements.txt

Create a .env file:

GEMINI_API_KEY=YOUR_API_KEY

Run the backend server:

uvicorn app.main:app --reload

Backend:

http://localhost:8000

Swagger Documentation:

http://localhost:8000/docs

3. Frontend Setup

Open a second terminal.

cd frontend
npm install
npm run dev

Frontend:

http://localhost:3000

4. Using the Application

  1. Start both the backend and frontend.
  2. Open http://localhost:3000.
  3. Paste the URL of any public GitHub repository.
  4. Wait while CodeDoctor AI clones, scans, chunks, embeds, and indexes the repository.
  5. Ask questions about the repository in natural language.

📡 API Endpoints

POST /analyze

Analyze and index a repository.

{
  "repo_url": "https://github.com/user/project"
}

POST /ask

Ask a question about an indexed repository.

{
  "repo_url": "https://github.com/user/project",
  "question": "Where is authentication implemented?"
}

Example Response

{
  "answer": "Authentication is implemented in SecurityConfig.java using JWT filters.",
  "sources": [
    {
      "file": "SecurityConfig.java",
      "start_line": 24,
      "end_line": 78
    }
  ]
}

🎯 Roadmap

✅ Completed

  • GitHub repository cloning
  • Source code scanning
  • Code chunking
  • Sentence embeddings
  • FAISS vector indexing
  • Semantic retrieval
  • Google Gemini integration
  • FastAPI backend
  • Next.js frontend
  • Repository-aware AI chat

🚧 Coming Soon

  • Repository dashboard
  • Repository structure visualization
  • Language analytics
  • AI-generated repository summary
  • Suggested questions
  • Architecture visualization
  • Streaming responses
  • Chat history
  • Repository caching
  • Docker support
  • Authentication
  • Cloud deployment

🤝 Contributing

Contributions are welcome! Feel free to fork the repository, open issues, or submit pull requests.


⭐ Support

If this project helped you, please consider giving it a ⭐ Star on GitHub. It helps others discover the project and motivates future development.


About

AI-powered repository analysis platform that understands GitHub repositories using RAG, semantic search, FAISS, and Google Gemini.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages