Skip to content

walidsobhie-code/ai-code-assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸ’» AI Code Assistant

Ask questions about YOUR codebase β€” AI that actually understands your code, not just general programming.

Python License Stars

πŸ€— HuggingFace πŸš€ Try Live Demo

🎯 What It Does

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.

✨ Features

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

πŸš€ Quick Start

Install

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 Codebase

# 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

Ask Questions

# 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"

Interactive Chat

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
#    ...

🎨 Web UI Demo

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  πŸ’» 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...                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ’» Python API

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

πŸ” Real Examples

Understand Legacy Code

$ 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"

Find Code Fast

$ 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()
    ..."

Document Automatically

$ 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"

πŸ“Š Supported Languages

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

docker build -t code-assistant .
docker run -p 7860:7860 -e OPENAI_API_KEY=your_key code-assistant

πŸ“ Project Structure

ai-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

🀝 Contributing

See CONTRIBUTING.md

⭐ Support

If this saved you time, please star the repo!


Built with ❀️ by walidsobhie-code

πŸ–₯️ Demo Screenshot

Code Assistant Demo

πŸ—ΊοΈ Roadmap

  • [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

🏒 Used By

Have a project using this? Send a PR to add your company!

  • (coming soon β€” be the first to list your project!)

🀝 Contributors

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

GitHub Contributors

About

AI-powered coding assistant that understands YOUR codebase. Get answers, generate tests, refactor code.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors