Skip to content

Commit e07602a

Browse files
author
Walid Sobhi
committed
Enhance README with real examples, supported languages, use cases
1 parent 75b1958 commit e07602a

File tree

1 file changed

+204
-26
lines changed

1 file changed

+204
-26
lines changed

README.md

Lines changed: 204 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,229 @@
1-
# AI Code Assistant 🤖💻
1+
# 💻 AI Code Assistant
22

3-
AI-powered coding assistant that understands YOUR codebase. Get answers, generate tests, refactor code.
3+
> **Ask questions about YOUR codebase** — AI that actually understands your code, not just general programming.
44
5-
[![Python](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/)
5+
[![Python](https://img.shields.io/badge/python-3.10+-blue.svg)](https://python.org)
66
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
7-
[![Docker](https://img.shields.io/badge/docker-ready-blue.svg)](Dockerfile)
7+
[![Stars](https://img.shields.io/github/stars/walidsobhie-code/ai-code-assistant)](https://github.com/walidsobhie-code/ai-code-assistant/stargazers)
88

9-
## Why This?
9+
## 🎯 What It Does
1010

11-
Every developer needs an AI that knows their specific codebase, not just general coding.
11+
```
12+
You: "How does authentication work?"
13+
AI: "Authentication uses JWT tokens stored in localStorage.
14+
The flow is: Login → Verify → Store JWT →
15+
Attach JWT to all requests → Validate on backend..."
16+
17+
You: "Where is the database connection?"
18+
AI: "Database connection is in src/db/connection.py
19+
It uses SQLAlchemy with PostgreSQL..."
20+
```
21+
22+
Stop googling YOUR own code. Ask your AI assistant that knows your codebase.
1223

1324
## ✨ Features
1425

15-
- 🧠 **Code Understanding** - Learns your entire codebase
16-
- 💡 **Suggest Improvements** - Code review and optimization
17-
- 🧪 **Generate Tests** - Auto-create unit tests
18-
- 📖 **Document Code** - Auto-generate docs
19-
- 🔍 **Find Bugs** - Identify issues
20-
- 💬 **Chat** - Ask questions in natural language
21-
- 🌐 **Web UI** - Beautiful Gradio interface
22-
- 🐳 **Docker Ready** - Deploy anywhere
26+
| Feature | Description |
27+
|---------|-------------|
28+
| 🧠 **Understands Your Code** | Indexes your entire codebase |
29+
| 🔍 **Semantic Search** | Find code by what it does, not just names |
30+
| 📊 **Multi-Language** | Python, JavaScript, Go, Rust, Java, etc. |
31+
| 🤖 **GPT-4 Powered** | State-of-the-art code understanding |
32+
| 💬 **Chat Interface** | Ask questions naturally |
33+
| 🎛️ **Gradio UI** | Beautiful web interface |
2334

2435
## 🚀 Quick Start
2536

37+
### Install
2638
```bash
39+
git clone https://github.com/walidsobhie-code/ai-code-assistant.git
40+
cd ai-code-assistant
2741
pip install -r requirements.txt
42+
cp .env.example .env
43+
# Add your OPENAI_API_KEY
44+
```
45+
46+
### Index Your Codebase
47+
```bash
48+
# Index your entire project
49+
python context_loader.py --path ./my_project
50+
51+
# Output:
52+
# 📂 Loading 247 code files...
53+
# ✅ Indexed Python (89 files), JavaScript (67 files), etc.
54+
# 📊 Total chunks: 1,432
55+
```
56+
57+
### Ask Questions
58+
```bash
59+
# Query your codebase
60+
python query_engine.py "How does the payment flow work?"
61+
62+
# 💬 AI: "Payment flow uses Stripe:
63+
# 1. User selects products → Cart.checkout()
64+
# 2. Create Stripe session → Payment.create_session()
65+
# 3. Redirect to Stripe → payment.process()
66+
# 4. Webhook confirms → Order.confirm()
67+
# Files: payment.py, checkout.py, webhook.py"
68+
```
69+
70+
### Interactive Chat
71+
```bash
72+
python query_engine.py --interactive
73+
74+
# 💬 Chat mode
75+
# You: How does caching work?
76+
# AI: Caching is implemented using Redis in src/cache/redis.py...
77+
# You: Find all API endpoints
78+
# AI: 23 endpoints found in src/api/:
79+
# - GET /users/:id
80+
# - POST /orders
81+
# - PUT /payments/:id
82+
# ...
83+
```
84+
85+
## 🎨 Web UI Demo
86+
87+
```
88+
┌─────────────────────────────────────────────────────────┐
89+
│ 💻 AI Code Assistant │
90+
├─────────────────────────────────────────────────────────┤
91+
│ │
92+
│ 📂 Index: my_project/ [🔄] │
93+
│ Status: ✅ 247 files indexed │
94+
│ │
95+
│ 💬 Ask Questions │
96+
│ ┌─────────────────────────────────────────────────┐ │
97+
│ │ How does authentication work? │ │
98+
│ └─────────────────────────────────────────────────┘ │
99+
│ [💬 Ask] │
100+
│ │
101+
│ 💡 Answer: │
102+
│ Authentication uses JWT tokens: │
103+
│ │
104+
│ 📄 src/auth/jwt.py (92% match) │
105+
│ 📄 src/middleware/auth.py (87% match) │
106+
│ 📄 src/routes/auth.py (81% match) │
107+
│ │
108+
│ JWT tokens are created on login and validated │
109+
│ on every protected route... │
110+
└─────────────────────────────────────────────────────────┘
111+
```
112+
113+
## 💻 Python API
114+
115+
```python
116+
from context_loader import CodebaseIndexer
117+
from query_engine import CodeAssistant
118+
119+
# Step 1: Index your codebase
120+
indexer = CodebaseIndexer()
121+
result = indexer.index_codebase("./my_project")
122+
print(f"Indexed {result['files']} files")
123+
# Output: Indexed 247 files in 12 languages
124+
125+
# Step 2: Ask questions
126+
assistant = CodeAssistant()
127+
result = assistant.query("Where is the API handler?")
128+
print(result["answer"])
129+
# Output: The API handler is in src/api/handler.py.
130+
# It uses FastAPI with the following routes:...
131+
132+
# Step 3: Get sources
133+
for source in result["sources"]:
134+
print(f"📄 {source}")
135+
# 📄 src/api/handler.py
136+
# 📄 src/routes/api.py
137+
```
28138

29-
# Index your codebase
30-
python context_loader.py --path ./your_project
139+
## 🔍 Real Examples
31140

32-
# Ask questions
33-
python query_engine.py "How does authentication work?"
141+
### Understand Legacy Code
142+
```bash
143+
$ python query_engine.py "What does this authentication system do?"
144+
145+
AI: "This is a JWT-based auth system:
146+
- Login: POST /auth/login → validates credentials
147+
- Token: Returns JWT with 24h expiry
148+
- Middleware: Verifies JWT on protected routes
149+
- Refresh: POST /auth/refresh → renews token
150+
- Logout: Invalidates token in Redis"
151+
```
152+
153+
### Find Code Fast
154+
```bash
155+
$ python query_engine.py "Find all database queries"
34156

35-
# Or use Web UI
36-
python gradio_app.py
37-
# Open http://localhost:7861
157+
AI: "Found 23 database queries across 12 files:
158+
- src/models/user.py: get_user(), create_user()
159+
- src/models/order.py: get_orders(), create_order()
160+
- src/db/connection.py: query(), transaction()
161+
..."
38162
```
39163

164+
### Document Automatically
165+
```bash
166+
$ python query_engine.py "Document the payment module"
167+
168+
AI: "## Payment Module
169+
170+
### Classes
171+
- PaymentIntent: Handles Stripe payment intents
172+
- Refund: Manages partial/full refunds
173+
- WebhookHandler: Processes Stripe webhooks
174+
175+
### Methods
176+
- process_payment(): Initiates Stripe checkout
177+
- confirm_payment(): Confirms payment success
178+
- refund_payment(): Processes refund via Stripe"
179+
```
180+
181+
## 📊 Supported Languages
182+
183+
| Language | Extensions | Status |
184+
|----------|------------|--------|
185+
| Python | .py ||
186+
| JavaScript | .js, .jsx ||
187+
| TypeScript | .ts, .tsx ||
188+
| Java | .java ||
189+
| Go | .go ||
190+
| Rust | .rs ||
191+
| C/C++ | .c, .cpp ||
192+
| Ruby | .rb ||
193+
| PHP | .php ||
194+
| Swift | .swift ||
195+
| Kotlin | .kt ||
196+
| Scala | .scala ||
197+
40198
## 🐳 Docker
41199

42200
```bash
43-
docker build -t ai-code-assistant .
44-
docker run -p 7861:7861 -e OPENAI_API_KEY=your-key ai-code-assistant
201+
docker build -t code-assistant .
202+
docker run -p 7860:7860 -e OPENAI_API_KEY=your_key code-assistant
203+
```
204+
205+
## 📁 Project Structure
206+
45207
```
208+
ai-code-assistant/
209+
├── context_loader.py # Index code
210+
├── query_engine.py # Query code
211+
├── gradio_app.py # Web UI
212+
├── requirements.txt
213+
├── Dockerfile
214+
└── examples/
215+
├── index_project.py
216+
└── ask_questions.py
217+
```
218+
219+
## 🤝 Contributing
220+
221+
See [CONTRIBUTING.md](CONTRIBUTING.md)
222+
223+
## ⭐ Support
46224

47-
## 📝 License
225+
If this saved you time, please star the repo!
48226

49-
MIT License
227+
---
50228

51-
## ⭐ Star if helpful!
229+
**Built with ❤️ by [walidsobhie-code](https://github.com/walidsobhie-code)**

0 commit comments

Comments
 (0)