Developer Tools Databases 33 vues

GrafeoDB/grafeo: Pure-Rust Graph Database with LPG+RDF Dual Support

M
Mohamed IDBRAHIM
Auteur
GrafeoDB/grafeo: Pure-Rust Graph Database with LPG+RDF Dual Support

GrafeoDB/grafeo: Pure-Rust Graph Database with LPG+RDF Dual Support

Developers building graph-powered applications face a persistent trade-off: embeddable engines lack query language breadth, while full-featured databases demand heavy infrastructure. JVM dependencies, Docker↗ Bright Coding Blog containers, and external processes create friction for teams shipping to edge environments or embedding databases directly into applications. Meanwhile, the rise of AI workloads—vector search, semantic retrieval, hybrid graph+vector queries—has exposed gaps in traditional graph database architectures. Teams need a single engine that handles property graphs and RDF, runs in-process or as a server, and integrates with modern language ecosystems without compromising on performance or memory efficiency.

GrafeoDB/grafeo addresses this directly. Built from the ground up in Rust, it offers dual data model support (LPG and RDF), six query languages, and embeddable deployment with zero external dependencies. With 696 GitHub stars, 30 forks, and active development through July 2026, it represents a credible emerging option for developers evaluating graph infrastructure.

What is GrafeoDB/grafeo?

Grafeo is a graph database implemented entirely in Rust, designed for both embedded library use and standalone server deployment. It supports in-memory and persistent storage modes with full ACID transactions and MVCC snapshot isolation. The project is Apache 2.0 licensed and maintains an MSRV of Rust 1.91.1.

The database distinguishes itself through dual data model support: the Labeled Property Graph (LPG) model familiar from Neo4j and the Resource Description Framework (RDF) triple-store model used in semantic web applications. Most graph databases commit to one paradigm; Grafeo's unified logical plan architecture allows both to coexist with optimized storage backends for each.

Performance claims are substantiated through the project's graph-bench suite, which includes workloads inspired by the LDBC Social Network Benchmark. In embedded configuration (SF0.1), Grafeo completed SNB Interactive queries in 2,904 ms using 136 MB of memory, versus LadybugDB (Kuzu) at 5,333 ms / 4,890 MB and FalkorDB Lite at 7,454 ms / 156 MB. Server benchmarks show similar positioning: 730 ms for SNB Interactive versus Memgraph at 4,113 ms and Neo4j at 6,788 ms. These are not official LDBC results—the project disclaims this explicitly—but they provide directional signal for evaluation.

The ecosystem extends beyond the core engine to include a standalone server (grafeo-server), WebAssembly bindings for browser deployment, LangChain and LlamaIndex integrations for AI applications, and client libraries across Python↗ Bright Coding Blog, Node.js, Go, C#, Dart, and WebAssembly.

Key Features

Query Language Breadth Grafeo supports six query languages through a modular translator architecture: GQL (ISO/IEC 39075), Cypher (openCypher 9.0), Gremlin (Apache TinkerPop), GraphQL, SPARQL (W3C 1.1), and SQL/PGQ (SQL:2023). All languages support EXPLAIN and EXPLAIN ANALYZE for query plan inspection. This coverage exceeds most open-source alternatives and positions Grafeo for standards compliance as GQL adoption accelerates.

Vector Search and AI Integration Vector search is implemented as a first-class type (Value::Vector(Arc<[f32]>)) rather than bolt-on functionality. Features include HNSW approximate nearest neighbor indexing with O(log n) search complexity, SIMD-accelerated distance functions (AVX2, SSE, NEON), scalar/binary/product quantization for compression, and hybrid search combining BM25 text retrieval with vector similarity via Reciprocal Rank Fusion or weighted fusion. Memory-mapped storage with LRU caching supports datasets exceeding RAM.

Execution Engine The query processor uses push-based vectorized execution with adaptive chunk sizing, morsel-driven parallelism with auto-detected thread counts, and Block-STM conflict partitioning for parallel transaction re-execution. A cost-based optimizer implements DPccp join ordering with histograms. Zone maps enable data skipping at the block level, including specialized vector zone maps for ANN queries.

Storage Architecture Columnar storage with dictionary, delta, and run-length encoding compression underlies both LPG and RDF backends. The "writable layered compact store" pattern provides a mutable overlay atop immutable columnar bases, with explicit recompact() operations to merge. Transparent spilling enables out-of-core processing for large intermediates.

Security and Operations Optional AES-256-GCM encryption at rest (Argon2id password-derived or raw keys), role-based access control (Admin/ReadWrite/ReadOnly), per-graph access grants, and SHACL validation with all 28 Core constraint types. Incremental backup with point-in-time recovery, Prometheus metrics export, and optional async I/O via tokio round out operational features.

Use Cases

Embedded Knowledge Graphs in Rust Applications Teams building Rust-native applications—telemetry pipelines, security tools, or network analyzers—can embed Grafeo directly without JVM or Docker overhead. The zero-dependency embedded mode with full GQL support enables complex graph analytics within single-binary deployments.

AI and Retrieval-Augmented Generation (RAG) The vector+graph hybrid architecture suits emerging RAG patterns where structured relationships (LPG/RDF) coexist with semantic embeddings. The LangChain and LlamaIndex integrations, plus the dedicated grafeo-memory project for LLM fact extraction and deduplication, position this as infrastructure for AI agents requiring persistent structured memory.

Semantic Web and Linked Data RDF support with SPARQL 1.1, SHACL validation, and Ring Index WCOJ planner provides a modern alternative to legacy triple stores. The SPO/POS/OSP index structure and Turtle/N-Triples import support standard linked data workflows.

Edge and WebAssembly Deployment The edge feature profile (GQL, compact storage, regex-lite) and WebAssembly bindings enable graph databases in browsers, serverless functions, and resource-constrained environments. The grafeo-web project provides IndexedDB-persistent browser-based graphs.

Multi-Language Data Science Pipelines Python bindings with pandas/Polars/Arrow export, plus Node.js and Go libraries, allow Grafeo to serve as a unified graph layer across polyglot teams without separate database infrastructure.

Installation & Setup

Rust

cargo add grafeo

Grafeo uses persona-based feature profiles that compose for specific use cases:

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

# Add RDF/SPARQL support
cargo add grafeo --features rdf

# Add graph algorithms
cargo add grafeo --features analytics

# Add vector/text/hybrid search
cargo add grafeo --features ai

# Full feature set
cargo add grafeo --features enterprise

# Minimal: GQL only
cargo add grafeo --no-default-features --features gql

# All query languages
cargo add grafeo --no-default-features --features languages

# ONNX embeddings (~17MB, opt-in)
cargo add grafeo --features embed

Profile reference:

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

Python

pip install grafeo
# or with uv
uv add grafeo

# With CLI support
pip install grafeo[cli]
uv add grafeo[cli]

Requires Python 3.12+.

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 8

dotnet add package Grafeo

Dart

# pubspec.yaml
dependencies:
  grafeo: ^0.5.42

Real Code Examples

Python: Basic Graph Operations

The Python API supports both direct method calls and GQL execution:

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 with property
db.execute("""
    MATCH (a:Person {name: 'Alix'}), (b:Person {name: 'Gus'})
    INSERT (a)-[:KNOWS {since: 2020}]->(b)
""")

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

for row in result:
    print(row)

# Direct API for programmatic access
node = db.create_node(["Person"], {"name": "Harm"})
print(f"Created node with ID: {node.id}")

# Label management
db.add_node_label(node.id, "Employee")
labels = db.get_node_labels(node.id)

This demonstrates Grafeo's dual API surface: declarative GQL for complex patterns and imperative methods for application logic requiring fine-grained control.

Python: Vector Search

import grafeo

db = grafeo.GrafeoDB()

# Store documents with embeddings
db.execute("""INSERT (:Document {
    title: 'Graph Databases',
    embedding: vector([0.1, 0.8, 0.3, 0.5])
})""")
db.execute("""INSERT (:Document {
    title: 'Vector Search',
    embedding: vector([0.2, 0.7, 0.4, 0.6])
})""")
db.execute("""INSERT (:Document {
    title: 'Cooking Recipes',
    embedding: vector([0.9, 0.1, 0.2, 0.1])
})""")

# Create HNSW index for approximate nearest neighbor search
db.execute("""
    CREATE VECTOR INDEX doc_idx ON :Document(embedding)
    DIMENSION 4 METRIC 'cosine'
""")

# Query with cosine similarity threshold
query = [0.15, 0.75, 0.35, 0.55]
result = db.execute(f"""
    MATCH (d:Document)
    WHERE cosine_similarity(d.embedding, vector({query})) > 0.9
    RETURN d.title, cosine_similarity(d.embedding, vector({query})) AS score
    ORDER BY score DESC
""")

for row in result:
    print(row)  # Returns: Graph Databases, Vector Search

The vector() constructor and cosine_similarity() function integrate naturally into GQL patterns, enabling hybrid queries that combine graph traversal predicates with semantic similarity filters.

Node.js: Embedded Database

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

// In-memory instance
const db = await GrafeoDB.create();

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

// Insert nodes
await db.execute("INSERT (:Person {name: 'Alix', age: 30})");
await db.execute("INSERT (:Person {name: 'Gus', age: 25})");

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

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

await db.close();

The async/await API follows JavaScript↗ Bright Coding Blog conventions while exposing the same GQL surface available in other bindings.

Rust: Minimal Example

use grafeo::GrafeoDB;

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

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

    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);
    }
}

The Rust API is the most direct, with Result-based error handling and no async runtime requirement for embedded use.

Advanced Usage & Best Practices

Feature Profile Selection The default lpg profile pulls in AI and analytics capabilities that may be unnecessary for simple deployments. For WASM or constrained environments, explicitly use --no-default-features --features edge to minimize binary size. The embed feature adds ~17MB for ONNX inference—only enable if generating embeddings in-database.

Storage Mode Trade-offs In-memory mode provides lowest latency for working sets fitting in RAM. Persistent mode with memory-mapped vectors and LRU caching suits larger-than-RAM datasets, particularly for vector search where the HNSW graph structure may exceed available memory.

Query Planning Use EXPLAIN ANALYZE across all six supported languages to verify plan quality. The cost-based optimizer with histograms generally produces sound plans, but complex multi-hop LPG queries with variable-length paths may benefit from explicit join ordering hints where the schema is well-understood.

Backup Strategy The incremental backup with epoch-bounded retention supports point-in-time recovery. For production deployments, combine backup_full baselines with backup_incremental and test restore_to_epoch procedures before relying on them operationally.

Security Hardening Enable the encryption feature for AES-256-GCM at rest. The Argon2id key derivation is preferred over raw-key configuration for password-based setups. RBAC roles apply across all query languages—verify that SPARQL endpoints exposed to untrusted clients have appropriate ReadOnly grants.

Comparison with Alternatives

Dimension GrafeoDB/grafeo Kuzu (LadybugDB) Neo4j Community
Language Rust (embeddable) C++ (embeddable) Java (JVM required)
Data models LPG + RDF LPG only LPG only
Query languages GQL, Cypher, Gremlin, GraphQL, SPARQL, SQL/PGQ Cypher Cypher, GQL (partial)
Vector search Native HNSW, hybrid search None Via separate GDS library
Deployment Embedded, server, WASM Embedded, server Server, desktop
License Apache 2.0 MIT GPL v3 / Commercial
Memory (SF0.1 SNB) 136 MB 4,890 MB Not tested in graph-bench

Trade-offs to consider: Grafeo's broader language and model support comes with a younger ecosystem—696 stars versus Neo4j's established community and commercial support. Kuzu offers mature Cypher-only embedded performance with smaller API surface. Neo4j's APOC library and Bloom visualization exceed Grafeo's current tooling depth. For teams prioritizing standards compliance (GQL, SQL/PGQ) and multi-model flexibility, Grafeo merits evaluation; for Cypher-only workloads with conservative risk profiles, Kuzu or Neo4j may prove more predictable.

FAQ

What Rust version is required? MSRV is 1.91.1, specified in the project metadata.

Can I run Grafeo without Docker or JVM? Yes—embedded mode has zero external dependencies, by design.

Is the GQL implementation ISO/IEC 39075 compliant? The project claims GQL support with Unicode identifiers per spec; full conformance testing status is not detailed in the README.

How does vector search performance scale? HNSW provides O(log n) approximate search with tunable recall; SIMD acceleration and quantization options trade accuracy for speed and memory.

What backup options exist? Full, incremental, and point-in-time recovery to specific epochs are supported via API and CLI.

Is there a managed cloud offering? No cloud service is mentioned; deployment is self-hosted via library or server binary.

How active is development? Last commit dated 2026-07-13 with active CI, documentation, and multi-language binding maintenance.

Conclusion

GrafeoDB/grafeo occupies a distinctive position in the graph database landscape: a Rust-native engine combining LPG and RDF support with six query languages, native vector search, and embeddable deployment without infrastructure dependencies. The benchmark results—while self-reported—suggest competitive performance with substantially lower memory overhead than some alternatives. The breadth of language bindings and AI ecosystem integrations (LangChain, LlamaIndex, MCP) indicate serious investment in developer experience.

For Rust developers building graph-native applications, teams exploring hybrid graph+vector architectures for RAG, or organizations needing standards-compliant GQL and SPARQL in a single engine, Grafeo warrants direct evaluation. The Apache 2.0 license and active development reduce adoption risk for experimental and production use cases alike.

Explore the codebase, run the benchmarks against your workloads, and engage with the community on Discord. The project repository is at https://github.com/GrafeoDB/grafeo.

For related reading on embedded database architectures, see [INTERNAL_LINK: rust-embedded-databases].

Commentaires 0

Aucun commentaire pour l'instant. Soyez le premier à réagir !

Laisser un commentaire