StackMap
Subscribe
Explore / latticedb
jeffhajewski

latticedb

Embedded single-file graph database in Zig: graph traversal, HNSW vector search and BM25 full-text in one query language, plus a durable event log — built for Graph RAG and local agent memory.

568 25 Zig MITupdated today
View on GitHubDispute this mapping →
Curator's take

SQLite's shape applied to the three retrieval modes agents actually need. One file, no server, one query layer where a Cypher-style MATCH can filter on vector distance and a full-text match in the same statement, and one WAL that graph writes and named event streams share — so your changefeed is transactional with the graph. Quoted 0.13µs node lookups and 0.83ms vector search at 1M vectors, with CLI, Python, TypeScript, Java and Go bindings. Reach for it when relationships are the point and you were about to bolt a vector DB onto a graph DB. Do not reach for it for multi-writer or multi-machine work: it is explicitly single-writer, one owning process, one machine. Also young — Zig, 567 stars, bundled native libs per platform, and the built-in `hash_embed` helper is a deterministic placeholder, not an embedding model.

Mapped by ShipWithAI editors · links verified
README.md

LatticeDB

Embedded property-graph database with native vector and full-text indexing.

LatticeDB is a single-file local database for connected, semantic, and textual data. It lets you traverse relationships, run vector similarity search, and do BM25 full-text search over the same dataset in one engine and one query layer. It is designed for relationship-heavy workloads on a single machine, with zero-config operation and an embedded single-writer model.

LatticeDB is an embedded, single-file graph database that lets local applications query the same data by relationship, semantics, and text, then consume durable graph and application events from the same file. Workloads like Graph RAG, agent memory, and local knowledge tools are examples built on those primitives, not the definition of the engine.

  • One file. Your entire database is a single portable file. No server, no configuration.
  • One query layer. Graph traversal, HNSW vector similarity, and BM25 full-text — in the same query language.
  • One event log. Durable named streams and a built-in graph changefeed share the same transaction/WAL path as graph writes.
  • Local-first. Designed for one owning process on one machine, with WAL-backed durability.
  • Fast. 0.13 μs node lookups. 0.83 ms vector search at 1M vectors with 100% recall.
// Find chunks similar to a query, traverse to their document, then to the author
MATCH (chunk:Chunk)-[:PART_OF]->(doc:Document)-[:AUTHORED_BY]->(author:Person)
WHERE chunk.embedding <=> $query_vector < 0.3
  AND doc.content @@ "neural networks"
RETURN doc.title, chunk.text, author.name
ORDER BY chunk.embedding <=> $query_vector
LIMIT 10

Install

CLI

curl -fsSL https://raw.githubusercontent.com/jeffhajewski/latticedb/main/dist/install.sh | bash

Python

pip install latticedb

Published wheels are expected to bundle liblattice on supported platforms. Source installs can also bundle a staged native library during wheel builds with LATTICE_BUNDLE_LIB_DIR=/path/to/lib.

TypeScript / Node.js

npm install @hajewski/latticedb

Published package tarballs are expected to bundle liblattice on supported platforms. Source checkouts can stage the native library into the package with LATTICE_BUNDLE_LIB_DIR=/path/to/lib npm run bundle:native.

Java

Requires JDK 21+. See bindings/java/README.md for the Maven build, which compiles the JNI bridge and stages liblattice from zig-out/lib. A runnable knowledge-graph example is in bindings/java/src/main/java/io/latticedb/examples.

Go

See bindings/go/README.md for the current cgo workflow. The default consumer path uses installed pkg-config metadata; in-repo development can use -tags repolocal against zig-out/lib. There is also a runnable graph/vector/text retrieval example in examples/go.

Recent binding-surface cleanups moved embedding helpers into dedicated modules and subpackages. See docs/client_api_migration.md for the preferred imports and current compatibility aliases.

Start Here

Example

A complete example: create a small knowledge graph with documents and authors, store embeddings, index text, then query across all three search modes.

The examples use the built-in hash_embed / hashEmbed / HashEmbed helper so they run with no external service. It is a deterministic placeholder, not a semantic embedding: similar text does not produce nearby vectors, so a distance threshold is arbitrary and a similarity query may match nothing. Use a r

Continue your stack

What teams reach for next — and why each earns a place beside latticedb. Ranked by curator confidence.