Spaces:
Sleeping
Sleeping
Clean up project: add LICENSE, simplify Modal config, update docs
Browse files- LICENSE +21 -0
- Makefile +13 -3
- README.md +76 -167
- app.py +1 -22
- modal_app.py +0 -98
- modal_backend.py +4 -17
- requirements.txt +2 -0
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2025 Aghil Sabu
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
Makefile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
.PHONY: install run dev clean deploy help
|
| 2 |
|
| 3 |
# Python configuration
|
| 4 |
PYTHON = python3
|
|
@@ -42,9 +42,19 @@ dev: ## Run with auto-reload
|
|
| 42 |
@echo "🔧 Starting in dev mode..."
|
| 43 |
@GRADIO_WATCH_DIRS=. $(VENV_PYTHON) app.py
|
| 44 |
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
@echo "☁️ Deploying to Modal..."
|
| 47 |
-
|
| 48 |
@echo "✅ Deployed!"
|
| 49 |
|
| 50 |
clean: ## Remove venv and cache files
|
|
|
|
| 1 |
+
.PHONY: install run dev clean modal-deploy modal-install modal-login help
|
| 2 |
|
| 3 |
# Python configuration
|
| 4 |
PYTHON = python3
|
|
|
|
| 42 |
@echo "🔧 Starting in dev mode..."
|
| 43 |
@GRADIO_WATCH_DIRS=. $(VENV_PYTHON) app.py
|
| 44 |
|
| 45 |
+
modal-login: ## Authenticate with Modal (run once)
|
| 46 |
+
@echo "🔐 Authenticating with Modal..."
|
| 47 |
+
@$(VENV)/bin/modal token new
|
| 48 |
+
@echo "✅ Modal authenticated!"
|
| 49 |
+
|
| 50 |
+
modal-install: ## Install Modal CLI in venv
|
| 51 |
+
@echo "📦 Installing Modal..."
|
| 52 |
+
@$(VENV_PIP) install modal
|
| 53 |
+
@echo "✅ Modal installed! Run 'make modal-login' to authenticate"
|
| 54 |
+
|
| 55 |
+
modal-deploy: ## Deploy backend API to Modal
|
| 56 |
@echo "☁️ Deploying to Modal..."
|
| 57 |
+
@$(VENV)/bin/modal deploy modal_backend.py
|
| 58 |
@echo "✅ Deployed!"
|
| 59 |
|
| 60 |
clean: ## Remove venv and cache files
|
README.md
CHANGED
|
@@ -23,6 +23,7 @@ tags:
|
|
| 23 |
- graphviz
|
| 24 |
- architecture
|
| 25 |
- visualization
|
|
|
|
| 26 |
---
|
| 27 |
|
| 28 |
<div align="center">
|
|
@@ -34,7 +35,7 @@ tags:
|
|
| 34 |
**Transform any GitHub repository into beautiful architecture diagrams with voice narration and AI chat — powered by MCP**
|
| 35 |
|
| 36 |
[](https://huggingface.co/spaces/MCP-1st-Birthday/CodeAtlas)
|
| 37 |
-
[](https://modelcontextprotocol.io)
|
| 39 |
[](https://llamaindex.ai)
|
| 40 |
[](https://ai.google.dev)
|
|
@@ -42,7 +43,7 @@ tags:
|
|
| 42 |
[](https://elevenlabs.io)
|
| 43 |
[](https://modal.com)
|
| 44 |
|
| 45 |
-
**[
|
| 46 |
|
| 47 |
</div>
|
| 48 |
|
|
@@ -50,9 +51,10 @@ tags:
|
|
| 50 |
|
| 51 |
## 🎬 Demo Video
|
| 52 |
|
|
|
|
| 53 |
https://github.com/user-attachments/assets/YOUR_VIDEO_ID
|
| 54 |
|
| 55 |
-
> *Watch CodeAtlas analyze
|
| 56 |
|
| 57 |
---
|
| 58 |
|
|
@@ -117,7 +119,7 @@ https://github.com/user-attachments/assets/YOUR_VIDEO_ID
|
|
| 117 |
| 🗺️ **Architecture Diagrams** | AI-generated Graphviz diagrams with layers, clusters, and relationships | **Graphviz** + Gemini AI |
|
| 118 |
| 🔊 **Voice Narration** | Natural speech explanation of your architecture | **🎙️ ElevenLabs TTS** |
|
| 119 |
| 💬 **AI Chat** | Context-aware Q&A about your codebase | **🦙 LlamaIndex** RAG |
|
| 120 |
-
| 🤖 **Multi-Model Support** | Choose between Gemini 3.0
|
| 121 |
| 📐 **Interactive Layout** | Real-time diagram adjustments (direction, spacing, zoom) | Graphviz DOT |
|
| 122 |
| 📜 **Diagram History** | Browse and reload previous analyses | Local Storage |
|
| 123 |
| 🔌 **MCP Server** | 4 tools for AI agent integration | **FastMCP** |
|
|
@@ -127,87 +129,66 @@ https://github.com/user-attachments/assets/YOUR_VIDEO_ID
|
|
| 127 |
|
| 128 |
## 🔌 MCP Server Integration
|
| 129 |
|
| 130 |
-
CodeAtlas
|
| 131 |
-
|
| 132 |
-
### Available MCP Tools
|
| 133 |
|
| 134 |
| Tool | Description |
|
| 135 |
|------|-------------|
|
| 136 |
-
| `analyze_codebase` | Generate architecture diagram from GitHub URL
|
| 137 |
-
| `get_architecture_summary` | Get
|
| 138 |
| `chat_with_codebase` | Ask questions about any codebase |
|
| 139 |
| `list_recent_analyses` | List recently analyzed repositories |
|
| 140 |
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
Add this to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json`):
|
| 144 |
-
|
| 145 |
-
```json
|
| 146 |
-
{
|
| 147 |
-
"mcpServers": {
|
| 148 |
-
"codeatlas": {
|
| 149 |
-
"url": "https://your-deployment.modal.run/gradio_api/mcp/sse"
|
| 150 |
-
}
|
| 151 |
-
}
|
| 152 |
-
}
|
| 153 |
-
```
|
| 154 |
-
|
| 155 |
-
Then ask Claude: *"Analyze the architecture of github.com/pallets/flask using CodeAtlas"*
|
| 156 |
|
| 157 |
---
|
| 158 |
|
| 159 |
-
## 🛠️ Tech Stack
|
|
|
|
|
|
|
| 160 |
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
-
|
| 164 |
-
|-------|------------|----------------|
|
| 165 |
-
| **🎨 UI Framework** | [**Gradio 6**](https://gradio.app) — Multi-page routing, `mcp_server=True` | Core Hackathon |
|
| 166 |
-
| **🦙 AI Framework** | [**LlamaIndex**](https://llamaindex.ai) — Unified LLM interface, RAG | **$1K LlamaIndex Prize** |
|
| 167 |
-
| **✨ Primary AI** | [**Google Gemini**](https://ai.google.dev) — Gemini 3.0 Pro, 2.5 Pro/Flash | **$10K Gemini Credits** |
|
| 168 |
-
| **🤖 Alternate AI** | [**OpenAI**](https://openai.com) — GPT-5.1, GPT-5 Mini/Nano | **ChatGPT Pro + $1K Credits** |
|
| 169 |
-
| **🎙️ Voice TTS** | [**ElevenLabs**](https://elevenlabs.io) — High-quality voice narration | **~$2K + AirPods Pro** |
|
| 170 |
-
| **☁️ Deployment** | [**Modal**](https://modal.com) — Serverless cloud, auto-scaling | **$2.5K Modal Prize** |
|
| 171 |
-
| **🔌 MCP Protocol** | [**FastMCP**](https://github.com/jlowin/fastmcp) — Model Context Protocol | Core MCP Track |
|
| 172 |
|
| 173 |
-
|
| 174 |
|
| 175 |
```
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
│
|
| 183 |
-
│
|
| 184 |
-
│
|
| 185 |
-
│
|
| 186 |
-
│
|
| 187 |
-
│
|
| 188 |
-
│
|
| 189 |
-
│
|
| 190 |
-
│
|
| 191 |
-
│
|
| 192 |
-
│
|
| 193 |
-
│
|
| 194 |
-
│
|
| 195 |
-
│
|
| 196 |
-
│
|
| 197 |
-
│
|
| 198 |
-
|
| 199 |
-
│
|
| 200 |
-
│
|
| 201 |
-
│
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
│ └─────────────────────────────────────────────────────────────────────────────┘ │
|
| 205 |
-
│ │
|
| 206 |
-
│ ┌─────────────────────────────────────────────────────────────────────────────┐ │
|
| 207 |
-
│ │ DEPLOYMENT LAYER │ │
|
| 208 |
-
│ │ ☁️ Modal (Serverless, Auto-scaling) │ │
|
| 209 |
-
│ └─────────────────────────────────────────────────────────────────────────────┘ │
|
| 210 |
-
└──────────────────────────────────────────────────────────────────────────────────┘
|
| 211 |
```
|
| 212 |
|
| 213 |
---
|
|
@@ -222,8 +203,8 @@ CodeAtlas integrates **6 major sponsor technologies** for a comprehensive soluti
|
|
| 222 |
|
| 223 |
```bash
|
| 224 |
# Clone and setup
|
| 225 |
-
git clone https://github.com/
|
| 226 |
-
cd
|
| 227 |
python -m venv .venv && source .venv/bin/activate
|
| 228 |
pip install -r requirements.txt
|
| 229 |
|
|
@@ -240,31 +221,22 @@ make install # Create venv and install dependencies
|
|
| 240 |
make run # Run the application
|
| 241 |
```
|
| 242 |
|
| 243 |
-
### Option 3: Deploy
|
| 244 |
-
|
| 245 |
-
**For the hackathon submission**, we use:
|
| 246 |
-
- **HF Space**: Runs the Gradio UI (required for hackathon)
|
| 247 |
-
- **Modal Backend**: Provides compute endpoints (eligible for $2.5K Modal prize)
|
| 248 |
|
| 249 |
```bash
|
| 250 |
-
#
|
| 251 |
-
pip install modal && modal setup
|
| 252 |
modal deploy modal_backend.py
|
| 253 |
-
# Note your endpoint URLs
|
| 254 |
-
|
| 255 |
-
# 2. Push to HF Spaces
|
| 256 |
-
# Set MODAL_BACKEND_URL secret in your HF Space settings
|
| 257 |
-
# pointing to your Modal deployment URL
|
| 258 |
```
|
| 259 |
|
| 260 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
|
| 262 |
-
|
| 263 |
-
# Deploy the complete app on Modal
|
| 264 |
-
modal deploy modal_app.py
|
| 265 |
-
```
|
| 266 |
-
|
| 267 |
-
Your app will be live at `https://your-modal-url.modal.run` 🚀
|
| 268 |
|
| 269 |
---
|
| 270 |
|
|
@@ -275,50 +247,11 @@ Configure API keys via the **Settings** page in the UI:
|
|
| 275 |
| Key | Required | Purpose | Get Key |
|
| 276 |
|-----|----------|---------|---------|
|
| 277 |
| **Gemini API Key** | ✅ Yes | Primary AI engine | [aistudio.google.com/apikey](https://aistudio.google.com/apikey) |
|
| 278 |
-
| **OpenAI API Key** | Optional | GPT-5.1/5 Mini
|
| 279 |
| **ElevenLabs API Key** | Optional | Voice narration | [elevenlabs.io/app/developers](https://elevenlabs.io/app/developers/api-keys) |
|
| 280 |
|
| 281 |
---
|
| 282 |
|
| 283 |
-
## 📁 Project Structure
|
| 284 |
-
|
| 285 |
-
```
|
| 286 |
-
CodeAtlas/
|
| 287 |
-
├── app.py # 🚀 Main entry point
|
| 288 |
-
├── modal_app.py # ☁️ Modal cloud deployment
|
| 289 |
-
├── server.py # 🔌 MCP server entry
|
| 290 |
-
├── requirements.txt # 📦 Dependencies
|
| 291 |
-
├── Makefile # 🛠️ Build commands
|
| 292 |
-
│
|
| 293 |
-
├── src/
|
| 294 |
-
│ ├── config.py # ⚙️ Configuration & settings
|
| 295 |
-
│ │
|
| 296 |
-
│ ├── core/ # 🧠 Core analysis engine
|
| 297 |
-
│ │ ├── analyzer.py # LlamaIndex + Gemini/OpenAI
|
| 298 |
-
│ │ ├── diagram.py # Graphviz rendering
|
| 299 |
-
│ │ └── repository.py # GitHub/ZIP processing
|
| 300 |
-
│ │
|
| 301 |
-
│ ├── integrations/ # 🔗 External services
|
| 302 |
-
│ │ ├── elevenlabs.py # ElevenLabs TTS client
|
| 303 |
-
│ │ └── voice.py # Audio generation pipeline
|
| 304 |
-
│ │
|
| 305 |
-
│ ├── mcp/ # 🤖 MCP Protocol
|
| 306 |
-
│ │ ├── server.py # FastMCP server
|
| 307 |
-
│ │ └── tools.py # 4 MCP tools
|
| 308 |
-
│ │
|
| 309 |
-
│ └── ui/ # 🎨 Gradio interface
|
| 310 |
-
│ ├── app.py # Multi-page routes
|
| 311 |
-
│ ├── components.py # Reusable UI components
|
| 312 |
-
│ └── styles.py # Custom CSS
|
| 313 |
-
│
|
| 314 |
-
└── data/
|
| 315 |
-
├── diagrams/ # 📊 Generated DOT files
|
| 316 |
-
├── audios/ # 🔊 Generated audio files
|
| 317 |
-
└── logs/ # 📝 Application logs
|
| 318 |
-
```
|
| 319 |
-
|
| 320 |
-
---
|
| 321 |
-
|
| 322 |
## 🔍 How It Works
|
| 323 |
|
| 324 |
```mermaid
|
|
@@ -338,7 +271,7 @@ flowchart LR
|
|
| 338 |
```
|
| 339 |
|
| 340 |
1. **📥 Load Repository** — Download from GitHub or extract ZIP, smart-filter to relevant code files (excludes node_modules, tests, configs)
|
| 341 |
-
2. **🧠 AI Analysis** — LlamaIndex processes code context with Gemini 3.0
|
| 342 |
3. **🗺️ Generate Diagram** — AI creates Graphviz DOT code with 15-20 key nodes showing layers, clusters, and relationships
|
| 343 |
4. **🔊 Voice Narration** — AI generates natural summary, ElevenLabs converts to high-quality speech
|
| 344 |
5. **💬 Chat Interface** — Context-aware Q&A about the analyzed codebase with conversation history
|
|
@@ -347,44 +280,20 @@ flowchart LR
|
|
| 347 |
|
| 348 |
## 🎯 Use Cases
|
| 349 |
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
| **📚 Learning** | Understand how popular open-source projects are structured |
|
| 356 |
-
| **🏚️ Legacy Code** | Make sense of undocumented older codebases |
|
| 357 |
-
| **🤖 AI Agents** | Give Claude/Cursor AI ability to analyze any repo via MCP |
|
| 358 |
-
|
| 359 |
-
---
|
| 360 |
-
|
| 361 |
-
## 🏆 Hackathon Submission
|
| 362 |
-
|
| 363 |
-
This project is submitted to **MCP's 1st Birthday Hackathon** hosted by Anthropic and Gradio.
|
| 364 |
-
|
| 365 |
-
- **Track:** MCP in Action → Consumer
|
| 366 |
-
- **Tags:** `mcp-in-action-track-consumer`
|
| 367 |
-
- **Team:** Solo
|
| 368 |
-
|
| 369 |
-
### Sponsor Integrations
|
| 370 |
-
|
| 371 |
-
| Sponsor | Integration | Feature |
|
| 372 |
-
|---------|-------------|---------|
|
| 373 |
-
| 🦙 **LlamaIndex** | `llama-index-core`, `llama-index-llms-gemini`, `llama-index-llms-openai` | Unified AI interface, RAG support |
|
| 374 |
-
| ✨ **Google Gemini** | `google-genai`, Gemini 3.0 Pro, 2.5 Pro/Flash | Primary AI analysis engine |
|
| 375 |
-
| 🤖 **OpenAI** | `openai`, GPT-5.1, GPT-5 Mini/Nano | Alternative AI model support |
|
| 376 |
-
| 🎙️ **ElevenLabs** | `elevenlabs` | Voice narration TTS |
|
| 377 |
-
| ☁️ **Modal** | `modal` | Serverless cloud deployment |
|
| 378 |
-
| 🔌 **FastMCP** | `fastmcp`, `mcp` | MCP protocol server |
|
| 379 |
|
| 380 |
---
|
| 381 |
|
| 382 |
## 👨💻 Author
|
| 383 |
|
| 384 |
-
**
|
| 385 |
-
- GitHub: [@
|
| 386 |
-
- HuggingFace: [@
|
| 387 |
-
- Twitter/X: [@
|
| 388 |
|
| 389 |
---
|
| 390 |
|
|
@@ -400,6 +309,6 @@ MIT License — see [LICENSE](LICENSE) for details.
|
|
| 400 |
|
| 401 |
*November 2025*
|
| 402 |
|
| 403 |
-
[](https://huggingface.co/spaces/MCP-1st-Birthday/CodeAtlas)
|
| 38 |
+
[](https://gradio.app)
|
| 39 |
[](https://modelcontextprotocol.io)
|
| 40 |
[](https://llamaindex.ai)
|
| 41 |
[](https://ai.google.dev)
|
|
|
|
| 43 |
[](https://elevenlabs.io)
|
| 44 |
[](https://modal.com)
|
| 45 |
|
| 46 |
+
**[🔗 Try it Live](https://huggingface.co/spaces/MCP-1st-Birthday/CodeAtlas)** • **[📺 Demo Video](#-demo-video)** • **[📱 Social Post](https://x.com/your-post-link)**
|
| 47 |
|
| 48 |
</div>
|
| 49 |
|
|
|
|
| 51 |
|
| 52 |
## 🎬 Demo Video
|
| 53 |
|
| 54 |
+
<!-- Replace with your actual video link -->
|
| 55 |
https://github.com/user-attachments/assets/YOUR_VIDEO_ID
|
| 56 |
|
| 57 |
+
> *Watch CodeAtlas analyze a GitHub repository in real-time, generate architecture diagrams, and explain the codebase with voice narration.*
|
| 58 |
|
| 59 |
---
|
| 60 |
|
|
|
|
| 119 |
| 🗺️ **Architecture Diagrams** | AI-generated Graphviz diagrams with layers, clusters, and relationships | **Graphviz** + Gemini AI |
|
| 120 |
| 🔊 **Voice Narration** | Natural speech explanation of your architecture | **🎙️ ElevenLabs TTS** |
|
| 121 |
| 💬 **AI Chat** | Context-aware Q&A about your codebase | **🦙 LlamaIndex** RAG |
|
| 122 |
+
| 🤖 **Multi-Model Support** | Choose between Gemini 3.0/2.5 Pro/Flash or GPT-5.1/5 Mini | **Google Gemini** + **OpenAI** |
|
| 123 |
| 📐 **Interactive Layout** | Real-time diagram adjustments (direction, spacing, zoom) | Graphviz DOT |
|
| 124 |
| 📜 **Diagram History** | Browse and reload previous analyses | Local Storage |
|
| 125 |
| 🔌 **MCP Server** | 4 tools for AI agent integration | **FastMCP** |
|
|
|
|
| 129 |
|
| 130 |
## 🔌 MCP Server Integration
|
| 131 |
|
| 132 |
+
CodeAtlas exposes **4 MCP tools** for AI agent integration:
|
|
|
|
|
|
|
| 133 |
|
| 134 |
| Tool | Description |
|
| 135 |
|------|-------------|
|
| 136 |
+
| `analyze_codebase` | Generate architecture diagram from GitHub URL |
|
| 137 |
+
| `get_architecture_summary` | Get text summary of codebase architecture |
|
| 138 |
| `chat_with_codebase` | Ask questions about any codebase |
|
| 139 |
| `list_recent_analyses` | List recently analyzed repositories |
|
| 140 |
|
| 141 |
+
**MCP Endpoint:** `https://huggingface.co/spaces/MCP-1st-Birthday/CodeAtlas/gradio_api/mcp/sse`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
---
|
| 144 |
|
| 145 |
+
## 🛠️ Tech Stack
|
| 146 |
+
|
| 147 |
+
CodeAtlas integrates multiple technologies for a comprehensive solution:
|
| 148 |
|
| 149 |
+
| Layer | Technology | Purpose |
|
| 150 |
+
|-------|------------|---------|
|
| 151 |
+
| **🎨 UI Framework** | [**Gradio 6**](https://gradio.app) | Multi-page routing, `mcp_server=True` |
|
| 152 |
+
| **🦙 AI Framework** | [**LlamaIndex**](https://llamaindex.ai) | Unified LLM interface, RAG |
|
| 153 |
+
| **✨ Primary AI** | [**Google Gemini**](https://ai.google.dev) | Gemini 3.0 Pro, 2.5 Pro/Flash |
|
| 154 |
+
| **🤖 Alternate AI** | [**OpenAI**](https://openai.com) | GPT-5.1, GPT-5 Mini/Nano |
|
| 155 |
+
| **🎙️ Voice TTS** | [**ElevenLabs**](https://elevenlabs.io) | High-quality voice narration |
|
| 156 |
+
| **☁️ Backend API** | [**Modal**](https://modal.com) | Serverless API endpoints |
|
| 157 |
+
| **🔌 MCP Protocol** | [**FastMCP**](https://github.com/jlowin/fastmcp) | Model Context Protocol |
|
| 158 |
|
| 159 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
|
| 161 |
+
## 📁 Project Structure
|
| 162 |
|
| 163 |
```
|
| 164 |
+
codeAtlas/
|
| 165 |
+
├── app.py # Main Gradio application entry point
|
| 166 |
+
├── modal_backend.py # Modal serverless API deployment
|
| 167 |
+
├── requirements.txt # Python dependencies
|
| 168 |
+
├── Makefile # Build and run commands
|
| 169 |
+
├── src/
|
| 170 |
+
│ ├── config.py # Configuration management
|
| 171 |
+
│ ├── core/
|
| 172 |
+
│ │ ├── analyzer.py # AI-powered codebase analysis
|
| 173 |
+
│ │ ├── diagram.py # Graphviz diagram generation
|
| 174 |
+
│ │ └── repository.py # GitHub/ZIP repository loading
|
| 175 |
+
│ ├── integrations/
|
| 176 |
+
│ │ ├── elevenlabs.py # ElevenLabs TTS integration
|
| 177 |
+
│ │ ├── modal_client.py # Modal API client
|
| 178 |
+
│ │ └── voice.py # Voice synthesis utilities
|
| 179 |
+
│ ├── mcp/
|
| 180 |
+
│ │ ├── server.py # FastMCP server setup
|
| 181 |
+
│ │ └── tools.py # MCP tool definitions
|
| 182 |
+
│ └── ui/
|
| 183 |
+
│ ├── app.py # UI layout and routing
|
| 184 |
+
│ ├── components.py # Reusable UI components
|
| 185 |
+
│ └── styles.py # CSS styling
|
| 186 |
+
├── data/
|
| 187 |
+
│ ├── diagrams/ # Generated diagram files
|
| 188 |
+
│ ├── audios/ # Voice narration files
|
| 189 |
+
│ └── logs/ # Application logs
|
| 190 |
+
└── assets/
|
| 191 |
+
└── screenshots/ # Documentation screenshots
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
```
|
| 193 |
|
| 194 |
---
|
|
|
|
| 203 |
|
| 204 |
```bash
|
| 205 |
# Clone and setup
|
| 206 |
+
git clone https://github.com/aghilsabu/codeAtlas.git
|
| 207 |
+
cd codeAtlas
|
| 208 |
python -m venv .venv && source .venv/bin/activate
|
| 209 |
pip install -r requirements.txt
|
| 210 |
|
|
|
|
| 221 |
make run # Run the application
|
| 222 |
```
|
| 223 |
|
| 224 |
+
### Option 3: Deploy API Backend to Modal
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
|
| 226 |
```bash
|
| 227 |
+
# Deploy the serverless API backend on Modal
|
|
|
|
| 228 |
modal deploy modal_backend.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
```
|
| 230 |
|
| 231 |
+
**Modal Backend API Endpoints:**
|
| 232 |
+
| Endpoint | URL |
|
| 233 |
+
|----------|-----|
|
| 234 |
+
| Health Check | `https://aghilsabu--codeatlas-backend-health.modal.run` |
|
| 235 |
+
| Generate Diagram | `https://aghilsabu--codeatlas-backend-generate-diagram.modal.run` |
|
| 236 |
+
| Generate Voice | `https://aghilsabu--codeatlas-backend-generate-voice.modal.run` |
|
| 237 |
+
| Analyze Codebase | `https://aghilsabu--codeatlas-backend-analyze-codebase.modal.run` |
|
| 238 |
|
| 239 |
+
These serverless endpoints handle heavy compute operations and can be called from any frontend! 🚀
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
|
| 241 |
---
|
| 242 |
|
|
|
|
| 247 |
| Key | Required | Purpose | Get Key |
|
| 248 |
|-----|----------|---------|---------|
|
| 249 |
| **Gemini API Key** | ✅ Yes | Primary AI engine | [aistudio.google.com/apikey](https://aistudio.google.com/apikey) |
|
| 250 |
+
| **OpenAI API Key** | Optional | GPT-5.1/5 Mini models | [platform.openai.com/api-keys](https://platform.openai.com/api-keys) |
|
| 251 |
| **ElevenLabs API Key** | Optional | Voice narration | [elevenlabs.io/app/developers](https://elevenlabs.io/app/developers/api-keys) |
|
| 252 |
|
| 253 |
---
|
| 254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
## 🔍 How It Works
|
| 256 |
|
| 257 |
```mermaid
|
|
|
|
| 271 |
```
|
| 272 |
|
| 273 |
1. **📥 Load Repository** — Download from GitHub or extract ZIP, smart-filter to relevant code files (excludes node_modules, tests, configs)
|
| 274 |
+
2. **🧠 AI Analysis** — LlamaIndex processes code context with Gemini 3.0 (or GPT-5.1) to understand architecture
|
| 275 |
3. **🗺️ Generate Diagram** — AI creates Graphviz DOT code with 15-20 key nodes showing layers, clusters, and relationships
|
| 276 |
4. **🔊 Voice Narration** — AI generates natural summary, ElevenLabs converts to high-quality speech
|
| 277 |
5. **💬 Chat Interface** — Context-aware Q&A about the analyzed codebase with conversation history
|
|
|
|
| 280 |
|
| 281 |
## 🎯 Use Cases
|
| 282 |
|
| 283 |
+
- **Onboarding** — New team members instantly understand codebase structure
|
| 284 |
+
- **Documentation** — Generate architecture diagrams for README/docs
|
| 285 |
+
- **Code Review** — Visualize changes in context of overall architecture
|
| 286 |
+
- **Learning** — Understand how popular open-source projects are structured
|
| 287 |
+
- **Legacy Code** — Make sense of undocumented older codebases
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
|
| 289 |
---
|
| 290 |
|
| 291 |
## 👨💻 Author
|
| 292 |
|
| 293 |
+
**Aghil Sabu**
|
| 294 |
+
- GitHub: [@aghilsabu](https://github.com/aghilsabu)
|
| 295 |
+
- HuggingFace: [@aghilsabu](https://huggingface.co/aghilsabu)
|
| 296 |
+
- Twitter/X: [@AghilSabu](https://x.com/AghilSabu)
|
| 297 |
|
| 298 |
---
|
| 299 |
|
|
|
|
| 309 |
|
| 310 |
*November 2025*
|
| 311 |
|
| 312 |
+
[](https://github.com/aghilsabu/codeAtlas)
|
| 313 |
|
| 314 |
</div>
|
app.py
CHANGED
|
@@ -16,34 +16,13 @@ def main():
|
|
| 16 |
neutral_hue=gr.themes.colors.gray,
|
| 17 |
)
|
| 18 |
|
| 19 |
-
# Force light theme CSS
|
| 20 |
-
light_theme_css = """
|
| 21 |
-
.dark {
|
| 22 |
-
--body-background-fill: white !important;
|
| 23 |
-
--background-fill-primary: white !important;
|
| 24 |
-
--background-fill-secondary: #f7f7f7 !important;
|
| 25 |
-
--block-background-fill: white !important;
|
| 26 |
-
--body-text-color: #374151 !important;
|
| 27 |
-
--block-label-text-color: #374151 !important;
|
| 28 |
-
--block-title-text-color: #374151 !important;
|
| 29 |
-
--input-background-fill: white !important;
|
| 30 |
-
--input-background-fill-focus: white !important;
|
| 31 |
-
--border-color-primary: #e5e7eb !important;
|
| 32 |
-
--link-text-color: #ea580c !important;
|
| 33 |
-
--link-text-color-hover: #c2410c !important;
|
| 34 |
-
--button-primary-background-fill: #ea580c !important;
|
| 35 |
-
--button-primary-text-color: white !important;
|
| 36 |
-
}
|
| 37 |
-
"""
|
| 38 |
-
combined_css = light_theme_css + (custom_css or "")
|
| 39 |
-
|
| 40 |
app.launch(
|
| 41 |
share=False,
|
| 42 |
server_name="0.0.0.0",
|
| 43 |
server_port=7860,
|
| 44 |
mcp_server=True,
|
| 45 |
theme=theme,
|
| 46 |
-
css=
|
| 47 |
allowed_paths=[str(AUDIOS_DIR)],
|
| 48 |
)
|
| 49 |
|
|
|
|
| 16 |
neutral_hue=gr.themes.colors.gray,
|
| 17 |
)
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
app.launch(
|
| 20 |
share=False,
|
| 21 |
server_name="0.0.0.0",
|
| 22 |
server_port=7860,
|
| 23 |
mcp_server=True,
|
| 24 |
theme=theme,
|
| 25 |
+
css=custom_css,
|
| 26 |
allowed_paths=[str(AUDIOS_DIR)],
|
| 27 |
)
|
| 28 |
|
modal_app.py
DELETED
|
@@ -1,98 +0,0 @@
|
|
| 1 |
-
"""CodeAtlas - Modal Cloud Deployment"""
|
| 2 |
-
|
| 3 |
-
import modal
|
| 4 |
-
|
| 5 |
-
app = modal.App(name="codeatlas")
|
| 6 |
-
|
| 7 |
-
image = (
|
| 8 |
-
modal.Image.debian_slim(python_version="3.12")
|
| 9 |
-
.apt_install("graphviz", "fonts-liberation")
|
| 10 |
-
.pip_install(
|
| 11 |
-
"gradio>=5.0.0",
|
| 12 |
-
"fastapi[standard]",
|
| 13 |
-
"uvicorn>=0.20.0",
|
| 14 |
-
"google-genai>=1.0.0",
|
| 15 |
-
"llama-index-core>=0.11.0",
|
| 16 |
-
"llama-index-llms-gemini>=0.4.0",
|
| 17 |
-
"llama-index-llms-openai>=0.3.0",
|
| 18 |
-
"elevenlabs>=1.0.0",
|
| 19 |
-
"fastmcp>=0.1.0",
|
| 20 |
-
"requests>=2.31.0",
|
| 21 |
-
"graphviz>=0.20.0",
|
| 22 |
-
)
|
| 23 |
-
)
|
| 24 |
-
|
| 25 |
-
local_files = modal.Mount.from_local_dir(
|
| 26 |
-
".",
|
| 27 |
-
remote_path="/app",
|
| 28 |
-
condition=lambda path: not any(x in path for x in [
|
| 29 |
-
"__pycache__", ".git", ".venv", "node_modules",
|
| 30 |
-
"data/", ".session_state.json", ".env",
|
| 31 |
-
])
|
| 32 |
-
)
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
@app.function(
|
| 36 |
-
image=image,
|
| 37 |
-
mounts=[local_files],
|
| 38 |
-
cpu=2.0,
|
| 39 |
-
memory=4096,
|
| 40 |
-
min_containers=0,
|
| 41 |
-
max_containers=10,
|
| 42 |
-
scaledown_window=300,
|
| 43 |
-
timeout=600,
|
| 44 |
-
secrets=[modal.Secret.from_name("codeatlas-secrets", required_keys=[])],
|
| 45 |
-
)
|
| 46 |
-
@modal.concurrent(max_inputs=50)
|
| 47 |
-
@modal.asgi_app()
|
| 48 |
-
def serve():
|
| 49 |
-
"""Serve the CodeAtlas Gradio application."""
|
| 50 |
-
import os
|
| 51 |
-
import sys
|
| 52 |
-
|
| 53 |
-
sys.path.insert(0, "/app")
|
| 54 |
-
os.chdir("/app")
|
| 55 |
-
|
| 56 |
-
os.makedirs("/app/data/diagrams", exist_ok=True)
|
| 57 |
-
os.makedirs("/app/data/audios", exist_ok=True)
|
| 58 |
-
os.makedirs("/app/data/logs", exist_ok=True)
|
| 59 |
-
|
| 60 |
-
from fastapi import FastAPI
|
| 61 |
-
from gradio.routes import mount_gradio_app
|
| 62 |
-
from src.ui import create_app, CUSTOM_CSS
|
| 63 |
-
import gradio as gr
|
| 64 |
-
|
| 65 |
-
gradio_app, _ = create_app()
|
| 66 |
-
|
| 67 |
-
theme = gr.themes.Soft(
|
| 68 |
-
primary_hue=gr.themes.colors.orange,
|
| 69 |
-
secondary_hue=gr.themes.colors.orange,
|
| 70 |
-
neutral_hue=gr.themes.colors.gray,
|
| 71 |
-
)
|
| 72 |
-
|
| 73 |
-
fastapi_app = FastAPI(title="CodeAtlas", version="1.0.0")
|
| 74 |
-
|
| 75 |
-
@fastapi_app.get("/health")
|
| 76 |
-
async def health():
|
| 77 |
-
return {"status": "healthy"}
|
| 78 |
-
|
| 79 |
-
return mount_gradio_app(app=fastapi_app, blocks=gradio_app, path="/")
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
@app.function(image=image, mounts=[local_files], cpu=1.0, memory=2048, timeout=300)
|
| 83 |
-
def analyze_codebase_remote(github_url: str, api_key: str, model_name: str = "gemini-2.5-flash") -> str:
|
| 84 |
-
"""Remote function to analyze a codebase."""
|
| 85 |
-
import sys
|
| 86 |
-
import os
|
| 87 |
-
|
| 88 |
-
sys.path.insert(0, "/app")
|
| 89 |
-
os.chdir("/app")
|
| 90 |
-
|
| 91 |
-
from src.mcp.tools import analyze_codebase
|
| 92 |
-
return analyze_codebase(api_key=api_key, github_url=github_url, model_name=model_name)
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
@app.local_entrypoint()
|
| 96 |
-
def main():
|
| 97 |
-
print("🚀 Use 'modal serve modal_app.py' to test locally")
|
| 98 |
-
print(" Use 'modal deploy modal_app.py' to deploy")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modal_backend.py
CHANGED
|
@@ -14,11 +14,12 @@ import json
|
|
| 14 |
# Create Modal app
|
| 15 |
app = modal.App(name="codeatlas-backend")
|
| 16 |
|
| 17 |
-
# Container image with all dependencies
|
| 18 |
image = (
|
| 19 |
modal.Image.debian_slim(python_version="3.12")
|
| 20 |
.apt_install("graphviz", "fonts-liberation", "git")
|
| 21 |
.pip_install(
|
|
|
|
| 22 |
"google-genai>=1.0.0",
|
| 23 |
"llama-index-core>=0.11.0",
|
| 24 |
"llama-index-llms-gemini>=0.4.0",
|
|
@@ -28,16 +29,8 @@ image = (
|
|
| 28 |
"graphviz>=0.20.0",
|
| 29 |
"requests>=2.31.0",
|
| 30 |
)
|
| 31 |
-
)
|
| 32 |
-
|
| 33 |
-
# Mount source code (excluding data and cache)
|
| 34 |
-
local_files = modal.Mount.from_local_dir(
|
| 35 |
-
".",
|
| 36 |
-
remote_path="/app",
|
| 37 |
-
condition=lambda path: not any(x in path for x in [
|
| 38 |
-
"__pycache__", ".git", ".venv", "node_modules",
|
| 39 |
-
"data/", ".session_state.json", ".env",
|
| 40 |
-
])
|
| 41 |
)
|
| 42 |
|
| 43 |
|
|
@@ -47,11 +40,9 @@ local_files = modal.Mount.from_local_dir(
|
|
| 47 |
|
| 48 |
@app.function(
|
| 49 |
image=image,
|
| 50 |
-
mounts=[local_files],
|
| 51 |
cpu=2.0,
|
| 52 |
memory=4096,
|
| 53 |
timeout=300,
|
| 54 |
-
secrets=[modal.Secret.from_name("codeatlas-secrets", required_keys=[])],
|
| 55 |
)
|
| 56 |
@modal.web_endpoint(method="POST", docs=True)
|
| 57 |
def generate_diagram(request: dict) -> dict:
|
|
@@ -137,11 +128,9 @@ def generate_diagram(request: dict) -> dict:
|
|
| 137 |
|
| 138 |
@app.function(
|
| 139 |
image=image,
|
| 140 |
-
mounts=[local_files],
|
| 141 |
cpu=1.0,
|
| 142 |
memory=2048,
|
| 143 |
timeout=120,
|
| 144 |
-
secrets=[modal.Secret.from_name("codeatlas-secrets", required_keys=[])],
|
| 145 |
)
|
| 146 |
@modal.web_endpoint(method="POST", docs=True)
|
| 147 |
def generate_voice(request: dict) -> dict:
|
|
@@ -213,11 +202,9 @@ def generate_voice(request: dict) -> dict:
|
|
| 213 |
|
| 214 |
@app.function(
|
| 215 |
image=image,
|
| 216 |
-
mounts=[local_files],
|
| 217 |
cpu=2.0,
|
| 218 |
memory=4096,
|
| 219 |
timeout=300,
|
| 220 |
-
secrets=[modal.Secret.from_name("codeatlas-secrets", required_keys=[])],
|
| 221 |
)
|
| 222 |
@modal.web_endpoint(method="POST", docs=True)
|
| 223 |
def analyze_codebase(request: dict) -> dict:
|
|
|
|
| 14 |
# Create Modal app
|
| 15 |
app = modal.App(name="codeatlas-backend")
|
| 16 |
|
| 17 |
+
# Container image with all dependencies and source code
|
| 18 |
image = (
|
| 19 |
modal.Image.debian_slim(python_version="3.12")
|
| 20 |
.apt_install("graphviz", "fonts-liberation", "git")
|
| 21 |
.pip_install(
|
| 22 |
+
"fastapi",
|
| 23 |
"google-genai>=1.0.0",
|
| 24 |
"llama-index-core>=0.11.0",
|
| 25 |
"llama-index-llms-gemini>=0.4.0",
|
|
|
|
| 29 |
"graphviz>=0.20.0",
|
| 30 |
"requests>=2.31.0",
|
| 31 |
)
|
| 32 |
+
.add_local_dir("src", "/app/src", copy=True)
|
| 33 |
+
.add_local_file("app.py", "/app/app.py", copy=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
)
|
| 35 |
|
| 36 |
|
|
|
|
| 40 |
|
| 41 |
@app.function(
|
| 42 |
image=image,
|
|
|
|
| 43 |
cpu=2.0,
|
| 44 |
memory=4096,
|
| 45 |
timeout=300,
|
|
|
|
| 46 |
)
|
| 47 |
@modal.web_endpoint(method="POST", docs=True)
|
| 48 |
def generate_diagram(request: dict) -> dict:
|
|
|
|
| 128 |
|
| 129 |
@app.function(
|
| 130 |
image=image,
|
|
|
|
| 131 |
cpu=1.0,
|
| 132 |
memory=2048,
|
| 133 |
timeout=120,
|
|
|
|
| 134 |
)
|
| 135 |
@modal.web_endpoint(method="POST", docs=True)
|
| 136 |
def generate_voice(request: dict) -> dict:
|
|
|
|
| 202 |
|
| 203 |
@app.function(
|
| 204 |
image=image,
|
|
|
|
| 205 |
cpu=2.0,
|
| 206 |
memory=4096,
|
| 207 |
timeout=300,
|
|
|
|
| 208 |
)
|
| 209 |
@modal.web_endpoint(method="POST", docs=True)
|
| 210 |
def analyze_codebase(request: dict) -> dict:
|
requirements.txt
CHANGED
|
@@ -34,6 +34,8 @@ graphviz>=0.20.0
|
|
| 34 |
# ==================== Utilities ====================
|
| 35 |
requests>=2.31.0
|
| 36 |
|
|
|
|
|
|
|
| 37 |
|
| 38 |
# ==================== Development ====================
|
| 39 |
# ruff # Linting
|
|
|
|
| 34 |
# ==================== Utilities ====================
|
| 35 |
requests>=2.31.0
|
| 36 |
|
| 37 |
+
# ==================== Modal Deployment ====================
|
| 38 |
+
modal>=0.64.0
|
| 39 |
|
| 40 |
# ==================== Development ====================
|
| 41 |
# ruff # Linting
|