Minigraf: An Embedded Bi-temporal Graph Database in Rust
Overview
Minigraf is a self-contained, embedded graph database designed for AI agents, mobile applications, and browser-based environments. It functions as a "SQLite for connected data," providing a single-file storage system that supports Datalog queries and a bi-temporal time-travel model, allowing users to query data as it existed at any specific point in transaction time or valid time.
Core Technical Capabilities
Bi-temporal Time Travel
Minigraf implements a bi-temporal model where every fact is tracked by two distinct time dimensions:
- Transaction Time: When a fact was recorded in the database.
- Valid Time: When the fact was true in the real world.
This architecture allows for retroactive corrections without losing history. For example, a user can correct a mis-entered value while preserving the original record, enabling an audit trail of what the system believed at any given moment.
Datalog Query Language
Minigraf utilizes Datalog instead of SQL or Cypher for graph traversals. The project maintains that Datalog is superior for graph data because it is recursive by design, making multi-hop traversals natural. Additionally, its uniform grammar—consisting of simple patterns like [?e :attr ?v]—makes it highly compatible with LLM-generated queries.
Embedded Architecture
Minigraf is designed to be embedded directly into applications rather than running as a separate server. Key architectural constraints include:
- Single-File Storage: Data is stored in a single
.graphfile. - Scale Target: Optimized for datasets under 1 million nodes.
- Zero Configuration: Databases are initialized with a simple call to
Minigraf::open("data.graph"). - Non-Distributed: By design, Minigraf does not support clustering, sharding, or replication; each instance owns its own local file.
Performance and Durability
According to current benchmarks, a point query at 1 million facts takes between 4.3 and 4.5 seconds. The system uses a selective B+tree lookup for bounded patterns and O(N) for full-attribute scans.
To ensure data integrity, Minigraf employs two durability modes:
- SyncMode::Full: Every write is
fsync'd immediately (default). - SyncMode::Normal: Used for bulk loaders or migrations to increase throughput, though
checkpoint()still triggers an unconditionalfsync.
File-backed databases enforce a maximum serialized size of 4,080 bytes per fact, whereas in-memory databases have no such limit.
Platform Support and Bindings
Minigraf is written in Rust (requiring version 1.89 or newer) and offers various tiers of language bindings:
| Platform | Tier | Package/Method |
|---|---|---|
| Rust (Native) | 1 | minigraf on crates.io |
| Python | 1 | minigraf on PyPI |
| Browser WASM | 2 | @minigraf/browser on npm (IndexedDB-backed) |
| WASI | 2 | @minigraf/wasi on npm |
| Node.js | 2 | minigraf on npm |
| Java/Android | 2 | Maven Central (.aar for Android) |
| iOS/macOS | 2 | Swift Package Manager (.xcframework) |
| C / FFI | 2 | C header and shared library |
Tier 1 bindings are fully tested and released concurrently with core releases; Tier 2 bindings are experimental and smoke-tested.
Use Case Applications
AI Agents
Minigraf serves as a temporal memory layer for AI agents. It allows agents to store beliefs, retract or correct them without erasing history, and replay past states to audit the reasoning behind a specific decision. This complements vector stores in a "GraphRAG" pattern, where vector stores handle similarity searches and Minigraf handles relational and temporal queries.
Mobile Applications
The bi-temporal model supports offline-first applications that require retroactive corrections. Native Kotlin and Swift bindings allow integration into Android and iOS apps without requiring the developer to write Rust code.
Community Discussion and Counterpoints
While the project highlights its unique combination of features, some community members on Hacker News have questioned the necessity of a new query language and database for these use cases:
"Existing cypher based databases which support typed properties (including timestamps) on relationship tables can handle this use case just fine."
Others have questioned the practical application of a "temporal multiverse of entities" for personal productivity tools, suggesting that standard SQLite implementations can handle graph data at scale (e.g., 10 million edges) for specific applications like code analysis.
Sources
Related
- Project
- Project
- Dispatch
- Project
- Project