Relate: The Embedded, Agent-Native Graph Database
| Documentation for a Neo4j Labs project, which is governed by these terms. |
Relate is a graph database in a single binary — query it in Cypher, embed it anywhere, deploy nothing.
It is an embedded, in-memory property-graph engine written in Rust, with a CLI for interactive and scripted queries.
A graph is a single .rl file, a (markdown) folder, or pure in-memory — durable through a fsync’d write-ahead log and Parquet checkpoints.
The same engine powers the relate CLI, a Python package, Node.js and browser (WASM) npm packages, a Rust crate, an optional one-process server speaking Bolt, HTTP, and MCP, and clients for Java, .NET, Go, Swift, and C.
No server to manage, no infrastructure to operate.
Relate is open source (Apache License 2.0) at github.com/relatedb/relate (leave a star), with documentation, cookbooks, playground, guides, and API references at relatedb.ai/docs.
Why You Should Care
If you have ever wanted "SQLite for graphs" — something you can spin up in a script, a notebook, or an agent sandbox, query with real Cypher, and throw away or keep as a single file — Relate is that. Three use cases cover most of the ground:
Agentic Development
| You want | Relate gives you |
|---|---|
Throwaway graph management and compute, like SQLite or DuckDB — but for connected data |
|
Processing data in sessions, from Python |
|
Agent sandboxes and agent memory |
A durable, queryable graph in one |
An agent that already speaks Cypher |
The agent skill ( |
Embedded, Low Resource, Anywhere
One engine, every form factor:
-
On device / in app — a Rust crate (
cargo add relate), Python wheel, or npm package as a single dependency; no sidecar service. -
In a notebook — the Python package runs wherever Python runs;
execute_arrow()hands results to pandas or Polars as Arrow IPC bytes. -
In the browser — the engine compiled to WebAssembly: run Cypher in a page, durable via OPFS, no server. Try it in the browser playground.
-
A store is a file — a directory, a single
.rlbundle, or a folder of markdown notes (every node a note, every relationship a; open it in Obsidian, diff it in git, query it with Cypher).
Neo4j Compatibility
Relate speaks the same language as Neo4j — the Cypher 25 dialect (superset of GQL and openCypher), with label expressions, quantified path patterns, vector and fulltext search, validated by the languager compatibility kit:
-
relate pullcopies a subgraph from a Neo4j/Aura instance into a local store;relate pushmirrors it back, merging on keys. -
relate serve --bolt 7687 --http 7474speaks Bolt or Http — Neo4j drivers and neo4j-browser connect out of the box; the HTTP surface is Neo4j’s Query API v2 shape. -
Test fixtures and golden graphs: pull a slice of production into a
.rlfile, commit it, test offline. -
Markdown mode to turn any local knowledge repository, Obsidian vault or docs set into a graph
-
Where the dialect differs from Neo4j habits, the differences page names the exact error and the form to write instead.
-
Extension system to quickly turn data sources into graphs
git-to-graph,fs-to-grapheasy to add your own withrelate extension init <name> [--lang sh|py|ts|rust]
| Not sure whether a Neo4j workload fits Relate? Read Where relate fits and the honest limitations list — the working set fits in memory, one graph per store, one writer per process. Relate is not a larger-than-memory warehouse or a multi-tenant server. |
Quick Start
Installation
The installer verifies the pinned-key release signature (SSHSIG) and SHA256SUMS before installing anything.
curl -sSfL https://relatedb.ai/install.sh | bash
relate skill install # optional: teach your AI coding agents to drive relate
irm https://relatedb.ai/install.ps1 | iex
relate skill install
First statements
# A one-shot query on an in-memory database
relate "RETURN 1 + 2 AS sum"
# Create a small graph in a store
relate -d ./friends "CREATE (:Person {name: 'Alice'})-[:KNOWS]->(:Person {name: 'Bob'})-[:KNOWS]->(:Person {name: 'Charlie'})"
# Script-friendly JSON: whom does Alice know?
relate --json -d ./friends "MATCH p = (:Person {name: 'Alice'})-[:KNOWS]->() RETURN p"
# Several statements at once, then a transitive reach query
relate -d ./friends "
MATCH (c:Person {name: 'Charlie'}) CREATE (c)-[:KNOWS {since: 2024}]->(:Person {name: 'Dana'});
MATCH (:Person {name: 'Alice'})-[:KNOWS]->+(p) RETURN p.name AS reachable ORDER BY reachable;
"
# Explore the same store in the interactive shell (.quit to exit)
relate query -d ./friends
Python, in-process:
# pip install relate-db
import relate
db = relate.connect(":memory:") # or "./friends"
db.execute("""
UNWIND $rows as row
MERGE (p:Person {name: row.name}) SET p.age=row.age
UNWIND row.knows as friend
MERGE (p)-[:KNOWS]-(:Person {name: friend})
""",
{"rows":[{"name": "David", "age": 23, "knows":["Alice","Eve"]},
{"name": "Eve", "age": 34, "knows":["Bob","Frank","David"]},
{"name": "Frank", "age": 56, "knows":["Charlie","Bob","Alice"]}]})
for row in db.execute("""
MATCH (p:Person)-[:KNOWS*2]-(foaf) RETURN p.name as person, collect(distinct foaf.name) AS foaf
"""):
print(row['person']," friend of a friend ",row["foaf"])
# Alice friend of a friend ['Eve', 'Bob', 'Charlie'] ...
Node.js:
// npm install @relate/relate
const { Database } = require("@relate/relate");
const db = Database.open("./friends"); // or ":memory:"
const result = db.connect().query(`
MATCH (p:Person)-[:KNOWS*2]-(reco)
WHERE NOT exists { (p)-[:KNOWS]-(reco)}
RETURN p.name, reco.name as reco LIMIT 2
`);
result.rows;
/*
[
{ 'p.name': 'Alice', reco: 'Eve' },
{ 'p.name': 'Eve', reco: 'Alice' }
]
*/
A Worked Example: Stack Overflow as a Graph
A classic "why graphs" dataset: Question, Answer, User, and Tag nodes, connected by ASKED, TAGGED, ANSWERED, and PROVIDED relationships.
Two ways to get it into Relate:
From a running Neo4j instance
relate pull copies a Stack Overflow subgraph out of a Neo4j/Aura instance into a local store.
Here from the neo4j-graph-examples/stackoverflow dataset running in demo.neo4jlabs.com.
NEO4J_URI=https://demo.neo4jlabs.com:7473 \
NEO4J_USERNAME=stackoverflow2 NEO4J_PASSWORD=stackoverflow2 NEO4J_DATABASE=stackoverflow2 \
relate pull --database ./so --query 'MATCH (n)-[r]->(m) RETURN n,r,m'
# pulled 6193 new / 5619 reused nodes, 11540 new / 0 reused rels (+ 0 constraints, 0 indexes; 5 schema skipped) to ./so
Live, from the Stack Exchange API
The worked so-to-graph extension example imports the newest questions for a tag.
From a checkout of the Relate repository:
mkdir -p /tmp/so-to-graph
cp docs/api/extensions/examples/so-to-graph.sh /tmp/so-to-graph/
cp docs/api/extensions/examples/extension.bash.json /tmp/so-to-graph/extension.json
chmod +x /tmp/so-to-graph/so-to-graph.sh
relate extension install so-to-graph --from /tmp/so-to-graph
relate run so-to-graph --tag neo4j --pages 1 --body -d ./so
(Python and TypeScript variants of the same importer are beside it in docs/api/extensions/examples/.)
Running queries
Then the questions the flat data cannot answer: relate -d ./so
// Which tags appear together on questions?
MATCH (t1:Tag)<-[:TAGGED]-(q)-[:TAGGED]->(t2:Tag)
WHERE id(t1) < id(t2)
WITH t1, t2, count(*) AS freq WHERE freq >= 2
RETURN t1.name AS tag1, t2.name AS tag2, freq
ORDER BY freq DESC LIMIT 10;
// Which tags are similar, by the Jaccard overlap of their questions?
MATCH (t1:Tag)<-[:TAGGED]-(q1:Question) WITH t1, collect(id(q1)) AS qs1
MATCH (t2:Tag)<-[:TAGGED]-(q2:Question) WHERE id(t1) < id(t2)
WITH t1, t2, qs1, collect(id(q2)) AS qs2
WITH t1, t2, size(qs1) AS d1, size(qs2) AS d2, [x IN qs1 WHERE x IN qs2] AS both
WITH t1, t2, d1, d2, size(both) AS inter WHERE inter >= 2
RETURN t1.name AS tag1, t2.name AS tag2,
(inter * 1.0) / (d1 + d2 - inter) AS jaccard
ORDER BY jaccard DESC LIMIT 10;
Both queries run in milliseconds on a store of roughly 1,000 nodes and 1,300 relationships. In a notebook, draw any result as an interactive graph:
# pip install neo4j-viz
from relate.viz import to_visualization_graph
graph = to_visualization_graph(db.execute("MATCH p = ()-[:TAGGED]->() RETURN p"))
graph.render() # an interactive graph in Jupyter
Features
Tested, runnable recipes for most of the above are in the Relate cookbook — entity resolution, dependency blast radius, hybrid recall, long-term agent memory, and more, each step runnable in the browser.
Language Bindings
Every binding wraps one engine.
| Language | Package and docs |
|---|---|
Python |
|
Node.js |
|
Browser (WASM) |
|
Rust |
|
Java |
|
.NET |
|
Go |
|
Swift |
SwiftPM package (iOS 16+ / macOS 13+) — get started, API reference |
C |
|
Relate FAQ
What is Relate?
An embedded, in-memory property-graph engine written in Rust, with a CLI. A graph is a single .rl file, a directory, a markdown folder, or in-memory. One binary, no server.
How is Relate different from Neo4j?
Neo4j is a multi-tenant client/server database for teams and large graphs. Relate is a single-process, memory-resident engine for working sets that fit in RAM: agent memory, sandboxes, notebooks, apps, tests. You move data between them with relate pull / relate push, and Neo4j drivers connect to relate serve --bolt directly.
Does it really speak Cypher?
Yes — the Cypher 25 dialect with label expressions, quantified path patterns, path selectors, string interpolation, GROUP BY, and more. The openCypher TCK is the language contract. Differences from Neo4j habits are documented with their exact errors.
Do I need to run a server?
No. The default is a library or CLI call, in-process. When you do want a socket, relate serve --database ./g --bolt 7687 --http 7474 --mcp 7475 hosts Bolt, the HTTP Query API, and MCP on one store in one process.
How do I install it?
curl -sSfL https://relatedb.ai/install.sh | bash (macOS/Linux), irm https://relatedb.ai/install.ps1 | iex (Windows), pip install relate-db (Python), npm install @relate/relate (Node.js), cargo add relate (Rust).
How do I give my AI agent Relate?
relate skill install — installs the agent skill (CLI, Cypher, vector, and spatial references) into every detected agent (Claude Code, Cursor, Codex, Gemini CLI, Copilot, and more). The skill is also at relatedb.ai/skill.md. For MCP: relate serve --mcp stdio --database ./graph.rl --read-only.
Is it free and open source? Yes — Apache License 2.0, source public at github.com/relatedb/relate.
Is my data safe with an agent writing to it?
Open the store --read-only and writes are refused. Back up with relate clone before writes; the row cap and typed error objects keep agents from silently drowning in output. The agent safety guide covers the rest.
Where are the limits? The limitations page — the honest list: the working set fits in memory, one graph per store, a single writer per process.
Where to Go Next
-
Relate homepage and the launch blog posts
-
Full documentation — tutorials, guides, CLI / Cypher / API references; the curated agent index at relatedb.ai/docs/llms.txt
-
The cookbooks — task-shaped, tested recipes; its machine index at relatedb.ai/cookbook/llms.txt
-
The browser playground — run Cypher in the page, no install
-
GitHub repository, issues, and the TCK compliance record
-
Coding Tool Integrations^ — connect coding tools to a live Neo4j database over MCP