Skip to content

Grafeo

A pure-Rust, high-performance, embeddable graph database

Get Started View on GitHub


Why Grafeo?

  • High Performance


    Built from the ground up in Rust for maximum performance with vectorized execution, adaptive chunking, and SIMD-optimized operations.

  • Embeddable


    Embed directly into your application with zero external dependencies. Perfect for edge computing, desktop apps, and serverless environments.

  • Pure Rust


    Written entirely in safe Rust with no C dependencies. Memory-safe by design with fearless concurrency.

  • Python Bindings


    First-class Python support via PyO3. Use Grafeo from Python with a Pythonic API that feels natural.

  • Multi-Language Queries


    GQL, Cypher, Gremlin, GraphQL, and SPARQL. Choose the query language that fits your needs and expertise.

  • ACID Transactions


    Full ACID compliance with MVCC-based snapshot isolation. Reliable transactions for production workloads.


Quick Start

uv add grafeo
import grafeo

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

# Create nodes and edges
with db.session() as session:
    session.execute("""
        INSERT (:Person {name: 'Alice', age: 30})
        INSERT (:Person {name: 'Bob', age: 25})
    """)

    session.execute("""
        MATCH (a:Person {name: 'Alice'}), (b:Person {name: 'Bob'})
        INSERT (a)-[:KNOWS {since: 2024}]->(b)
    """)

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

    for row in result:
        print(f"{row['p.name']} knows {row['friend.name']}")
cargo add grafeo
use grafeo::Database;

fn main() -> Result<(), grafeo::Error> {
    // Create an in-memory database
    let db = Database::open_in_memory()?;

    // Create a session and execute queries
    let session = db.session()?;

    session.execute(r#"
        INSERT (:Person {name: 'Alice', age: 30})
        INSERT (:Person {name: 'Bob', age: 25})
    "#)?;

    session.execute(r#"
        MATCH (a:Person {name: 'Alice'}), (b:Person {name: 'Bob'})
        INSERT (a)-[:KNOWS {since: 2024}]->(b)
    "#)?;

    // Query the graph
    let result = session.execute(r#"
        MATCH (p:Person)-[:KNOWS]->(friend)
        RETURN p.name, friend.name
    "#)?;

    for row in result {
        println!("{} knows {}", row.get("p.name")?, row.get("friend.name")?);
    }

    Ok(())
}

Features

Dual Data Model Support

Grafeo supports both major graph data models with optimized storage for each:

  • Nodes with labels and properties
  • Edges with types and properties
  • Properties supporting rich data types
  • Ideal for social networks, knowledge graphs, application data
  • Triples: subject-predicate-object statements
  • SPO/POS/OSP indexes for efficient querying
  • W3C standard compliance
  • Ideal for semantic web, linked data, ontologies

Query Languages

Choose the query language that fits your needs:

Language Data Model Style
GQL (default) LPG ISO standard, declarative pattern matching
Cypher LPG Neo4j-compatible, ASCII-art patterns
Gremlin LPG Apache TinkerPop, traversal-based
GraphQL LPG, RDF Schema-driven, familiar to web developers
SPARQL RDF W3C standard for RDF queries
MATCH (me:Person {name: 'Alice'})-[:KNOWS]->(friend)-[:KNOWS]->(fof)
WHERE fof <> me
RETURN DISTINCT fof.name
MATCH (me:Person {name: 'Alice'})-[:KNOWS]->(friend)-[:KNOWS]->(fof)
WHERE fof <> me
RETURN DISTINCT fof.name
g.V().has('name', 'Alice').out('KNOWS').out('KNOWS').
  where(neq('me')).values('name').dedup()
{
  Person(name: "Alice") {
    friends { friends { name } }
  }
}
SELECT DISTINCT ?fofName WHERE {
  ?me foaf:name "Alice" .
  ?me foaf:knows ?friend .
  ?friend foaf:knows ?fof .
  ?fof foaf:name ?fofName .
  FILTER(?fof != ?me)
}

Architecture Highlights

  • Push-based execution engine with morsel-driven parallelism
  • Columnar storage with type-specific compression
  • Cost-based query optimizer with cardinality estimation
  • MVCC transactions with snapshot isolation
  • Zone maps for intelligent data skipping

Installation

uv add grafeo
cargo add grafeo

Or add to your Cargo.toml:

[dependencies]
grafeo = "0.1"

License

Grafeo is licensed under the Apache-2.0 License.