Expand description
§sqlite-graphrag
Local GraphRAG memory for LLMs in a single SQLite file — zero external services required.
sqlite-graphrag is a CLI-first library that persists memories, entities and
typed relationships inside a single SQLite database. It combines FTS5
full-text search with sqlite-vec KNN over locally-generated embeddings to
expose a hybrid retrieval ranker tailored for LLM agents.
§CLI usage
Install and initialize once, then save and recall memories:
cargo install sqlite-graphrag
sqlite-graphrag init
sqlite-graphrag remember \
--name onboarding-note \
--type user \
--description "first memory" \
--body "hello graphrag"
sqlite-graphrag recall "graphrag" --k 5§Crate layout
The public modules group the CLI, the SQLite storage layer and the
supporting primitives (embedder, chunking, graph, namespace detection,
output, paths and pragmas). The CLI binary wires them together through the
commands in commands.
§Exit codes
Errors returned from errors::AppError map to deterministic exit codes
suitable for orchestration by shell scripts and LLM agents. Consult the
README for the full contract.
Modules§
- chunking
- Token-aware chunking utilities for bodies that exceed the embedding window. Semantic chunking for embedding inputs (Markdown-aware, 512-token limit).
- cli
clapdefinitions for the top-levelsqlite-graphragbinary. CLI argument structs and command surface (clap-based).- commands
- Subcommand handlers wired into the
claptree fromcli. - constants
- Compile-time constants: embedding dimensions, limits and thresholds. Compile-time constants shared across the crate.
- daemon
- Daemon IPC for persistent embedding model reuse across CLI invocations. IPC daemon: keeps the embedding model warm across CLI invocations.
- embedder
- Local embedding generation backed by
fastembed. fastembed wrapper and per-process embedding cache. - errors
- Library-wide error type and the mapping to process exit codes (see
errors::AppError). Library-wide error type. - extraction
- Hybrid entity extraction: regex pre-filter + candle BERT NER (graceful degradation). Entity and URL extraction pipeline (NER + regex prefilter).
- graph
- Graph traversal helpers over the entities and relationships tables. Entity graph traversal (BFS over memory_entities + relations).
- i18n
- Bilingual message layer for human-facing stderr progress (
--lang en|pt,SQLITE_GRAPHRAG_LANG). Bilingual human-readable message layer. - lock
- Counting semaphore via lock files to limit parallel invocations (see
lock::acquire_cli_slot). Counting semaphore via lock files to limit parallel CLI invocations. - memory_
guard - Memory guard: checks RAM availability before loading the ONNX model. Memory guard: checks RAM availability before loading the ONNX model.
- migrations
- namespace
- Namespace resolution with precedence between flag, environment and markers. Namespace resolution layer (flag > env > “global” fallback).
- output
- Centralized stdout/stderr emitters for CLI output formatting. Single point of terminal I/O for the CLI (stdout JSON, stderr human).
- parsers
- Dual-format argument parser: accepts Unix epoch and RFC 3339. Input format parsers (Markdown, YAML, plain text, timestamp).
- paths
- Filesystem paths for the project-local database and app support directories. XDG/cwd path resolution and traversal-safe overrides.
- pragmas
- SQLite pragma helpers applied on every connection. SQLite PRAGMA helpers applied at connection open and on each transaction.
- storage
- Persistence layer: memories, entities, chunks and version history. SQLite persistence layer: sub-modules for each domain table group.
- tokenizer
- Real tokenizer of the embedding model for accurate token counting and chunking. Token-count utilities for embedding input sizing.
- tz
- Display time zone for
*_isofields (flag--tz, envSQLITE_GRAPHRAG_DISPLAY_TZ, fallback UTC). Display timezone for*_isofields in JSON output.
Statics§
- SHUTDOWN
- Signals that a shutdown signal (SIGINT / SIGTERM / SIGHUP) has been received.
Functions§
- shutdown_
requested - Returns
trueif a shutdown signal has been received since the process started.