{"slug": "show-hn-minigraf-an-embedded-bi-temporal-graph-database-in-rust", "title": "Show HN: Minigraf – An embedded, bi-temporal graph database in Rust", "summary": "Minigraf 2.0.2, an embedded bi-temporal graph database written in Rust, has been released as a single-file library with Datalog queries, time travel, window functions, and prepared statements, targeting AI agents, mobile apps, and the browser. The project requires Rust 1.89 or newer and documents a known v2.x bug (#371) in which two values of the same attribute written in a single transact call can read back as one value; the fix changes the file format and ships in v3.0.0, with v2.x receiving data-integrity and security fixes for 12 months after v3.0.0 ships.", "body_md": "**Embedded graph memory for AI agents, mobile apps, and the browser** — the SQLite of bi-temporal graph databases\n\nA tiny, self-contained graph database with **Datalog queries** and **bi-temporal time travel**. Think SQLite, but for connected data with full history.\n\n[Try it in your browser — no install needed →](https://minigraf-playground.vercel.app/)\n\n**[Watch time travel in the visualizer →](https://project-minigraf.github.io/minigraf-visualizer/#sample=careers&tx=7&e=:alice&view=map)** Scrub transaction time and valid time, and see the graph change.\n\nMinigraf is a **single-file embedded graph database** that lets you:\n\n- ✅ **Query relationships with Datalog** - Recursive rules, natural graph traversal\n- ✅ **Time travel through history** - Bi-temporal queries (transaction time + valid time)\n- ✅ **Window functions** -`sum/count/min/max/avg/rank/row-number :over (partition-by … :order-by …)` in`:find` clauses\n- ✅ **Prepared statements** - Parse + plan once with`$slot` bind tokens, execute thousands of times\n- ✅ **Embed anywhere** - Native, WASM, mobile, IoT - one`.graph` file\n- ✅ **Zero configuration** - Just`Minigraf::open(\"data.graph\")` and you're done\n\n**Status**: See [ROADMAP.md](https://github.com/project-minigraf/minigraf/blob/main/ROADMAP.md) for planned work and current direction.\n\n**Datalog is fundamentally better for graphs than SQL-like languages:**\n\n1. **Recursive by design** - Multi-hop traversals are natural, not an afterthought\n2. **Simpler to implement** - Smaller spec = more reliable, faster to production\n3. **Perfect for temporal** - Time is just another dimension in relations\n4. **Proven at scale** - 40+ years of research, production use (Datomic, XTDB)\n5. **Graph-native** - Facts (Entity-Attribute-Value) are literally edges\n6. **LLM-friendly** - The small, uniform grammar (`[?e :attr ?v]` patterns, no JOIN variants, no subquery nesting) is easy for AI coding assistants to generate correctly from a few examples; the entire language fits in a system prompt\n\n```\n[dependencies]\nminigraf = \"2.0.2\"\n```\n\nOr via cargo:\n\n```\ncargo add minigraf\n```\n\nRequires Rust 1.89 or newer (the minimum supported Rust version, set in `Cargo.toml`).\n\nBugs present in the current release, with affected versions, workarounds and fix versions, are listed in the pinned **[Known issues in the current release](https://github.com/project-minigraf/minigraf/issues/421)** issue. The most important one on v2.x:\n\n- Two values of the same attribute for one entity written in a single `transact` (or retracted in a single`retract` ) can read back as one value ([#371](https://github.com/project-minigraf/minigraf/issues/371) ). Write or retract each value of a multi-valued attribute in its own call. The fix changes the file format and ships in v3.0.0.\n\nv2.x gets data-integrity and security fixes for 12 months after v3.0.0 ships. See the [support policy](https://github.com/project-minigraf/minigraf/blob/main/PHILOSOPHY.md#support-policy).\n\n```\nuse minigraf::{Minigraf, OpenOptions};\n\n// Open or create a file-backed database\nlet db = OpenOptions::new().path(\"myapp.graph\").open()?;\n\n// Add facts\ndb.execute(r#\"(transact [[:alice :person/name \"Alice\"]\n                         [:alice :person/age 30]\n                         [:alice :friend :bob]\n                         [:bob :person/name \"Bob\"]])\"#)?;\n\n// Query with Datalog\nlet results = db.execute(r#\"\n    (query [:find ?friend-name\n            :where [:alice :friend ?friend]\n                   [?friend :person/name ?friend-name]])\n\"#)?;\n\n// Explicit transaction — all-or-nothing\nlet mut tx = db.begin_write()?;\ntx.execute(r#\"(transact [[:alice :person/age 31]])\"#)?;\ntx.commit()?;\n\n// Time travel — query as of past transaction counter\ndb.execute(\"(query [:find ?age :as-of 1 :where [:alice :person/age ?age]])\")?;\n\n// Recursive rule — transitive reachability\ndb.execute(r#\"(rule [(reachable ?a ?b) [?a :friend ?b]])\n              (rule [(reachable ?a ?b) [?a :friend ?m] (reachable ?m ?b)])\"#)?;\n\n// Prepared statement — parse + plan once, execute many times\nuse minigraf::BindValue;\nlet pq = db.prepare(\"(query [:find ?name :as-of $tx :where [$entity :person/name ?name]])\")?;\nlet r1 = pq.execute(&[(\"tx\", BindValue::TxCount(1)), (\"entity\", BindValue::Entity(alice_id))])?;\nlet r2 = pq.execute(&[(\"tx\", BindValue::TxCount(2)), (\"entity\", BindValue::Entity(bob_id))])?;\ncargo run          # interactive Datalog REPL\ncargo test         # run 1212 tests\ncargo run < demos/demo_recursive.txt   # recursive rules demo\n```\n\nSee a working implementation of **temporal reasoning** with Minigraf at [github.com/adityamukho/temporal_reasoning](https://github.com/adityamukho/temporal_reasoning) — an AI agent that uses Minigraf's bi-temporal model to store, correct, and audit beliefs.\n\nThe **[time travel visualizer](https://project-minigraf.github.io/minigraf-visualizer/)** runs Minigraf in your browser and draws its history. Step through transactions, move the valid-time cursor, and see each fact version on a bitemporal map. It opens `.graph` files too. For example, see [a salary that was recorded wrong and then corrected](https://project-minigraf.github.io/minigraf-visualizer/#sample=careers&tx=7&e=:alice&view=map).\n\nSee the [Datalog Reference](https://github.com/project-minigraf/minigraf/wiki/Datalog-Reference) wiki page for the complete syntax.\n\nNo other database offers this combination:\n\n| Feature | Minigraf | XTDB | Cozo | Neo4j | SQLite | \n|---|---|---|---|---|---|\n| **Query Language** | Datalog | Datalog | Datalog | Cypher | SQL | \n| **Single File** | ✅ Yes | ❌ No | ❌ No | ❌ No | ✅ Yes | \n| **Bi-temporal** | ✅ Yes | ✅ Yes |  | ❌ No | ❌ No | \n| **Embedded** | ✅ Yes | ✅ Yes | ✅ Yes | ❌ No | ✅ Yes | \n| **Graph Native** | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ❌ No | \n| **Rust** | ✅ Yes | ❌ Clojure | ✅ Yes | ❌ Java | ❌ C | \n| **WASM Ready** | ✅ Yes (browser + WASI) | ❌ No |  | ❌ No | ✅ Yes | \n\n| Platform | Tier | Package | Install | \n|---|---|---|---|\n| Rust (native) | 1 | `minigraf` on crates.io | `cargo add minigraf` | \n| Python | 1 | `minigraf` on PyPI | `pip install minigraf` | \n| Browser WASM | 2 (experimental) | `@minigraf/browser` on npm | `npm install @minigraf/browser` | \n| WASI | 2 (experimental) | `@minigraf/wasi` on npm | `npm install @minigraf/wasi` | \n| Node.js | 2 (experimental) | `minigraf` on npm | `npm install minigraf` | \n| Java/JVM | 2 (experimental) | `io.github.project-minigraf:minigraf-jvm` on Maven Central | see [wiki](https://github.com/project-minigraf/minigraf/wiki/Use-Cases) | \n| Android | 2 (experimental) | `io.github.project-minigraf:minigraf-android` (`.aar` ) on Maven Central | see [wiki](https://github.com/project-minigraf/minigraf/wiki/Use-Cases) | \n| iOS / macOS | 2 (experimental) | `.xcframework` via Swift Package Manager ([minigraf-swift](https://github.com/project-minigraf/minigraf-swift) ) | see [wiki](https://github.com/project-minigraf/minigraf/wiki/Use-Cases) | \n| C / FFI | 2 (experimental) | header + tarball on [minigraf-c releases](https://github.com/project-minigraf/minigraf-c/releases) | see [wiki](https://github.com/project-minigraf/minigraf/wiki/Use-Cases) | \n\n**Tier 1** bindings are fully tested and released at the same time as every core release. **Tier 2** bindings are built and smoke-tested, released on a best-effort schedule, and experimental. A binding moves to Tier 1 when real users need it. Tier 1 operating systems and filesystems are Linux (ext4, xfs), macOS (APFS) and Windows (NTFS) on local disk; NFSv4 is supported with caveats, and NFSv3 `nolock` is unsupported for multiple writers. Details: [support tiers](https://github.com/project-minigraf/minigraf/blob/main/PHILOSOPHY.md#support-tiers).\n\n**Embedded graph memory for agents, mobile, and the browser — SQLite's simplicity + Datomic's temporal model.**\n\n| Language | Package | Repo | \n|---|---|---|\n| Python | [`minigraf` on PyPI](https://pypi.org/p/minigraf) | [minigraf-python](https://github.com/project-minigraf/minigraf-python) | \n| Node.js | [`minigraf` on npm](https://www.npmjs.com/package/minigraf) | [minigraf-node](https://github.com/project-minigraf/minigraf-node) | \n| Browser WASM | [`@minigraf/browser` on npm](https://www.npmjs.com/package/@minigraf/browser) | [minigraf-wasm](https://github.com/project-minigraf/minigraf-wasm) | \n| WASI | [`@minigraf/wasi` on npm](https://www.npmjs.com/package/@minigraf/wasi) | [minigraf-wasm](https://github.com/project-minigraf/minigraf-wasm) | \n| Java | `io.github.project-minigraf:minigraf-jvm` on Maven Central | [minigraf-java](https://github.com/project-minigraf/minigraf-java) | \n| Android | `io.github.project-minigraf:minigraf-android` on Maven Central | [minigraf-android](https://github.com/project-minigraf/minigraf-android) | \n| iOS/macOS | Swift bindings | [minigraf-swift](https://github.com/project-minigraf/minigraf-swift) | \n| C | C bindings | [minigraf-c](https://github.com/project-minigraf/minigraf-c) | \n\nSee the [Comparison](https://github.com/project-minigraf/minigraf/wiki/Comparison) wiki page for detailed analysis including temporal vs. time-series databases.\n\nStore what an agent believes, retract and correct without losing history, and replay past states to audit decisions. Every fact carries both transaction time (when it was recorded) and valid time (when it was true), so you can reconstruct the exact knowledge state at the moment of any past decision.\n\nPairs well with vector stores (GraphRAG pattern): the vector store answers \"what is similar?\"; Minigraf answers \"what are the relationships, who recorded them, and what did we believe at time T?\"\n\nSee it in the visualizer: [what an agent believed when it made a recommendation](https://project-minigraf.github.io/minigraf-visualizer/#sample=agent-memory&tx=3&vt=any&e=:user-ana), and the correction that followed (press → to step forward).\n\nOffline-first storage with retroactive corrections — the bi-temporal model lets you correct a mis-entered value while preserving the original record ([see a correction in the visualizer](https://project-minigraf.github.io/minigraf-visualizer/#data=KHRyYW5zYWN0IHs6dmFsaWQtZnJvbSAiMjAyNS0wNi0wMSJ9CiAgICAgICAgICBbWzp1c2VyIDpoZWFsdGgvd2VpZ2h0LWtnIDgyLjVdXSkKKHJldHJhY3QgW1s6dXNlciA6aGVhbHRoL3dlaWdodC1rZyA4Mi41XV0pCih0cmFuc2FjdCB7OnZhbGlkLWZyb20gIjIwMjUtMDYtMDEifQogICAgICAgICAgW1s6dXNlciA6aGVhbHRoL3dlaWdodC1rZyA4MC41XV0p&title=Record+facts+offline%2C+correct+on+sync&vt=any&e=:user&view=map)). Native Kotlin and Swift bindings ship as an Android `.aar` (Maven Central) and an iOS `.xcframework` (Swift Package Manager) via [UniFFI](https://github.com/mozilla/uniffi-rs). No Rust required.\n\n```\n// Android (Kotlin)\nval db = MiniGrafDb.open(context.filesDir.absolutePath + \"/myapp.graph\")\ndb.execute(\"\"\"(transact [[:alice :person/name \"Alice\"] [:alice :person/age 30]])\"\"\")\nval json = db.execute(\"(query [:find ?name :where [?e :person/name ?name]])\")\njs\n// iOS (Swift)\nlet db = try MiniGrafDb.open(path: docsURL.appendingPathComponent(\"myapp.graph\").path)\ntry db.execute(datalog: #\"(transact [[:alice :person/name \"Alice\"] [:alice :person/age 30]])\"#)\nlet json = try db.execute(datalog: \"(query [:find ?name :where [?e :person/name ?name]])\")\n```\n\nSee the [Mobile Integration](https://github.com/project-minigraf/minigraf/wiki/Use-Cases#mobile-apps) wiki section for full setup and usage docs (Gradle config, SPM integration, error handling, threading).\n\nPublished as [`@minigraf/browser`](https://www.npmjs.com/package/@minigraf/browser) on npm (IndexedDB-backed, `wasm-pack`). WASI build (` wasm32-wasip1`) available as [`@minigraf/wasi`](https://www.npmjs.com/package/@minigraf/wasi) on npm and as a GitHub Releases artifact (Wasmtime / Wasmer). See the [Use Cases wiki](https://github.com/project-minigraf/minigraf/wiki/Use-Cases). The [playground](https://minigraf-playground.vercel.app/) and the [time travel visualizer](https://project-minigraf.github.io/minigraf-visualizer/) are both built on `@minigraf/browser`.\n\nLanguage bindings ship as `minigraf` on PyPI, `minigraf` on npm (Node.js native addon), `io.github.adityamukho:minigraf-jvm` on Maven Central, and a C header + prebuilt shared library on GitHub Releases. See the [Use Cases wiki](https://github.com/project-minigraf/minigraf/wiki/Use-Cases).\n\nMinigraf runs as:\n\n- ✅ An embedded library\n- ✅ A standalone binary (interactive REPL)\n- ✅ Browser WASM — `@minigraf/browser` (IndexedDB-backed,`wasm-pack` )\n- ✅ Server-side WASM — `wasm32-wasip1` / WASI (Wasmtime, Wasmer, Cloudflare Workers)\n- ✅ Android, iOS, Python, Node.js, Java, C — via UniFFI / napi-rs / cbindgen\n\nMinigraf will **not** be (by design):\n\n- **Distributed** — no clustering, no sharding, no replication; each agent instance owns its own`.graph` file\n- **Client-server** — no network protocol in core\n- **Billion-node scale** — optimised for <1M nodes (like SQLite)\n- **A time-series database** — Minigraf is a*temporal* database; see[Comparison](https://github.com/project-minigraf/minigraf/wiki/Comparison#influxdb--prometheus--timescaledb-time-series-databases)\n\nSee [ROADMAP.md](https://github.com/project-minigraf/minigraf/blob/main/ROADMAP.md) for planned work and current direction.\n\nSee [BENCHMARKS.md](https://github.com/project-minigraf/minigraf/blob/main/docs/BENCHMARKS.md) for the current reproducible local snapshot and benchmark commands.\n| Point query at 1M facts | 4.3–4.5 s (selective B+tree lookup for bounded patterns; O(N) for full-attribute scans) |\n| Open time at 1M facts | 1.31 s (2.4× faster than v5 — indexes no longer loaded into RAM) |\n| Peak heap at 1M facts | 1.05 GB (~21% less than v5 — indexes paged in on demand) |\n\nFile-backed databases enforce a maximum fact size of **4 080 serialised bytes** per fact. In-memory databases have no limit.\n\n**Durability tuning:** every write is `fsync`'d immediately by default (` SyncMode::Full`). Bulk loaders/migrations that can safely re-run from a checkpoint watermark on failure can trade that for throughput with `OpenOptions::new().synchronous(SyncMode::Normal)` — `checkpoint()` still fsyncs unconditionally in both modes. See the [Performance Tuning wiki page](https://github.com/project-minigraf/minigraf/wiki/Performance-Tuning#configuration-knobs) for the full tradeoff and the write-batching pattern that pairs with it.\n\nThis is a solo-maintained project with a long-term vision. Read [PHILOSOPHY.md](https://github.com/project-minigraf/minigraf/blob/main/PHILOSOPHY.md) and [ROADMAP.md](https://github.com/project-minigraf/minigraf/blob/main/ROADMAP.md) before proposing features.\n\nSee [CONTRIBUTING.md](https://github.com/project-minigraf/minigraf/blob/main/CONTRIBUTING.md) for development setup, code standards, and the PR process.\n\nLicensed under either of:\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](https://github.com/project-minigraf/minigraf/blob/main/LICENSE-APACHE) or[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) )\n- MIT license ([LICENSE-MIT](https://github.com/project-minigraf/minigraf/blob/main/LICENSE-MIT) or[http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT) )\n\nat your option.\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.", "url": "https://wpnews.pro/news/show-hn-minigraf-an-embedded-bi-temporal-graph-database-in-rust", "canonical_source": "https://github.com/project-minigraf/minigraf", "published_at": "2026-10-05 11:18:18+00:00", "updated_at": "2026-10-05 11:49:34.726524+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-agents", "developer-tools", "ai-infrastructure"], "entities": ["Minigraf", "Rust", "Datalog", "SQLite", "Datomic", "XTDB", "WASM"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/show-hn-minigraf-an-embedded-bi-temporal-graph-database-in-rust", "markdown": "https://wpnews.pro/news/show-hn-minigraf-an-embedded-bi-temporal-graph-database-in-rust.md", "text": "https://wpnews.pro/news/show-hn-minigraf-an-embedded-bi-temporal-graph-database-in-rust.txt", "jsonld": "https://wpnews.pro/news/show-hn-minigraf-an-embedded-bi-temporal-graph-database-in-rust.jsonld"}}