CoolFace
Apppublic

salim0986/graph-bug-ai

sourceHugging Facemitupdated 4mo agoView on Hugging Face
0likes
App README

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

bash
pip install -r requirements.txt

2. Configure Environment

Copy the example environment file:

bash
cp .env.example .env

Edit .env to match your setup. For local development with Docker, the defaults should work.

3. Start Infrastructure

Start Neo4j and Qdrant using Docker Compose:

bash
docker-compose up -d

This starts:

  • β€”Neo4j on ports 7474 (HTTP) and 7687 (Bolt)
  • β€”Qdrant on port 6333

4. Run the Service

bash
# 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 4

5. Verify Setup

Check the health endpoint:

bash
curl http://localhost:8000/health

API Endpoints

Health Check

GET /health

Returns 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):

VariableDescriptionDefault
NEO4J_URINeo4j connection URIneo4j://neo4j:7687
NEO4J_USERNeo4j usernameneo4j
NEO4J_PASSWORDNeo4j passwordgraphbug123
QDRANT_URLQdrant connection URLhttp://qdrant:6333
EMBEDDING_MODELSentence transformer modelall-MiniLM-L6-v2
TEMP_REPOS_DIRTemporary clone directory./temp_repos
LOG_LEVELLogging levelINFO

Testing

Run the pipeline test to verify everything works:

bash
python pipeline_test.py

Test the search functionality:

bash
python verify_search.py

Supported 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

  1. 1.Check if tree-sitter-languages supports it
  2. 2.Add the extension mapping to src/parser.py
  3. 3.Ensure the query file exists in src/queries/{language}/tags.scm

Troubleshooting

Import Errors

Make sure dependencies are installed:

bash
pip install -r requirements.txt

Connection Errors

Check that Docker services are running:

bash
docker-compose ps

Check service logs:

bash
docker-compose logs neo4j
docker-compose logs qdrant

Neo4j Authentication

If you changed the password, update both:

  • β€”docker-compose.yml (NEO4J_AUTH environment variable)
  • β€”.env file (NEO4J_PASSWORD variable)

Permission Errors

Ensure data directories are writable:

bash
chmod -R 755 data/

License

MIT