salim0986/graph-bug-ai
Graph Bug AI Service
AI-powered code intelligence service that builds knowledge graphs and semantic search for GitHub repositories.
Features
- π³ Multi-language parsing - Supports 35+ programming languages using tree-sitter
- πΈοΈ Knowledge graphs - Creates structured graphs of code relationships in Neo4j
- π Semantic search - Vector-based similarity search using Qdrant
- π Multi-tenant - Isolated by repository ID
- β‘ Background processing - Async repository ingestion
Architecture
- Parser (
src/parser.py) - Universal code parser using tree-sitter - Graph Builder (
src/graph_builder.py) - Neo4j knowledge graph construction - Vector Builder (
src/vector_builder.py) - Qdrant vector embeddings - API (
src/api.py) - FastAPI REST endpoints
Setup
1. Install Dependencies
pip install -r requirements.txt2. Configure Environment
Copy the example environment file:
cp .env.example .envEdit .env to match your setup. For local development with Docker, the defaults should work.
3. Start Infrastructure
Start Neo4j and Qdrant using Docker Compose:
docker-compose up -dThis starts:
- Neo4j on ports 7474 (HTTP) and 7687 (Bolt)
- Qdrant on port 6333
4. Run the Service
# Development
uvicorn src.api:app --reload --host 0.0.0.0 --port 8000
# Production
uvicorn src.api:app --host 0.0.0.0 --port 8000 --workers 45. Verify Setup
Check the health endpoint:
curl http://localhost:8000/healthAPI Endpoints
Health Check
GET /healthReturns service status and connectivity to Neo4j and Qdrant.
Ingest Repository
POST /ingest
Content-Type: application/json
{
"repo_url": "https://github.com/user/repo.git",
"repo_id": "unique-repo-id",
"installation_id": "github-app-installation-id"
}Queues a repository for background processing. Returns immediately.
Search Repository
POST /query
Content-Type: application/json
{
"repo_id": "unique-repo-id",
"query": "function that calculates tax"
}Returns semantically similar code snippets.
Configuration
All configuration is done via environment variables (see .env.example):
Testing
Run the pipeline test to verify everything works:
python pipeline_test.pyTest the search functionality:
python verify_search.pySupported Languages
JavaScript, TypeScript, Python, Go, Rust, Java, Ruby, PHP, C#, C++, C, Bash, Lua, YAML, TOML, Markdown, and 20+ more.
Development
Project Structure
ai-service/
βββ src/
β βββ api.py # FastAPI application
β βββ parser.py # Tree-sitter parser
β βββ graph_builder.py # Neo4j integration
β βββ vector_builder.py # Qdrant integration
β βββ config.py # Configuration management
β βββ logger.py # Logging setup
β βββ queries/ # Tree-sitter query files
βββ data/ # Persistent data (gitignored)
βββ temp_repos/ # Temporary clones (gitignored)
βββ docker-compose.yml # Infrastructure setup
βββ requirements.txt # Python dependencies
βββ .env # Environment config (gitignored)Adding Language Support
- Check if tree-sitter-languages supports it
- Add the extension mapping to
src/parser.py - Ensure the query file exists in
src/queries/{language}/tags.scm
Troubleshooting
Import Errors
Make sure dependencies are installed:
pip install -r requirements.txtConnection Errors
Check that Docker services are running:
docker-compose psCheck service logs:
docker-compose logs neo4j
docker-compose logs qdrantNeo4j Authentication
If you changed the password, update both:
docker-compose.yml(NEO4J_AUTH environment variable).envfile (NEO4J_PASSWORD variable)
Permission Errors
Ensure data directories are writable:
chmod -R 755 data/License
MIT
