Ask questions about YOUR codebase β AI that actually understands your code, not just general programming.
π€ HuggingFace π Try Live Demo
You: "How does authentication work?"
AI: "Authentication uses JWT tokens stored in localStorage.
The flow is: Login β Verify β Store JWT β
Attach JWT to all requests β Validate on backend..."
You: "Where is the database connection?"
AI: "Database connection is in src/db/connection.py
It uses SQLAlchemy with PostgreSQL..."
Stop googling YOUR own code. Ask your AI assistant that knows your codebase.
| Feature | Description |
|---|---|
| π§ Understands Your Code | Indexes your entire codebase |
| π Semantic Search | Find code by what it does, not just names |
| π Multi-Language | Python, JavaScript, Go, Rust, Java, etc. |
| π€ GPT-4 Powered | State-of-the-art code understanding |
| π¬ Chat Interface | Ask questions naturally |
| ποΈ Gradio UI | Beautiful web interface |
git clone https://github.com/walidsobhie-code/ai-code-assistant.git
cd ai-code-assistant
pip install -r requirements.txt
cp .env.example .env
# Add your OPENAI_API_KEY# Index your entire project
python context_loader.py --path ./my_project
# Output:
# π Loading 247 code files...
# β
Indexed Python (89 files), JavaScript (67 files), etc.
# π Total chunks: 1,432# Query your codebase
python query_engine.py "How does the payment flow work?"
# π¬ AI: "Payment flow uses Stripe:
# 1. User selects products β Cart.checkout()
# 2. Create Stripe session β Payment.create_session()
# 3. Redirect to Stripe β payment.process()
# 4. Webhook confirms β Order.confirm()
# Files: payment.py, checkout.py, webhook.py"python query_engine.py --interactive
# π¬ Chat mode
# You: How does caching work?
# AI: Caching is implemented using Redis in src/cache/redis.py...
# You: Find all API endpoints
# AI: 23 endpoints found in src/api/:
# - GET /users/:id
# - POST /orders
# - PUT /payments/:id
# ...βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π» AI Code Assistant β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β π Index: my_project/ [π] β
β Status: β
247 files indexed β
β β
β π¬ Ask Questions β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β How does authentication work? β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
β [π¬ Ask] β
β β
β π‘ Answer: β
β Authentication uses JWT tokens: β
β β
β π src/auth/jwt.py (92% match) β
β π src/middleware/auth.py (87% match) β
β π src/routes/auth.py (81% match) β
β β
β JWT tokens are created on login and validated β
β on every protected route... β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
from context_loader import CodebaseIndexer
from query_engine import CodeAssistant
# Step 1: Index your codebase
indexer = CodebaseIndexer()
result = indexer.index_codebase("./my_project")
print(f"Indexed {result['files']} files")
# Output: Indexed 247 files in 12 languages
# Step 2: Ask questions
assistant = CodeAssistant()
result = assistant.query("Where is the API handler?")
print(result["answer"])
# Output: The API handler is in src/api/handler.py.
# It uses FastAPI with the following routes:...
# Step 3: Get sources
for source in result["sources"]:
print(f"π {source}")
# π src/api/handler.py
# π src/routes/api.py$ python query_engine.py "What does this authentication system do?"
AI: "This is a JWT-based auth system:
- Login: POST /auth/login β validates credentials
- Token: Returns JWT with 24h expiry
- Middleware: Verifies JWT on protected routes
- Refresh: POST /auth/refresh β renews token
- Logout: Invalidates token in Redis"$ python query_engine.py "Find all database queries"
AI: "Found 23 database queries across 12 files:
- src/models/user.py: get_user(), create_user()
- src/models/order.py: get_orders(), create_order()
- src/db/connection.py: query(), transaction()
..."$ python query_engine.py "Document the payment module"
AI: "## Payment Module
### Classes
- PaymentIntent: Handles Stripe payment intents
- Refund: Manages partial/full refunds
- WebhookHandler: Processes Stripe webhooks
### Methods
- process_payment(): Initiates Stripe checkout
- confirm_payment(): Confirms payment success
- refund_payment(): Processes refund via Stripe"| Language | Extensions | Status |
|---|---|---|
| Python | .py | β |
| JavaScript | .js, .jsx | β |
| TypeScript | .ts, .tsx | β |
| Java | .java | β |
| Go | .go | β |
| Rust | .rs | β |
| C/C++ | .c, .cpp | β |
| Ruby | .rb | β |
| PHP | .php | β |
| Swift | .swift | β |
| Kotlin | .kt | β |
| Scala | .scala | β |
docker build -t code-assistant .
docker run -p 7860:7860 -e OPENAI_API_KEY=your_key code-assistantai-code-assistant/
βββ context_loader.py # Index code
βββ query_engine.py # Query code
βββ gradio_app.py # Web UI
βββ requirements.txt
βββ Dockerfile
βββ examples/
βββ index_project.py
βββ ask_questions.py
See CONTRIBUTING.md
If this saved you time, please star the repo!
Built with β€οΈ by walidsobhie-code
- [Planned] Web version / hosted demo
- [Planned] API endpoint for production use
- [Planned] Support for more languages
- [In Progress] Performance optimizations
- [Done] Gradio web interface
- [Done] Docker deployment
Have a project using this? Send a PR to add your company!
- (coming soon β be the first to list your project!)
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
