TapirusDB
The 100% Safe-Rust (#![forbid(unsafe_code)]) Embedded Quad-Model AI Database & Cognitive Memory Engine.
Relational SQL, HNSW Vector Search, Property Graphs / GraphRAG, JSON Document Collections, and Transactional AI Memory unified inside a single encrypted, crash-safe .tapir file and write-ahead log.
Explore the web tutorials, browse the API cookbook, or launch the Rust Browser WASM Workspace.
Core Architecture & Capabilities
- Four Data Models + AI Memory in One ACID Engine
- Relational SQL & SQLite Compatibility:
CREATE TABLE(withGENERATED ALWAYS AS (...)computed columns),CREATE [UNIQUE] INDEX(single, composite, expression & partialWHEREindexes),FOREIGN KEY(ON DELETE/ON UPDATE),CHECK,DEFAULT,CREATE TRIGGER(BEFORE/AFTER,WHEN,RAISE),FTS5full-text search,WITH [RECURSIVE]CTEs,UNION/UNION ALL/INTERSECT/EXCEPT(with trailingORDER BY/LIMIT/OFFSET),CROSS JOIN,CASE WHEN ... END,CAST(... AS ...), SQLite scalar & date/time built-ins (IIF,IFNULL,NULLIF,REPLACE,INSTR,TRIM/LTRIM/RTRIM,TYPEOF,DATE,TIME,DATETIME,STRFTIME,UNIXEPOCH,JULIANDAY, math &HEX), arithmetic/concat expressions, multi-columnORDER BY(columns & projected aliases), correlated & uncorrelated scalar subqueries inSELECT,WHERE,HAVING, CTEs &UPDATE SET, chained multi-tableJOINs with filtered indexed seek joins, subqueries ([NOT] EXISTS,[NOT] IN), column-to-columnWHEREcomparisons,ORindex-union planning (USING INDEX UNION),ON CONFLICT DO UPDATEupserts withEXCLUDED.<col>expressions,RETURNING, window functions, parameterized prepared statements, and C-ABIsqlite3_*compatibility (sqlite3_open_v2,sqlite3_prepare_v2,sqlite3_bind_*,sqlite3_step,sqlite3_column_*,sqlite3_exec) intapirus-ffi. - Vector Search & Quantization: Exact and HNSW approximate nearest neighbors, disk-backed paged HNSW, optional
wideSIMD kernels (--features simd), 8-bit scalar quantization (QuantizedVector8), and RaBit bit-packed Walsh-Hadamard quantization (RaBitQuantizer). - Graph & GraphRAG: Labelled property nodes and weighted edges, Compressed Sparse Row (
CsrGraph) export, PageRank, Dijkstra shortest path, connected components, betweenness centrality, Louvain community detection,GRAPH MATCH/CYPHERqueries, and fluentGraphChainhybrid traversal. - JSON Document Collections & Transactional AI Memory: Schemaless document APIs alongside indexed
storeMemory/upsertMemory/searchMemorieshybrid retrieval combining HNSW cosine similarity, BM25 lexical scoring, temporal recency decay, and importance via Reciprocal Rank Fusion (RRF) or weighted scoring — persisted in compact binaryTPMEM001rows with CRC32-validated__sys_memory_indexHNSW snapshots.
- Relational SQL & SQLite Compatibility:
- MVCC Snapshot Readers & Multi-Process SWMR WAL
SessionDatabaseprovides owned logical write sessions (session(),session_with_timeout()) plus non-blocking MVCC committedSnapshotSessionreaders (snapshot_reader(),mvcc_epoch()) that execute immediately without waiting on active uncommitted write transactions.Connection::open_concurrent*andConnection::open_read_only*coordinate multiple OS processes over SWMR WAL (refresh_from_disk(), acquiring.tapir-lockonly for writers).
- Hardened Cryptography, Zeroization & Native TLS
- Storage AEAD: Per-page 256-bit XChaCha20-Poly1305 encryption (
24-byte CSPRNGXNonce) with PBKDF2-HMAC-SHA256 key derivation (600,000iterations), constant-time KCV check, and Poly1305 AAD bindingpage_id+ Page 1 immutable security/format header fields. - Memory Hygiene: Non-
CloneDatabaseCipher(Zeroize+Drop), PBKDF2/HMAC stack buffer zeroization, andConfigsecret scrubbing with[REDACTED]Debugformatting onConnection::open*andtapirus serve. - Zero-Trust HTTP & MCP Server (
tapirus serve/tapirus mcp): Native Rustls TLS 1.2/1.3 (--tls-cert/--tls-key), loopback-by-default bind, constant-time header-only API key verification, AST-enforced SQL RBAC (--api-key-role KEY=readonly|readwrite[:tables]), per-owner AI Memory namespace isolation (--api-key-namespace,MemoryAccessScope,Connection::scoped_memory), opt-in CORS allowlist, defensive HTTP headers, and configurable Ollama / OpenAI-compatible HTTP neural embeddings. - Browser / WASM Encryption:
@tapirus/wasmand the smaller@tapirus/wasm-liteSQL/Crypto profile support end-to-end encrypted in-memory databases and.tapirsnapshots viaTapirusWasm.new_encrypted(passphrase)andTapirusWasm.import_encrypted_bytes(bytes, passphrase).
- Storage AEAD: Per-page 256-bit XChaCha20-Poly1305 encryption (
- Formal Verification & Supply-Chain Discipline
- MSRV Rust 1.88+ tracking patched cryptographic crates (
chacha20poly1305 0.11.0,ctutils 0.4.8,sha2 0.11.1), verified via OSV (scripts/check-dependency-advisories.py:0active production advisories across223locked registry packages). - Single-writer WAL crash-safety specification (TAPIRUS_WAL.tla) verified in CI by TLC2 (
552,520generated states,120,535distinct states,0invariant violations acrossTypeOK,RecoveredDiskMatchesCommitted,CheckpointedDiskMatchesCommitted, andNoUncommittedCheckpoint).
- MSRV Rust 1.88+ tracking patched cryptographic crates (
- Modular Editions & Edge-to-Cloud Footprint
- Build the full Quad engine (
tapirus), single-model entry points (tapirus-lite,tapirus-document,tapirus-graph,tapirus-vector), or bare-metalno_stdallocation-free flash storage (tapirus-micro) with signed offline capsule bridging into Quad (tapirus-iot).
- Build the full Quad engine (
Quickstart
Rust
Add tapirus (rust-version = "1.88") to Cargo.toml:
use ;
Or build single-model binaries cleanly from source:
Node.js (sdks/nodejs)
const = require;
const db = ;
db.;
const sources = db.;
console.log;
db.;
Python (sdks/python)
Secure HTTP & MCP Daemon (tapirus serve / tapirus mcp)
Start tapirus serve with native Rustls TLS 1.2/1.3, namespace-isolated API keys, AST-enforced SQL RBAC, and explicit CORS allowlisting:
Run an MCP server backed by a local Ollama or OpenAI-compatible neural embedding endpoint:
Build, Verification & Packaging
Verify formatting, strict lints, standalone editions, dependency advisories, and the full test suite locally:
Containerized execution (runs as a non-root user with /data volume persistence):
Documentation Map
- Security & Formal Verification
- SECURITY.md — Vulnerability disclosure, cryptographic guarantees, and deployment hardening
- Security Architecture & Threat Model — Trust boundaries and v1.1.0 third-party audit RFP
- TLA+ Formal WAL Specification — Crash-safety model and CI TLC2 verification
- Engineering Assurance Architecture — Safety boundaries, memory safety, and verification controls
- Architecture & Guides
- Complete Query Syntax Reference — SQL, Vector, Graph, Cypher, Parquet/OLAP, FTS5, TAP & Pragmas (web view)
- API Cookbook — Verified Rust, SQL, Vector, Graph, Encryption, and AI Memory recipes
- Transactional AI Memory & AI Embedded Workflows
- Editions & Build Profiles | IoT Capsules (
tapirus-micro) - Storage & Paging | WAL, MVCC & Recovery | SIMD Vector & Quantization | GraphBLAS & openCypher
- Language SDKs | Release Validation | Current Release Status
- Panduan TAP (BM) | Interactive Local Web Guide (BM)