Examples, integrations, and cookbooks for Minigraf -- part of the Minigraf ecosystem.
This repository is a standalone Rust examples crate. Each scenario is runnable with
Cargo and uses the published minigraf crate.
- Rust 1.85 or newer for edition 2024 crates.
- Cargo with access to crates.io.
minigraf = "1.1"from crates.io. Cargo currently resolves this tominigraf v1.1.1.
Install and verify dependencies:
cargo testStores user preferences and project context in Minigraf, queries them back for an agent response, then writes a correction while keeping transaction-time history.
Run:
cargo run --example agentic_memoryExpected output:
Agent memory: remembered Alice prefers concise technical answers.
Agent memory: retrieved Alice's current project, minigraf-examples.
Agent memory: wrote a correction with transaction history intact.
Stores local task changes while disconnected, queries pending changes for a future sync pass, then records a synced state while retaining earlier transaction state.
Run:
cargo run --example offline_first_mobileExpected output:
Offline mobile: stored two local task changes while disconnected.
Offline mobile: selected the pending changes for later sync.
Offline mobile: marked the synced task without losing local history.
Initializes an order in :awaiting-payment and stores legal transitions as Minigraf facts.
A Datalog guard query checks whether an event is legal from the order's current state.
A legal payment transition is accepted; an illegal ship event is rejected. The state
update is an atomic write transaction containing a retract and a transact. A
transaction-time replay with :as-of 1 shows the prior state.
Run:
cargo run --example state_machineExpected output:
State machine: accepted payment by querying transition facts as the guard.
State machine: rejected shipping from awaiting-payment before the transition.
State machine: replayed transaction history to explain the prior state.
Records a policy approval, supersedes the owner, then queries both current state and an earlier transaction-time view.
Run:
cargo run --example audit_logExpected output:
Audit log: recorded policy approval and superseding revision.
Audit log: queried the current policy owner.
Audit log: queried transaction-time history for the earlier owner.
The LangChain examples use the published language bindings directly:
- Python:
minigraf==1.1.1 - Node.js:
minigraf@1.1.1
Implements BaseChatMessageHistory from langchain-core with Minigraf-backed
message storage.
Install prerequisites:
python3 -m venv .venv
. .venv/bin/activate
python -m pip install -r integrations/langchain-python/requirements.txtRun:
python integrations/langchain-python/minigraf_chat_history.pyExpected output:
Human: Remember that Minigraf stores agent memory.
AI: Got it. I will use Minigraf-backed chat history.
minigraf-algorithms/ is a standalone crate for graph algorithms that operate
on Minigraf data. It lives outside Minigraf core so traversal helpers can evolve
as opt-in ecosystem utilities without enlarging the embedded database API.
Run:
cargo test -p minigraf-algorithmsImplements BaseChatMessageHistory from @langchain/core/chat_history with
Minigraf-backed message storage.
Install prerequisites:
cd integrations/langchain-js
npm installRun:
npm startExpected output:
Human: Remember that Minigraf stores agent memory.
AI: Got it. I will use Minigraf-backed chat history.
The GraphRAG example uses ChromaDB for semantic retrieval and Minigraf for structured graph traversal. Entity UUIDs are the explicit bridge between the two stores.
- Python:
minigraf==1.1.1,chromadb
Populates a six-node concept graph in Minigraf, indexes entity descriptions in an in-memory ChromaDB collection, retrieves the closest entity by semantic similarity, then traverses its graph neighbours.
Install prerequisites:
python3 -m venv .venv
. .venv/bin/activate
python -m pip install -r integrations/graphrag-python/requirements.txtNote: ChromaDB downloads the all-MiniLM-L6-v2 embedding model (~80 MB) on first run.
Run:
python integrations/graphrag-python/graphrag_minigraf.pyExpected output:
Query: "storing time-varying relationships"
Match: temporal-data
Related: graph-db, knowledge-graph
MinigrafGraphStore implements LlamaIndex's SimpleGraphStore with Minigraf as the
backing store. Triplets map directly onto Minigraf's native entity-attribute-value model:
subjects and predicates become Minigraf keywords (:myapp, :depends-on), objects are
string values. The example shows tech-stack dependency evolution: a v1 graph is ingested,
a dependency is upgraded, the current state is queried via get_rel_map, and Minigraf's
:as-of <tx> temporal query recovers the pre-upgrade state from transaction history.
- Python:
minigraf==1.1.1,llama-index-core
Subclasses SimpleGraphStore from llama_index.core.graph_stores with Minigraf-backed
triplet storage and a raw Datalog pass-through in query().
Install prerequisites:
python3 -m venv .venv
. .venv/bin/activate
python -m pip install -r integrations/llamaindex-python/requirements.txtRun:
python integrations/llamaindex-python/minigraf_graph_store.pyExpected output:
myapp depends-on: pydantic==2.0, requests==2.28
requests depends-on: urllib3==1.26
myapp at tx 3 depended-on: pydantic==1.10, requests==2.28
Temporal model: Each upsert_triplet call is one Minigraf transaction. After three
ingestion calls, SNAPSHOT_TX = 3. Retracting and re-asserting a dependency advances the
transaction counter. (query [:find ?o :as-of 3 :where [:myapp :depends-on ?o]]) returns
the dependency set as it existed after transaction 3 — before the upgrade.