Skip to content

BhavanKumarGM/Code_Explainer_Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  Code Explainer Agent

An AI-powered Code Explainer that understands, analyzes, and explains entire codebases using Qwen 2.5 running locally through Ollama. Built with a privacy-first approach, the entire application operates offline without relying on any cloud-based AI services.


๐Ÿ“– Overview

Code Explainer Agent is a local-first AI assistant designed to help developers understand unfamiliar codebases quickly. Simply upload a project or repository, and the agent analyzes the complete source code, builds contextual understanding, and answers questions about the architecture, execution flow, dependencies, and implementation details.

Unlike cloud-based coding assistants, all AI inference runs locally on your machine using Qwen 2.5 via Ollama, ensuring that your source code never leaves your computer.


โœจ Features

๐Ÿ“‚ Repository Analysis

  • Upload an entire project as a ZIP archive
  • Analyze complete folder structures
  • Parse thousands of source files
  • Support multi-language repositories
  • Automatic project indexing

๐Ÿง  Code Understanding

  • Explain complete repositories
  • Explain files and modules
  • Explain classes and methods
  • Explain functions line by line
  • Identify project architecture
  • Detect design patterns
  • Trace execution flow
  • Analyze dependencies
  • Understand configuration files

๐Ÿ’ฌ AI Chat

Ask questions such as:

  • Explain this project.
  • How does authentication work?
  • Where is the database connection initialized?
  • Explain this API.
  • How does JWT work here?
  • Which module handles payments?
  • Explain this function.
  • Find where this class is used.
  • Why am I getting this error?
  • Explain this algorithm.

๐Ÿ” Semantic Search

  • Context-aware code search
  • Function search
  • Class search
  • API search
  • Configuration search
  • Dependency search

๐Ÿ”’ Privacy First

Your source code never leaves your machine.

This project does not use:

  • โŒ OpenAI API
  • โŒ Anthropic API
  • โŒ Gemini API
  • โŒ Groq API
  • โŒ OpenRouter API
  • โŒ Claude API
  • โŒ Any cloud-hosted LLM

Everything runs locally through Ollama.


๐Ÿ— Architecture

                     User
                       โ”‚
                       โ–ผ
              React Frontend
                       โ”‚
                       โ–ผ
               FastAPI Backend
                       โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚                             โ”‚
        โ–ผ                             โ–ผ
 Repository Parser            Chat Service
        โ”‚                             โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ–ผ
              Chunking & Parsing
                       โ”‚
                       โ–ผ
              Embedding Generator
                       โ”‚
                       โ–ผ
             Local Vector Database
                       โ”‚
                       โ–ผ
                Ollama Server
                       โ”‚
                       โ–ผ
                  Qwen 2.5

โš™๏ธ Tech Stack

Frontend

  • React
  • TypeScript
  • Tailwind CSS
  • Vite

Backend

  • Python
  • FastAPI
  • LangChain

AI

  • Qwen 2.5
  • Ollama
  • Local Embedding Model
  • Retrieval-Augmented Generation (RAG)

Database

  • ChromaDB / FAISS
  • SQLite

๐Ÿš€ Workflow

Step 1

Upload a project ZIP file.

or

Select an existing repository.

โ†“

Step 2

The repository is extracted locally.

โ†“

Step 3

The parser scans:

  • Folder structure
  • Source files
  • Classes
  • Functions
  • Imports
  • Dependencies
  • Configuration files

โ†“

Step 4

Source code is divided into semantic chunks.

โ†“

Step 5

Embeddings are generated locally.

โ†“

Step 6

Embeddings are stored in the local vector database.

โ†“

Step 7

User asks a question.

โ†“

Step 8

Relevant code is retrieved.

โ†“

Step 9

Qwen 2.5 generates a contextual explanation.


๐Ÿ“ Project Structure

Code-Explainer-Agent/

โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ pages/
โ”‚   โ”œโ”€โ”€ hooks/
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ””โ”€โ”€ assets/
โ”‚
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”œโ”€โ”€ parser/
โ”‚   โ”œโ”€โ”€ rag/
โ”‚   โ”œโ”€โ”€ embeddings/
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ””โ”€โ”€ main.py
โ”‚
โ”œโ”€โ”€ uploads/
โ”œโ”€โ”€ vectordb/
โ”œโ”€โ”€ models/
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ requirements.txt

๐Ÿ–ฅ Installation

Clone Repository

git clone https://github.com/yourusername/Code-Explainer-Agent.git

cd Code-Explainer-Agent

Backend

cd backend

pip install -r requirements.txt

Frontend

cd frontend

npm install

๐Ÿค– Install Ollama

Download and install Ollama for your operating system.

Start the Ollama server:

ollama serve

Download the Qwen 2.5 model:

ollama pull qwen2.5

Verify installation:

ollama list

โ–ถ Running the Backend

uvicorn main:app --reload

โ–ถ Running the Frontend

npm run dev

๐ŸŒ Local URLs

Service URL
Frontend http://localhost:5173
Backend http://localhost:8000
Ollama http://localhost:11434

โš™ Configuration

OLLAMA_URL = "http://localhost:11434"

MODEL_NAME = "qwen2.5"

EMBEDDING_MODEL = "nomic-embed-text"

No API keys are required.


๐Ÿ’ฌ Example Prompts

Explain this repository.
Describe the project architecture.
How does authentication work?
Explain the API flow.
Where is the database initialized?
Explain this class.
Explain this function.
Which files handle routing?
Find all usages of UserService.
Why is this code throwing an exception?

๐ŸŽฏ Use Cases

  • Learning unfamiliar repositories
  • Understanding legacy code
  • Code reviews
  • Architecture exploration
  • Developer onboarding
  • Debugging
  • Documentation generation
  • Educational purposes

๐Ÿ”ฎ Roadmap

  • Multi-Agent Architecture
  • Code Editing Agent
  • Repository Refactoring
  • Git Integration
  • GitHub Repository Cloning
  • UML Diagram Generation
  • Documentation Generator
  • Test Case Generation
  • Session Memory
  • Multi-Repository Support
  • Workspace Management

๐Ÿค Contributing

Contributions are welcome.

  1. Fork the repository.
  2. Create a feature branch.
  3. Commit your changes.
  4. Push to your branch.
  5. Open a Pull Request.

โญ Support

If you find this project useful, consider giving it a Star โญ on GitHub.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages