MCPcopy Index your code
hub / github.com/GrafeoDB/grafeo

github.com/GrafeoDB/grafeo @v0.5.42

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.5.42 ↗ · + Follow
20,857 symbols 97,455 edges 748 files 5,108 documented · 24%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

CI grafeo.dev codecov CodSpeed Badge Crates.io PyPI npm wasm NuGet pub.dev Go Web Server License MSRV Python Discord

Grafeo

Grafeo is a graph database built in Rust from the ground up for speed and low memory use. It runs embedded as a library or as a standalone server, with in-memory or persistent storage and full ACID transactions.

In our graph-bench suite (which includes workloads inspired by the LDBC Social Network Benchmark), Grafeo is the fastest tested graph database in both embedded and server configurations, while using a fraction of the memory of some of the alternatives.

Grafeo Playground

Grafeo supports both Labeled Property Graph (LPG) and Resource Description Framework (RDF) data models and all major query languages.

Features

Core Capabilities

  • Dual data model support: LPG and RDF with optimized storage for each
  • Multi-language queries: GQL, Cypher, Gremlin, GraphQL, SPARQL and SQL/PGQ
  • Embeddable with zero external dependencies: no JVM, no Docker, no external processes
  • Multi-language bindings: Python (PyO3), Node.js/TypeScript (napi-rs), Go (CGO), C (FFI), C# (.NET 8 P/Invoke), Dart (dart:ffi), WebAssembly (wasm-bindgen)
  • In-memory and persistent storage modes
  • MVCC transactions with snapshot isolation

Query Languages

  • GQL (ISO/IEC 39075) with Unicode identifiers per spec
  • Cypher (openCypher 9.0)
  • Gremlin (Apache TinkerPop)
  • GraphQL
  • SPARQL (W3C 1.1) with SHACL validation and Ring Index WCOJ planner
  • SQL/PGQ (SQL:2023)
  • EXPLAIN / EXPLAIN ANALYZE across all six languages

Vector Search & AI

  • Vector as a first-class type: Value::Vector(Arc<[f32]>) stored alongside graph data
  • HNSW index: O(log n) approximate nearest neighbor search with tunable recall
  • Distance functions: Cosine, Euclidean, Dot Product, Manhattan (SIMD-accelerated: AVX2, SSE, NEON)
  • Vector quantization: Scalar (f32 → u8), Binary (1-bit) and Product Quantization (8-32x compression)
  • BM25 text search: Full-text inverted index with Unicode tokenizer and stop word removal
  • Hybrid search: Combined text + vector search with Reciprocal Rank Fusion (RRF) or weighted fusion
  • Change data capture: Before/after property snapshots for audit trails and history tracking
  • Hybrid graph+vector queries: Combine graph traversals with vector similarity in GQL and SPARQL
  • Memory-mapped storage: Disk-backed vectors with LRU cache for large datasets
  • Batch operations: Parallel multi-query search via rayon

Performance Features

  • Push-based vectorized execution with adaptive chunk sizing
  • Morsel-driven parallelism with auto-detected thread count
  • Block-STM conflict partitioning for parallel transaction re-execution
  • Columnar storage with dictionary, delta and RLE compression
  • Cost-based optimizer with DPccp join ordering and histograms
  • Zone maps for intelligent data skipping (including vector zone maps)
  • Adaptive query execution with runtime re-optimization
  • Transparent spilling for out-of-core processing
  • Streaming execution for large result sets without buffering
  • Bloom filters for efficient membership tests
  • Writable layered compact store: columnar base with mutable overlay, recompact() to merge

Security

  • Encryption at rest (encryption feature): AES-256-GCM for WAL records and .grafeo sections, password-based (Argon2id) or raw-key setup
  • Role-based access control: Admin, ReadWrite, ReadOnly roles enforced across all six query languages
  • Per-graph access grants: scope an identity's access to specific named graphs
  • SHACL validation (shacl feature): W3C Shapes Constraint Language with all 28 Core constraint types and SHACL-SPARQL
  • Resource limits: query timeouts, property size caps, HNSW max_elements bound

Operations & Observability

  • Incremental backup and point-in-time recovery: backup_full, backup_incremental, restore_to_epoch
  • Prometheus metrics (metrics feature): query, transaction, session, cache, and GC counters with text export
  • Change data capture: before/after property snapshots with epoch-bounded retention
  • Async storage (async-storage feature): non-blocking WAL and snapshot I/O via tokio
  • Tracing (tracing feature): opt-in observability spans and events
  • Bulk export: Arrow IPC, Polars, pandas, GEXF (Gephi), GraphML (Cytoscape, yEd, NetworkX)
  • Bulk import: CSV, JSONL, TSV, Matrix Market (MMIO), Turtle, N-Triples with streaming loaders

Benchmarks

Tested with graph-bench, which includes workloads inspired by the LDBC Social Network Benchmark. These are not official LDBC Benchmark results (see disclaimer).

Embedded (SF0.1, in-process):

Database SNB Interactive Memory Graph Analytics Memory
Grafeo 2,904 ms 136 MB 0.4 ms 43 MB
LadybugDB(Kuzu) 5,333 ms 4,890 MB 225 ms 250 MB
FalkorDB Lite 7,454 ms 156 MB 89 ms 88 MB

Server (SF0.1, over network):

Database SNB Interactive Graph Analytics
Grafeo Server 730 ms 15 ms
Memgraph 4,113 ms 19 ms
Neo4j 6,788 ms 253 ms
ArangoDB 40,043 ms 22,739 ms

Full results: embedded | server

Query Language & Data Model Support

Query Language LPG RDF
GQL -
Cypher -
GraphQL
Gremlin -
SPARQL -
SQL/PGQ -

Grafeo uses a modular translator architecture where query languages are parsed into ASTs, then translated to a unified logical plan that executes against the appropriate storage backend (LPG or RDF).

Data Models

  • LPG (Labeled Property Graph): Nodes with labels and properties, edges with types and properties. Ideal for social networks, knowledge graphs and application data.
  • RDF (Resource Description Framework): Triple-based storage (subject-predicate-object) with SPO/POS/OSP indexes. Ideal for semantic web, linked data and ontology-based applications.

Installation

Rust

cargo add grafeo

Grafeo uses persona-based feature profiles that describe use cases. Compose them freely:

# Default: LPG with GQL, AI, algorithms, parallel execution
cargo add grafeo

# Compose profiles for your use case
cargo add grafeo --features rdf          # Add RDF/SPARQL support
cargo add grafeo --features analytics    # Add graph algorithms
cargo add grafeo --features ai           # Add vector/text/hybrid search
cargo add grafeo --features enterprise   # Full feature set

# Or use individual flags
cargo add grafeo --no-default-features --features gql       # Minimal: GQL only
cargo add grafeo --no-default-features --features languages  # All query languages
cargo add grafeo --features embed                            # ONNX embeddings (opt-in, ~17MB)
Profile Contents Use case
lpg GQL, AI, algorithms, parallel Default for libraries and apps
rdf SPARQL, triple-store, ring-index Knowledge graphs, linked data
analytics Algorithms, parallel Graph analytics pipelines
ai Vector, text, hybrid search, CDC RAG, semantic search
edge GQL, compact, regex-lite WASM, resource-constrained
enterprise Metrics, tracing, async I/O Platform operators, observability

Node.js / TypeScript

npm install @grafeo-db/js

Go

go get github.com/GrafeoDB/grafeo/crates/bindings/go

WebAssembly

npm install @grafeo-db/wasm

C# / .NET

dotnet add package Grafeo

Dart

# pubspec.yaml
dependencies:
  grafeo: ^0.5.42

Python

pip install grafeo
# or with uv
uv add grafeo

With CLI support:

pip install grafeo[cli]
# or with uv
uv add grafeo[cli]

Quick Start

Node.js / TypeScript

const { GrafeoDB } = require('@grafeo-db/js');

// Create an in-memory database
const db = await GrafeoDB.create();

// Or open a persistent database
// const db = await GrafeoDB.create({ path: './my-graph.db' });

// Create nodes and relationships
await db.execute("INSERT (:Person {name: 'Alix', age: 30})");
await db.execute("INSERT (:Person {name: 'Gus', age: 25})");
await db.execute(`
    MATCH (a:Person {name: 'Alix'}), (b:Person {name: 'Gus'})
    INSERT (a)-[:KNOWS {since: 2020}]->(b)
`);

// Query the graph
const result = await db.execute(`
    MATCH (p:Person)-[:KNOWS]->(friend)
    RETURN p.name, friend.name
`);
console.log(result.toArray());

await db.close();

Python

import grafeo

# Create an in-memory database
db = grafeo.GrafeoDB()

# Or open/create a persistent database
# db = grafeo.GrafeoDB("/path/to/database")

# Create nodes using GQL
db.execute("INSERT (:Person {name: 'Alix', age: 30})")
db.execute("INSERT (:Person {name: 'Gus', age: 25})")

# Create a relationship
db.execute("""
    MATCH (a:Person {name: 'Alix'}), (b:Person {name: 'Gus'})
    INSERT (a)-[:KNOWS {since: 2020}]->(b)
""")

# Query the graph
result = db.execute("""
    MATCH (p:Person)-[:KNOWS]->(friend)
    RETURN p.name, friend.name
""")

for row in result:
    print(row)

# Or use the direct API
node = db.create_node(["Person"], {"name": "Harm"})
print(f"Created node with ID: {node.id}")

# Manage labels
db.add_node_label(node.id, "Employee")     # Add a label
db.remove_node_label(node.id, "Contractor") # Remove a label
labels = db.get_node_labels(node.id)        # Get all labels

Admin APIs (Python)

# Database inspection
db.info()           # Overview: mode, counts, persistence
db.detailed_stats() # Memory usage, index counts
db.schema()         # Labels, edge types, property keys
db.validate()       # Integrity check

# Named graphs and schemas
db.create_graph("social")
db.set_graph("social")
db.list_graphs()               # ['social']
db.set_schema("v1")
db.current_schema()            # 'v1'

# Graph projections (filtered virtual views)
db.create_projection("people", node_labels=["Person"], edge_types=["KNOWS"])
db.list_projections()          # ['people']
db.drop_projection("people")

# Data import
db.import_csv("users.csv", "Person", headers=True)
db.import_jsonl("events.jsonl", "Event")

# Backup and restore
db.backup_full("/backups/full")
db.backup_incremental("/backups/incr")
GrafeoDB.restore_to_epoch("/backups/full", epoch=100, output_path="./restored")

# Persistence control
db.save("/path/to/backup")    # Save to disk
db.to_memory()                # Create in-memory copy
GrafeoDB.open_in_memory(path) # Load as in-memory

# WAL management
db.wal_status()      # WAL info
db.wal_checkpoint()  # Force checkpoint

Rust

use grafeo::GrafeoDB;

fn main() {
    // Create an in-memory database
    let db = GrafeoDB::new_in_memory();

    // Or open a persistent database
    // let db = GrafeoDB::open("./my_database").unwrap();

    // Execute GQL queries
    db.execute("INSERT (:Person {name: 'Alix'})").unwrap();

    let result = db.execute("MATCH (p:Person) RETURN p.name").unwrap();
    for row in result.rows() {
        println!("{:?}", row);
    }
}

Vector Search

```python import grafeo

db = grafeo.GrafeoDB()

Store documents with embeddings

db.execute("""INSERT (:Document { title: 'Graph Databa

Extension points exported contracts — how you extend this code

MemoryConsumer (Interface)
Trait for subsystems that consume managed memory. Memory consumers register with the buffer manager and participate in [11 …
crates/grafeo-common/src/memory/buffer/consumer.rs
Procedure (Interface)
Unified interface for built-in procedures callable via `CALL`. Subsumes graph algorithms (through [`GraphAlgorithmProce [7 …
crates/grafeo-engine/src/procedures.rs
GraphAlgorithm (Interface)
A graph algorithm that can be executed on any graph store. This trait extends the base `Algorithm` trait with graph-spe [10 …
crates/grafeo-adapters/src/plugins/algorithms/traits.rs
GraphStore (Interface)
Read-only graph operations used by the query engine. This trait captures the minimal surface that scan, expand, filter, [9 …
crates/grafeo-core/src/graph/traits.rs
AsyncStorageBackend (Interface)
Async storage backend for I/O-bound persistence operations. This trait covers the persistence layer (WAL batches, snaps [3 …
crates/grafeo-storage/src/async_backend.rs
VectorIndexOption (FuncType)
VectorIndexOption configures vector index creation.
crates/bindings/go/types.go
Section (Interface)
A serializable section for the `.grafeo` container. Implemented in `grafeo-core` for each data model (LPG, RDF) and ind [11 …
crates/grafeo-common/src/storage/section.rs
FromValue (Interface)
Converts a [`grafeo_common::types::Value`] to a concrete Rust type. Implemented for common types like `i64`, `f64`, `St [4 …
crates/grafeo-engine/src/database/mod.rs

Core symbols most depended-on inside this repo

execute
called by 3980
crates/grafeo-engine/src/session/mod.rs
clone
called by 2892
crates/grafeo-core/src/execution/chunk.rs
to_string
called by 2712
crates/grafeo-core/src/graph/rdf/turtle/serializer.rs
session
called by 2509
crates/grafeo-engine/src/database/mod.rs
expect
called by 1752
crates/grafeo-adapters/src/query/gql/parser.rs
push
called by 1125
crates/grafeo-core/src/codec/bitvec.rs
collect
called by 966
crates/grafeo-engine/src/query/executor/stream.rs
collect
called by 949
crates/grafeo-core/src/execution/operators/accumulator.rs

Shape

Function 10,945
Method 8,163
Class 1,387
Enum 292
Interface 51
Struct 15
FuncType 2
TypeAlias 2

Languages

Rust87%
Python10%
C#2%
Go1%
TypeScript1%
C++1%

Modules by API surface

crates/grafeo-adapters/src/query/gql/parser.rs355 symbols
crates/grafeo-engine/src/session/mod.rs212 symbols
crates/grafeo-core/src/graph/compact/layered.rs203 symbols
crates/grafeo-adapters/src/query/cypher/parser.rs203 symbols
crates/grafeo-engine/tests/regression_external.rs202 symbols
crates/bindings/python/tests/lpg/gql/test_regression_external.py201 symbols
crates/grafeo-core/src/graph/compact/column.rs185 symbols
crates/grafeo-core/src/execution/operators/filter.rs181 symbols
crates/grafeo-engine/src/database/mod.rs175 symbols
crates/grafeo-engine/tests/spec_compliance.rs171 symbols
crates/bindings/python/src/database.rs170 symbols
crates/grafeo-engine/src/query/planner/rdf/mod.rs167 symbols

For agents

$ claude mcp add grafeo \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact