Getting started
From one command to a server your Neo4j drivers can talk to. A few minutes.
Run it
One command starts GraphBuff with the movies graph loaded. Needs Docker.
Run it with the movies graph
$ docker run --rm -p 127.0.0.1:7475:7475 -p 127.0.0.1:7687:7687 ghcr.io/janvencl/graphbuff --demo moviesBuild from source instead
# Linux and macOS curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Windows: download rustup-init.exe from rustup.rs rustup update stable rustc --version # 1.89 or newer git clone https://github.com/JanVencl/graphbuff && cd graphbuff cargo run --release -p graphbuff-cli -- -i examples/movies.cypherSee the first result
The server prints two lines and waits: HTTP/JSON on port 7475, Bolt on 7687, seven nodes and eight relationships loaded. From a second terminal, ask who acted with Keanu Reeves.
graphbuff-server listening on http://0.0.0.0:7475 and bolt://0.0.0.0:7687 (in-memory databases) demo `movies` loaded: 7 nodes, 8 relationships curl -s http://127.0.0.1:7475/query -H 'Content-Type: application/json' \ -d '{"query": "MATCH (:Person {name: \"Keanu Reeves\"})-[:ACTED_IN]->(m)<-[:ACTED_IN]-(co) RETURN co.name AS coActor, count(m) AS movies ORDER BY movies DESC"}' {"columns":["coActor","movies"],"rows":[["Carrie-Anne Moss",2],["Hugo Weaving",1]],"stats":{...}}Ask your own questions
Any Cypher goes in
query; values go inparams, so they never need escaping. The server also warns that it has no token: the command publishes its ports to this machine only, which is why that is safe here.curl -s http://127.0.0.1:7475/query -H 'Content-Type: application/json' \ -d '{"query": "MATCH p = shortestPath((h:Person {name: $from})-[*]-(l:Person {name: $to})) RETURN [n IN nodes(p) | coalesce(n.name, n.title)] AS path", "params": {"from": "Hugo Weaving", "to": "Lana Wachowski"}}' {"columns":["path"],"rows":[[["Hugo Weaving","The Matrix","Lana Wachowski"]]],"stats":{...}}It works. Now make it yours.
Keep the data
With
--datadatabases live in a directory and survive restarts. Add--persistentfor disk-resident storage that can grow past RAM.cargo run --release -p graphbuff-cli -- --data ./data cargo run --release -p graphbuff-cli -- --data ./data --persistent graphbuff> CREATE DATABASE movies; graphbuff> :use movies graphbuff> :source examples/movies.cypherStart the server
HTTP/JSON on port 7475, Bolt on 7687. It listens on localhost unless you bind it elsewhere; set a token or a users file before you do.
cargo run --release -p graphbuff-server -- --data ./data --bolt 127.0.0.1:7687 --token s3cret curl -s http://127.0.0.1:7475/query \ -H 'Authorization: Bearer s3cret' -H 'Content-Type: application/json' \ -d '{"query": "MATCH (p:Person) RETURN p.name AS name ORDER BY name"}' {"columns":["name"],"rows":[["Carrie-Anne Moss"],["Hugo Weaving"],...],"stats":{...}}Connect your application
Use the official Neo4j driver over Bolt, plain HTTP from any language, or embed the engine in a Rust program.
pip install neo4j from neo4j import GraphDatabase with GraphDatabase.driver("bolt://127.0.0.1:7687", auth=("neo4j", "s3cret")) as driver: records, _, _ = driver.execute_query("MATCH (p:Person) RETURN p.name AS name", database_="movies") for r in records: print(r["name"])// org.neo4j.driver:neo4j-java-driver try (var driver = GraphDatabase.driver("bolt://127.0.0.1:7687", AuthTokens.basic("neo4j", "s3cret"))) { var result = driver.executableQuery("MATCH (p:Person) RETURN p.name AS name") .withConfig(QueryConfig.builder().withDatabase("movies").build()) .execute(); result.records().forEach(r -> System.out.println(r.get("name").asString())); }# Cargo.toml [dependencies] graphbuff = { git = "https://github.com/JanVencl/graphbuff" } // main.rs use graphbuff::{Database, StorageMode}; fn main() -> Result<(), Box<dyn std::error::Error>> { let db = Database::open(StorageMode::hybrid("data/app"))?; db.execute("MERGE (:Person {name: 'Ann'})")?; println!("{}", db.execute("MATCH (p:Person) RETURN p.name")?.to_table()); Ok(()) }Optional: turn on the GPU
Needs a GPU with Vulkan, Direct3D 12 or Metal.
EXPLAINthen shows(wgpu; …)on the steps that run on the card. On Windows with the GNU toolchain, see the README for the extra linker setup.cargo run --release -p graphbuff-cli --features gpu -- --gpu cargo run --release -p graphbuff-server --features gpu -- --gpu --bolt 127.0.0.1:7687