CodeGraph is an open-source, AI-powered tool that transforms any public GitHub repository into an interactive, 2D force-directed knowledge graph in seconds.
By analyzing the Abstract Syntax Trees (AST) of the repository's source code and leveraging state-of-the-art Large Language Models, CodeGraph enables developers to instantly visualize, explore, and converse with complex codebases.
- Interactive Dependency Visualization: Explore codebases as a graph where nodes represent Files, Classes, and Functions, and edges represent relationships (
calls,defines,imports,contains). - AI Code Summarization: Automatically generates plain-English summaries for every function and class using Groq (llama-3.3-70b) and Mistral AI.
- PageRank Centrality: Automatically calculates node centrality using NetworkX to visually highlight the most important core functions (entry points and heavily utilized utilities).
- Deep Syntax Parsing: Uses
tree-sitterfor precise, multi-language structural code parsing (Python currently optimized). - "Ask me anything" AI Chatbot: Interact with a context-aware AI assistant that answers questions grounded strictly in your repository's structure, streaming live tokens and guiding you directly to relevant nodes.
- Code Inspector: View raw source code with syntax highlighting side-by-side with your graph. Features clickable inline node citations.
- File Tree Navigation: Traverse the repository with a familiar VSCode-style sidebar that tightly syncs with the graph.
- Shareable Links: Send your analyzed graph URL to your team for instant collaboration.
- Framework: FastAPI (Python)
- Code Parsing:
tree-sitter - Graph Processing: NetworkX
- AI Providers: Groq API, Mistral API
- Streaming: Server-Sent Events (SSE) for both pipeline progress and LLM chatbot responses.
- Framework: React + Vite
- Styling: TailwindCSS
- Graph Renderer:
react-force-graph-2d
- Node.js (v18+)
- Python (3.11+)
- GitHub Personal Access Token
- Groq API Key
- Mistral API Key
cd backend
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txtCreate a .env file in the backend/ directory:
GITHUB_TOKEN=your_github_token
GROQ_API_KEY=your_groq_api_key
MISTRAL_API_KEY=your_mistral_api_key
MAX_FILES=60
CACHE_DIR=./cacheStart the backend server:
uvicorn main:app --reload --port 8000cd frontend
npm installStart the development server:
npm run devNavigate to http://localhost:5173/ in your browser. Paste a GitHub repository URL and click Analyze Repo.
- Ingestion: Downloads the target repository structure from the GitHub API.
- Parsing: Extracts functions, classes, docstrings, parameters, and dependencies using tree-sitter.
- Graph Building: Constructs a directed graph of the entire repository ecosystem using NetworkX, identifying isolated entry points and calculating mathematical centrality for UI scaling.
- AI Enrichment: Processes the abstract syntax data through Groq/Mistral to produce high-level human-readable summaries.
- Rendering & Chat: Sends the heavily optimized payload via SSE (Server-Sent Events) to the React frontend. Users can interact with the d3 layout in an HTML5 Canvas, view source files, or chat with the AI using context generated on-the-fly from the graph.
This project is open-source and free to use.