# Supported Graph Database Technologies in code-graph-rag: Memgraph Integration Explained

> Discover code-graph-rag's supported graph database technologies. Learn how Memgraph powers graph storage and Qdrant manages vector embeddings for efficient code analysis.

- Repository: [Vitali Avagyan/code-graph-rag](https://github.com/vitali87/code-graph-rag)
- Tags: deep-dive
- Published: 2026-08-14

---

**The code-graph-rag project exclusively supports Memgraph as its graph database back-end, with Qdrant handling vector storage for embeddings.**

This open-source retrieval-augmented generation (RAG) system for codebases relies on a specific, tightly-coupled data stack. According to the vitali87/code-graph-rag source code, all graph operations flow through a dedicated Memgraph driver, while semantic search capabilities depend on a separate Qdrant vector store. No alternative graph databases are currently implemented.

## Graph Database: Memgraph

**Memgraph** serves as the sole supported graph database for storing code repository structure, relationships, and metadata.

### MemgraphIngestor: The Core Interface

All graph mutations route through `MemgraphIngestor`, defined in [`codebase_rag/services/graph_service.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/services/graph_service.py). This class implements the Bolt protocol client for connecting to Memgraph instances:

- **Host/port configuration**: Defaults to `localhost:7687` (standard Memgraph Bolt port)
- **Batch operations**: Configurable `batch_size` parameter for efficient bulk inserts
- **ACID compliance**: Leverages Memgraph's transactional guarantees for graph consistency

```python
from codebase_rag.services.graph_service import MemgraphIngestor
from pathlib import Path

# Initialize connection to running Memgraph instance

ingestor = MemgraphIngestor(
    host="localhost",
    port=7687,
    batch_size=500
)

# Connection is established lazily on first operation

```

### Graph Schema Implementation

The Memgraph integration follows a structured schema for code representation. Based on the architecture documentation in [`docs/architecture/graph-schema.md`](https://github.com/vitali87/code-graph-rag/blob/main/docs/architecture/graph-schema.md), the system stores:

- **Node types**: Files, functions, classes, modules, and AST elements
- **Relationship types**: `DEFINES`, `IMPORTS`, `CALLS`, `INHERITS_FROM`, `CONTAINS`
- **Properties**: Line numbers, signatures, docstrings, and file paths

```python
from codebase_rag.graph_updater import GraphUpdater

# Orchestrate full repository ingestion

updater = GraphUpdater(ingestor=ingestor, repo_path=Path("/path/to/repo"))
updater.update()  # Executes Cypher queries via MemgraphIngestor

```

### Real-Time Updates

The [`realtime_updater.py`](https://github.com/vitali87/code-graph-rag/blob/main/realtime_updater.py) module demonstrates production Memgraph usage, watching filesystem events and streaming incremental graph mutations:

```python

# From realtime_updater.py - continuous synchronization pattern

from codebase_rag.services.graph_service import MemgraphIngestor

ingestor = MemgraphIngestor(host="localhost", port=7687)

# File system events → parsed diffs → Cypher MERGE operations

```

## Vector Store: Qdrant

While not a graph database, **Qdrant** plays a critical complementary role as the embedding storage layer. Implemented in [`codebase_rag/vector_store.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/vector_store.py), the `QdrantVectorStore` class handles:

- Dense vector storage for code embeddings
- Approximate nearest neighbor (ANN) search for semantic retrieval
- Hybrid filtering combining vector similarity with metadata constraints

```python
from codebase_rag.vector_store import QdrantVectorStore

# Initialize from environment variables (QDRANT_URL, QDRANT_DB_PATH)

store = QdrantVectorStore()

# Store embeddings with associated metadata

store.upsert(
    collection="code_vectors",
    vectors=[{"id": "func_123", "vector": [0.1, ..., 0.9], "payload": {"file": "main.py"}}]
)

# Semantic search against code embeddings

results = store.search(
    collection="code_vectors",
    query_vector=[0.15, ..., 0.85],
    top_k=5
)

```

## Architecture: Dual-Store Design

The code-graph-rag system deliberately separates concerns across two specialized databases:

| Component | Technology | Responsibility | Source Path |
|-----------|-----------|--------------|-------------|
| **Graph engine** | Memgraph | Structural relationships, call graphs, inheritance hierarchies | [`codebase_rag/services/graph_service.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/services/graph_service.py) |
| **Vector engine** | Qdrant | Semantic embeddings, similarity search, natural language queries | [`codebase_rag/vector_store.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/vector_store.py) |

This separation allows optimized storage formats: Memgraph's native graph structure for traversals, Qdrant's HNSW index for vector similarity.

## Absence of Alternative Graph Databases

Source code analysis across `codebase_rag/**/*.py` reveals **no implementations** for:

- **Neo4j** (no `neo4j` or `neo4j-python-driver` imports)
- **TigerGraph** (no GSQL or TigerPython references)
- **JanusGraph** (no Gremlin traversal sources)
- **Amazon Neptune** or **Azure Cosmos DB** (no cloud-specific graph drivers)

The test suite in [`codebase_rag/tests/test_graph_service.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/tests/test_graph_service.py) confirms this: mocking substitutes are provided for `MemgraphIngestor` only, with no abstraction layer suggesting pluggable back-ends.

### Extending Support

Developers seeking alternative graph databases would need to implement a new ingestor class matching `MemgraphIngestor`'s interface:

1. Inherit from base ingestion protocol (if defined) or replicate method signatures
2. Implement connection management, transaction batching, and Cypher-equivalent query generation
3. Update `GraphUpdater` instantiation paths to accept the new driver

## Configuration Patterns

Both supported technologies follow environment-driven configuration:

```bash

# Memgraph connection

export MEMGRAPH_HOST=localhost
export MEMGRAPH_PORT=7687
export MEMGRAPH_BATCH_SIZE=500

# Qdrant connection

export QDRANT_URL=http://localhost:6333
export QDRANT_DB_PATH=/opt/qdrant/storage  # for local embedded mode

```

These variables are consumed at class instantiation time, with sensible defaults for local development.

## Summary

- **Memgraph** is the exclusively supported graph database, with `MemgraphIngestor` in [`codebase_rag/services/graph_service.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/services/graph_service.py) providing the complete integration
- **Qdrant** handles vector embeddings through `QdrantVectorStore` in [`codebase_rag/vector_store.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/vector_store.py)
- No abstraction layer exists for alternative graph databases—Memgraph is hard-coded as the graph back-end
- The dual-store architecture separates structural graph queries from semantic vector search
- All repository ingestion flows through `GraphUpdater`, which coordinates parsing and Memgraph mutation

## Frequently Asked Questions

### Does code-graph-rag support Neo4j?

No. The codebase contains no Neo4j driver imports, connection handling, or Cypher query builders. All graph operations are implemented specifically for Memgraph's Bolt protocol. Neo4j support would require a new ingestor class and query translation layer.

### Can I use code-graph-rag without a graph database?

Partially. The vector store (Qdrant) can operate independently for semantic code search. However, structural querying—call graphs, inheritance hierarchies, import relationships—requires Memgraph. The test suite provides mock ingestors for isolated unit testing.

### What version of Memgraph is required?

The source references standard Bolt protocol operations without version-specific features. Memgraph 2.x or later is recommended for full Cypher compatibility. The `mgclient` Python driver is used internally, which supports Memgraph 1.4+.

### Is there planned support for additional graph databases?

The current codebase shows no extension points for alternative graph engines. The `MemgraphIngestor` class is instantiated directly in production code paths rather than through a factory or registry pattern. Feature requests would need to propose a formal abstraction layer first.