A full-stack application that allows users to analyze and chat about code repositories using Google's Generative AI and LangChain. The system clones GitHub repositories, processes the code files, and enables intelligent conversations about the codebase.
- Repository cloning and code analysis
- Intelligent code-aware chatbot using Google's Generative AI
- Vector database for efficient code search and retrieval
- FastAPI backend with RESTful endpoints
- React frontend for user interaction
- Support for Python, HTML, and CSS file analysis
- Conversation memory for contextual responses
graph TD
A[User Input] --> B[Repository URL]
B --> C[Clone Repository]
C --> D[Process Code Files]
D --> E[Generate Embeddings]
E --> F[Store in Vector DB]
F --> G[Enable Chat Interface]
G --> H[User Questions]
H --> I[AI Responses]
-
Repository Handler (
repo_handler.py
)- Manages Git repository cloning
- Handles local repository storage
-
Document Processor (
document_processor.py
)- Processes code files using LangChain's document loaders
- Supports Python, HTML, and CSS parsing
- Implements intelligent text splitting for optimal processing
-
Vector Database Manager (
vector_database_manager.py
)- Manages Chroma vector database
- Utilizes Google's Generative AI embeddings
- Persists processed documents for quick retrieval
-
Chatbot Handler (
chatbot_handler.py
)- Implements conversation chain using LangChain
- Maintains conversation memory for context
- Uses Google's Gemini 1.5 Pro model for responses
- React-based user interface
- Located in
my-react-app
directory
- Python 3.8+
- Node.js and npm
- Google Cloud API credentials
- Git
Create a .env
file with the following variables:
GOOGLE_API_KEY=your_google_api_key
- Clone the repository:
git clone https://github.com/charans2702/Code-Repository-Analysis-Chatbot.git
cd Code-Repository-Analysis-Chatbot
- Install backend dependencies:
pip install -r requirements.txt
- Install frontend dependencies:
cd my-react-app
npm install
- Start the backend server:
uvicorn main:app --reload
- Start the frontend development server:
cd my-react-app
npm run dev
Initializes a new repository for analysis
{
"repo_url": "https://github.com/username/repo"
}
Sends a question to the chatbot
{
"question": "What does this repository do?"
}
Checks if a repository has been initialized
{
"initialized": true
}
- Uses MMR (Maximum Marginal Relevance) for document retrieval
- Chunk size of 500 characters with 20 character overlap for document splitting
- Supports multiple programming language parsing
- Implements CORS middleware for cross-origin requests
- Uses Pydantic for request/response validation
- FastAPI
- LangChain
- Google Generative AI
- ChromaDB
- GitPython
- python-dotenv
- React
- Additional frontend dependencies (specified in package.json)
- Support for more programming languages
- Advanced code analysis features
- User authentication
- Repository caching
- Real-time collaboration
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.