Skip to content
gr

A graph database that fits in a file

gr stores a whole labeled-property graph in one self-describing .gr file, queries it with openCypher, and gives you the SQLite feel for graphs: open a file, run queries, close it. No server, no configuration, no cluster.

A relational database keeps rows in tables. A graph database keeps nodes and relationships, so you model a social network, a dependency graph, or a knowledge base the way it actually is, not as a tangle of foreign-key joins.

gr brings that model to Go without a server:

db, err := gr.Open("friends.gr", gr.Options{})
if err != nil {
    log.Fatal(err)
}
defer db.Close()

db.Exec(ctx, `CREATE (:Person {name:"Alice"})-[:KNOWS]->(:Person {name:"Bob"})`, nil)

res, err := db.Query(ctx, `MATCH (a)-[:KNOWS]->(b) RETURN a.name, b.name`, nil)
if err != nil {
    log.Fatal(err)
}
defer res.Close()
for res.Next() {
    fmt.Println(res.Record().Values())
}

No network call. No daemon. One file on disk.

What gr provides

  • An embedded library. Import github.com/tamnd/gr, open a .gr file, and run Cypher queries. The database lives inside your process.
  • openCypher. The same graph query language Neo4j, Amazon Neptune, and others use. MATCH patterns, CREATE and MERGE, variable-length paths, aggregation, indexes, and constraints.
  • A CLI. gr is an interactive Cypher shell, a one-shot runner, an importer, a backup tool, and a schema inspector in one pure-Go binary.
  • A Bolt server. gr serve accepts connections from any Neo4j driver over the standard Bolt wire protocol.
  • Durability. WAL journaling, per-page checksums, crash recovery. A file the process crashes into comes back clean on the next open.
  • Pure Go. No cgo. Cross-compiles everywhere Go does. One static binary, no shared libraries.

Where to go next

Getting started Install gr and run your first Cypher query against a real graph in under five minutes. Cypher The openCypher graph query language: patterns, reads, writes, aggregation, and paths. Library Embed gr in a Go program: open databases, run queries, manage transactions, and read graph objects. CLI The gr command-line tool: interactive Cypher shell, one-shot queries, import, backup, and schema inspection.