# TriviumDB

Current stable release is 0.9.1 across Rust, Python, Node.js, CLI, and Server source. Full bilingual release notes are available at https://github.com/YoKONCy/TriviumDB/blob/master/docs/changes/0.9.1.md . Frozen ICDE measurements and source identities are available at https://github.com/YoKONCy/TriviumDB/tree/master/evaluation .

Document APIs provide source revisions, logical blocks, grouped text/vector/hybrid retrieval, phrase and proximity evidence, parser mappings, and staged publication. DOCUMENTS sources and GRAPH scopes integrate documents and named graphs into TQL, Prepared queries, and Planner. QuIVer offers centered INT8/INT4 reranking, FP32/INT8/INT4 query representations, SSD/Hot residency, byte-bounded caches, native I/O, and aligned window reuse. Document ANN can select compressed reranking per request. Rust, Python, and Node share Core semantics.

> TriviumDB is a native tri-model embedded database engine written in Rust. Vector search, property graphs, and JSON documents share one storage kernel and NodeId space. A unified Cascades optimizer plans cross-model TQL query pipelines. Native APIs are available for Rust, Python, and Node.js. License: Apache-2.0.

TriviumDB runs inside the host application. Applications use it for AI agent memory, AI companion memory, retrieval-augmented generation (RAG), local knowledge bases, and knowledge graphs. Independent database instances support per-agent, per-session, and per-tenant data organization in desktop applications and containers.

- Native tri-model unification: vector, graph, and document operations share the same storage kernel, node identities, and transaction system. NodeIds connect optional vectors, JSON payloads, indexed text, and graph edges. Applications combine semantic similarity, document predicates, and graph relationships over the same data.
- Typed query values: WITH projections capture per-row values and node identities across graph expansion. Aggregation, DISTINCT, alias ordering, and pagination share evaluation semantics. Unsigned vectors and integers retain their exact values through the corresponding typed APIs.
- Unified Cascades planning: TQL brings vector recall, document filtering, text retrieval, graph traversal, paths, set operations, aggregation, iteration, and reranking into one query pipeline. The same deterministic, cost-driven Cascades optimizer plans these cross-model pipelines using shared statistics, index availability, and resource budgets. MATCH, FIND, SEARCH, and WITH express the combined query.
- Vector retrieval: f32, f16, and u64 storage; exact vector search; and the QuIVer approximate nearest-neighbor (ANN) index. QuIVer uses compact 2-bit representations, sign-magnitude SM-L2 navigation, and candidate reranking with stored vectors. Dimension-aware automatic index construction supports growing datasets. The engine supports vector dimensions from 1 to 65,536, with QuIVer ANN covering 1 to 3,072 dimensions.
- Text retrieval: BM25 ranking and Aho-Corasick keyword matching support text search and hybrid recall. Text and vector recall can feed graph expansion and reranking.
- Graph operations: directed labeled edges with weights and metadata; neighborhood expansion; reachability; shortest paths; PageRank; connected components; Leiden community detection; and spreading activation with personalized restart (SA-PPR).
- Property indexes: persistent Hash, Ordered ART, Composite ART, and Roaring Bitmap indexes accelerate equality, range, prefix, composite, and low-cardinality set predicates.
- Transactions and persistence: vector, JSON payload, and graph mutations share transactions and an append-only write-ahead log (WAL). Text-index registrations persist through flush() and writable close(). Checkpoints, recovery, and background compaction manage durable storage.
- Storage modes: Rom packs vectors, JSON payloads, and edges into a portable .tdb data file. Mmap uses a .tdb main file, mapped .vec vectors, and generation-scoped .pld payload files. Tiered vector and Payload storage support on-demand reads and byte-bounded parsed JSON caching.
- Instance management: a shared ResourceRuntime coordinates per-instance heap and workspace budgets, maintenance allocations, worker threads, and task slots. Diagnostics expose instance and resource usage. Controlled shutdown persists data and releases instance resources; directory snapshots support consistent backup and restore.
- Search customization: six-stage search-pipeline hooks support custom recall, graph expansion, reranking, and result processing through Rust, Python, Node.js, and C/C++ FFI integrations.

## Documentation

- [English overview](https://raw.githubusercontent.com/YoKONCy/TriviumDB/master/README_EN.md): Product overview, installation, examples, and usage patterns.
- [Chinese overview](https://raw.githubusercontent.com/YoKONCy/TriviumDB/master/README.md): Chinese product overview, installation, and examples.
- [API reference](https://raw.githubusercontent.com/YoKONCy/TriviumDB/master/docs/api-reference.md): Rust, Python, and Node.js APIs, configuration, parameters, and return values.
- [TQL reference](https://raw.githubusercontent.com/YoKONCy/TriviumDB/master/docs/tql-reference.md): Unified Cascades planning, cross-model query syntax, pipeline operators, graph algorithms, and data mutations.
- [Features](https://raw.githubusercontent.com/YoKONCy/TriviumDB/master/docs/features.md): Native tri-model data model, shared storage kernel, indexing, transactions, and retrieval capabilities.
- [QuIVer vector index](https://raw.githubusercontent.com/YoKONCy/TriviumDB/master/docs/quiver.md): Quantized graph navigation, vector reranking, automatic construction, and index configuration.
- [Resource runtime](https://raw.githubusercontent.com/YoKONCy/TriviumDB/master/docs/resource-runtime.md): Shared resource budgets, thread pools, task admission, and instance diagnostics.
- [Shutdown, snapshots, and restore](https://raw.githubusercontent.com/YoKONCy/TriviumDB/master/docs/lifecycle-snapshots.md): Instance lifecycle, consistent directory snapshots, verification, and restore.
- [Best practices](https://raw.githubusercontent.com/YoKONCy/TriviumDB/master/docs/best-practices.md): Data modeling, application integration, retrieval patterns, and resource configuration.

- [0.9.1 release notes](https://raw.githubusercontent.com/YoKONCy/TriviumDB/master/docs/changes/0.9.1.md) provide bilingual changes, format and upgrade conditions, configuration, and installation versions.

## Packages

- [Rust crate](https://crates.io/crates/triviumdb): Embedded Rust API and package installation.
- [Python package](https://pypi.org/project/triviumdb/): Python bindings and package installation.
- [Node.js package](https://www.npmjs.com/package/triviumdb): Native Node.js bindings and TypeScript definitions.

## Optional

- [Hook guide](https://raw.githubusercontent.com/YoKONCy/TriviumDB/master/docs/hook-guide.md): Search-pipeline extensions, custom recall, reranking, and FFI integration.
- [CLI guide](https://raw.githubusercontent.com/YoKONCy/TriviumDB/master/crates/triviumdb-cli/README.md): The tdb command-line tool, database inspection, REPL, and terminal UI.
- [Storage integrity and concurrency](https://raw.githubusercontent.com/YoKONCy/TriviumDB/master/docs/security.md): Transaction atomicity, generation publication, concurrent access, and FFI contracts.
- [Source repository](https://github.com/YoKONCy/TriviumDB): Rust engine, language bindings, and examples.
- [Apache-2.0 license](https://raw.githubusercontent.com/YoKONCy/TriviumDB/master/LICENSE): Software license.
