An AI-powered Coding Assistant that understands, searches, edits, and debugs codebases using LangGraph, Groq, RAG, FAISS, and Tree-sitter.
Modern coding assistants such as Cursor, GitHub Copilot, and Claude Code rely on much more than a Large Language Model. They combine intelligent tool calling, semantic code retrieval, planning, and code understanding to assist developers throughout the software development lifecycle.
This project demonstrates how those core ideas can be implemented from scratch.
The AI Coding Agent can:
- π Explore an entire codebase
- π Perform semantic code search using Retrieval-Augmented Generation (RAG)
- π Read and explain source code
- π§ Understand code structure using AST parsing and Tree-sitter
- π Create, modify, and delete project files
- π» Execute terminal commands
- π Explain runtime errors and tracebacks
- π€ Plan multi-step tasks before execution using LangGraph
The project was built with a strong focus on AI Engineering concepts rather than simply wrapping an LLM API. Every component is modular, making it easy to understand how modern coding assistants are designed internally.
- LangGraph-powered agent workflow
- Multi-step task planning
- Conversation state management
- Intelligent tool selection
- Read source files
- Explain code
- Search files
- Extract code structure
- Understand functions, classes, and imports
- Semantic code search
- Sentence Transformer embeddings
- FAISS vector database
- Context-aware retrieval
- Create new files
- Modify existing files
- Delete files
- Workspace sandbox protection
- Execute terminal commands
- Explain Python tracebacks
- Debug runtime errors
- Docker support
- Environment variable configuration
- Modular project architecture
- Clean separation of concerns
- Logging support
This project demonstrates practical implementation of:
- AI Agents
- Tool Calling
- Retrieval-Augmented Generation (RAG)
- LangGraph Workflows
- Embeddings
- FAISS Vector Search
- Tree-sitter
- Python AST
- Context Management
- Multi-step Planning
- Docker
The AI Coding Agent follows a modular architecture where every component has a single responsibility. Instead of directly sending user prompts to the LLM, the agent first plans the task, retrieves relevant project context, selects appropriate tools, and finally generates an informed response.
User
β
βΌ
LangGraph Workflow
β
ββββββββββ΄βββββββββ
β β
Planner Node Chatbot Node
β
Tool Selection
β
ββββββββββββββββ¬βββββββββββββββΌββββββββββββββββ
β β β β
βΌ βΌ βΌ βΌ
Code RAG File Operations Terminal Code Structure
β β β β
ββββββββββββββββ΄βββββββββββββββ΄ββββββββββββββββ
β
βΌ
Workspace
Every request follows the same execution pipeline.
User Request
β
βΌ
Generate Execution Plan
β
βΌ
Determine Required Tool(s)
β
βΌ
Retrieve Relevant Code (if needed)
β
βΌ
Execute Tool(s)
β
βΌ
LLM Generates Final Response
For example, when the user asks:
Explain how authentication works.
The workflow becomes:
User Question
β
βΌ
Planner
β
βΌ
retrieve_code()
β
βΌ
Relevant Code Chunks
β
βΌ
(Optional) read_file()
β
βΌ
LLM
β
βΌ
Explanation
ai-coding-agent/
β
βββ agent/
β βββ graph.py
β βββ nodes.py
β βββ planner.py
β βββ planner_prompt.py
β βββ prompts.py
β βββ state.py
β
βββ parser/
β βββ ast_parser.py
β βββ tree_sitter_parser.py
β
βββ rag/
β βββ loader.py
β βββ chunker.py
β βββ embeddings.py
β βββ retriever.py
β βββ vector_store.py
β
βββ tools/
β βββ read_file.py
β βββ write_file.py
β βββ create_file.py
β βββ delete_file.py
β βββ list_files.py
β βββ search_files.py
β βββ retrieve_code.py
β βββ code_structure.py
β βββ terminal.py
β βββ debug_error.py
β
βββ utils/
β βββ config.py
β βββ logger.py
β βββ path_utils.py
β
βββ workspace/
βββ logs/
βββ faiss_index/
β
βββ app.py
βββ index_codebase.py
βββ requirements.txt
βββ Dockerfile
βββ .env.example
βββ README.md
git clone https://github.com/<your-username>/ai-coding-agent.git
cd ai-coding-agentpython -m venv venv
venv\Scripts\activatepython3 -m venv venv
source venv/bin/activatepip install -r requirements.txtCopy the example environment file.
cp .env.example .envAdd your Groq API key.
GROQ_API_KEY=your_groq_api_key
MODEL_NAME=llama-3.3-70b-versatile
LOG_LEVEL=INFOPlace the project you want the AI agent to analyze inside the workspace/ directory.
Build the vector index.
python index_codebase.pypython app.pyThe AI Coding Agent is now ready.
docker build -t ai-coding-agent .docker run --env-file .env -it ai-coding-agent| Variable | Description | Required |
|---|---|---|
GROQ_API_KEY |
Groq API Key | β |
MODEL_NAME |
Groq Model Name | β |
LOG_LEVEL |
Logging Level | Optional |
- All file operations are restricted to the
workspace/directory. - Build the FAISS index whenever the contents of the workspace change.
- The agent only operates on indexed repositories placed inside the workspace.
- The project is fully Dockerized for consistent local execution.
Unlike traditional chatbots, this project is built as an AI Agent that combines Large Language Models, tool calling, semantic retrieval, and structured planning to understand and interact with software projects.
Instead of relying solely on the LLM's internal knowledge, the agent dynamically gathers context from the target codebase before generating a response.
The high-level execution flow is shown below.
User
β
βΌ
LangGraph Agent
β
βββββββββββββββ΄ββββββββββββββ
β β
Planner Node Chatbot Node
β
Tool Selection
β
ββββββββββββββββ¬βββββββββββββββΌβββββββββββββββ
βΌ βΌ βΌ βΌ
Code RAG File Operations Terminal Code Structure
β
βΌ
Relevant Context
β
βΌ
Response
The project uses LangGraph to orchestrate the execution flow instead of making a single LLM API call.
Every user request follows a graph-based workflow:
START
β
Planner
β
Chatbot
β
Need Tool?
βββββββββββββββββ
β β
No Yes
β β
βΌ βΌ
END Execute Tool
β
βΌ
Chatbot
β
βΌ
END
Using LangGraph provides:
- Stateful conversations
- Multi-step execution
- Tool orchestration
- Extensible architecture
- Clear separation between planning and execution
Before responding, the agent first creates an execution plan.
For example:
User
Explain how authentication works.
Planner Output
{
"goal": "Explain authentication flow",
"steps": [
"Retrieve relevant code",
"Read important files",
"Generate explanation"
]
}The planner does not execute any tools.
Its only responsibility is deciding what should happen, allowing the chatbot node to perform the required actions.
Large codebases cannot be sent directly to an LLM because of context window limitations.
Instead, the project uses Retrieval-Augmented Generation (RAG).
The indexing pipeline is:
Repository
β
Document Loader
β
Code Chunking
β
Sentence Transformer Embeddings
β
FAISS Vector Database
During inference:
User Question
β
Embedding
β
Similarity Search
β
Relevant Code Chunks
β
LLM
β
Final Response
Only the most relevant code is supplied to the LLM, reducing token usage while improving answer quality.
Rather than answering only from the model's knowledge, the AI agent can invoke external tools whenever additional information or actions are required.
Implemented tools include:
| Tool | Purpose |
|---|---|
retrieve_code |
Semantic code retrieval using FAISS |
read_file |
Read file contents |
list_files |
List project files |
search_files |
Search for files by name |
code_structure |
Extract functions, classes, and imports |
run_terminal |
Execute terminal commands |
debug_error |
Explain runtime errors |
create_file |
Create new files |
write_file |
Modify existing files |
delete_file |
Delete files |
The LLM decides which tool to call based on the user's request.
The project combines two complementary approaches for understanding source code.
The built-in Python AST module is used to extract:
- Classes
- Functions
- Imports
This provides structured information that is difficult to obtain from plain text alone.
Tree-sitter parses source code into a syntax tree.
Unlike Python's AST module, Tree-sitter supports multiple programming languages, making the architecture extensible beyond Python.
Current implementation demonstrates Tree-sitter parsing for Python while keeping the project ready for future multi-language support.
To prevent accidental modification of files outside the target project, all file operations are restricted to the workspace/ directory.
Every read, write, create, and delete operation passes through a workspace path validator before execution.
This ensures the agent only interacts with the intended codebase.
The AI agent can execute terminal commands inside the workspace and use the command output as additional context.
Example workflow:
User
β
Run pytest
β
Terminal
β
Test Output
β
LLM
β
Summary
This enables the agent to assist with common development workflows such as running scripts, executing tests, or inspecting command output.
Runtime errors can be difficult to interpret.
The debugging workflow is:
Execute Program
β
Traceback
β
Debug Tool
β
LLM
β
Explanation
β
Suggested Fix
Instead of only displaying a traceback, the agent explains:
- What happened
- Why it happened
- Possible solutions
This makes debugging more accessible, especially for complex Python errors.
The project was intentionally designed around a few core engineering principles.
Each component has a single responsibility, making the project easier to understand, maintain, and extend.
Planning, retrieval, parsing, tool execution, and response generation are implemented independently rather than tightly coupled.
Instead of relying solely on the LLM's internal knowledge, the agent retrieves relevant project context before producing an answer.
All file operations are constrained to a dedicated workspace directory to avoid unintended access outside the target project.
The repository follows a clean project organization inspired by production AI applications while remaining approachable for learning purposes.
Below are a few example prompts you can use to interact with the AI Coding Agent.
Explain workspace/auth.py
How does the authentication flow work?
What does the login function do?
Explain the purpose of this repository.
Search for authentication files.
Where is JWT implemented?
Find all database-related files.
List every Python file.
Show the structure of workspace/auth.py
List all functions inside app.py.
Show all imports in main.py.
Create workspace/utils/math.py with an add() function.
Replace "Hello" with "Welcome" in app.py.
Delete workspace/test.py.
Run python workspace/app.py
Run pytest
Run pip list
Explain this traceback.
Why am I getting this NameError?
How can I fix this IndexError?
This project demonstrates practical implementation of several core AI Engineering concepts.
- AI Agents
- Tool Calling
- LangGraph Workflows
- Retrieval-Augmented Generation (RAG)
- Context Management
- Multi-step Planning
- Prompt Engineering
- Semantic Search
- Groq API Integration
- Structured Prompt Design
- Context Injection
- Conversation State Management
- Sentence Transformers
- Vector Embeddings
- FAISS Vector Database
- Code Retrieval Pipeline
- Python AST
- Tree-sitter
- Code Parsing
- Source Code Analysis
- Modular Architecture
- Docker
- Logging
- Environment Variables
- Workspace Sandboxing
- CLI Application Development
Modern AI coding assistants are far more than chat interfaces connected to an LLM.
This project demonstrates the fundamental building blocks behind modern coding assistants by combining:
- Intelligent tool calling
- Semantic code retrieval
- Structured planning
- Code understanding
- Workspace-aware file operations
- Terminal interaction
- Runtime error analysis
Rather than relying only on the language model's internal knowledge, the agent retrieves project-specific context and interacts with the codebase through tools before generating responses.
Building this project provides hands-on experience with:
- Designing AI agent workflows using LangGraph
- Building a Code RAG pipeline from scratch
- Working with vector databases and embeddings
- Implementing autonomous tool calling
- Understanding source code using ASTs and Tree-sitter
- Managing LLM context efficiently
- Creating production-style Python project structures
- Dockerizing AI applications
The current implementation focuses on the core concepts behind AI coding assistants.
Potential future enhancements include:
- Git integration
- Incremental vector index updates
- Multi-language Tree-sitter support
- Streaming responses
- Web-based user interface
- Patch-based code editing instead of full file replacement
- Support for additional vector databases (Qdrant, Weaviate)
- Authentication and user sessions
- Cloud deployment
- Multi-agent collaboration
Ensure your .env file contains:
GROQ_API_KEY=your_api_keyBefore starting the agent, build the vector index:
python index_codebase.pyVerify that the repository you want to analyze is placed inside the workspace/ directory before indexing.
If Docker fails to build due to a large build context, ensure your .dockerignore excludes directories such as:
venv/workspace/faiss_index/logs/.git/
Verify that:
- The requested file exists inside the
workspace/directory. - The workspace has been indexed.
- The Groq API key is configured correctly.
If this project helped you understand AI agents, Code RAG, or LangGraph, consider giving the repository a β.
It helps others discover the project and supports future improvements.
Contributions are welcome!
If you'd like to improve the project, feel free to:
- Report bugs
- Suggest new features
- Improve documentation
- Refactor existing code
- Submit pull requests
If you're planning a major change, please open an issue first to discuss the proposed improvement.
This project is licensed under the MIT License.
You are free to use, modify, and distribute this project under the terms of the MIT License.
For more details, see the LICENSE file.
This project was built using the following open-source tools and libraries:
- LangGraph
- LangChain
- Groq
- FAISS
- Sentence Transformers
- Tree-sitter
- Python AST
- Docker
Special thanks to the open-source community for building and maintaining these amazing tools.
Akash Bharangar
AI Engineer | GenAI Engineer | Backend Developer
I'm passionate about building AI applications powered by Large Language Models, Retrieval-Augmented Generation (RAG), AI Agents, and modern backend systems.
GitHub
github.com/akashbharangar
LinkedIn
linkedin.com/in/akash-bharangar-757440186
X (Twitter)
x.com/akaaaaashhhhh
If you found this project useful or learned something from it:
- β Star the repository
- π΄ Fork the project
- π οΈ Build on top of it
- π’ Share it with others
Your support helps make the project more visible and encourages further development.
- π€ LangGraph-based AI Coding Agent
- π Semantic Code Search with RAG + FAISS
- π§ Multi-step Planning Workflow
- π οΈ Intelligent Tool Calling
- π³ Code Structure Analysis using AST & Tree-sitter
- βοΈ File Creation, Editing & Deletion
- π» Terminal Execution & Error Explanation
- π³ Dockerized for Easy Deployment
- π Workspace Sandboxing for Safe File Operations
Built with β€οΈ using Python, Groq, LangGraph, FAISS, and Tree-sitter.




