SochDB Documentation
Welcome to the official SochDB documentation. SochDB is The LLM-Native Database β a high-performance embedded database designed specifically for AI applications.
Current Version: v0.4.4 (Core) | Python SDK v0.4.7 | Node.js SDK v0.5.1 | Go SDK v0.4.3
What is SochDB?β
SochDB is a single database that replaces your vector DB + relational DB + prompt packer stack. Store structured data, embeddings, and conversation history togetherβthen ask SochDB to assemble token-optimized context for your LLM.
Comparisonβ
Database + retrieval layerβ
| Feature | SochDB | SQLite + vec | Postgres + pgvector | Chroma | LanceDB |
|---|---|---|---|---|---|
| Embedded | β | β | β | β | β |
| Vector search | β HNSW | β οΈ (via extension) | β (HNSW / IVFFlat) | β | β |
| Full SQL (user-facing) | β SQL-92 | β | β | β | β |
| Hybrid search (vector + keyword) | β | β οΈ (DIY) | β οΈ (DIY) | β οΈ (limited) | β |
| Context builder | β | β | β | β | β |
| Token budgeting | β | β | β | β | β |
| Graph overlay | β | β | β | β | β |
| ACID transactions | β | β | β | β οΈ (limited) | β |
| Columnar storage | β | β | β | β | β |
Memory / agent-memory layerβ
| Feature | SochDB | Mem0 | Letta | Graphiti |
|---|---|---|---|---|
| Primary focus | DB + retrieval + context | Memory layer | Agent framework + memory | Temporal knowledge-graph memory |
| Long-term memory primitives | β | β | β | β |
| Token-aware context budgeting | β | β | β | β |
| Graph-based memory | β | β | β | β |
| Built-in vector store | β | β (BYO) | β (BYO) | β (BYO) |
| Built-in agent runtime | β | β | β | β |
| Drop-in βmemory add-onβ to existing apps | β | β | β οΈ | β |
Quick links: π Documentation β’ Quick Start β’ Architecture β’ TOON Format β’ Benchmarks β’ RFD
Why SochDB?β
β The Typical AI Agent Stackβ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β YOUR APPLICATION β
βββββββββ¬ββββββββββββββββββ¬ββββββββββββββββββ¬ββββββββββββββββββ¬ββββββββββββββββββββ
β β β β
βΌ βΌ βΌ βΌ
βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ βββββββββββββββββββββββββββββ
β Postgres β β Pinecone β β Redis β β Custom Code β
β (metadata) β β (vectors) β β (sessions) β β (context assembly) β
β β β β β β β β
β β’ User data β β β’ Embeddings β β β’ Chat state β β β’ Token counting β
β β’ Settings β β β’ Similarity β β β’ Cache β β β’ Truncation logic β
β β’ History β β search β β β’ Temp data β β β’ Prompt packing β
β β β β β β β β’ Multi-source fusion β
βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ βββββββββββββββββββββββββββββ
β β β β
βββββββββββββββββββ΄ββββββββββββββββββ΄ββββββββββββββββββ
β
βββββββββββββββββ΄ββββββββββββββββ
β π° You manage all of this: β
β β’ 4 different query languages β
β β’ 4 sets of credentials β
β β’ 4 failure modes β
β β’ No cross-system transactionsβ
β β’ Weeks of glue code β
βββββββββββββββββββββββββββββββββ
β With SochDBβ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β YOUR APPLICATION β
βββββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββ
β SochDB β
β β
β SQL + Vectors + Context Builder β
β β
β β’ One query language β
β β’ One connection β
β β’ ACID transactions β
β β’ Token budgeting built-in β
β β
βββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββ΄ββββββββββββββββββ
β π What you actually ship: β
β β’ Single ~700KB embedded DB β
β β’ Zero external dependencies β
β β’ Works offline β
β β’ Deploys anywhere β
βββββββββββββββββββββββββββββββββββββ
The Problem β Solutionβ
| Challenge | Traditional Stack | SochDB |
|---|---|---|
| Token waste | JSON/SQL bloat in prompts | TOON format for dense output |
| RAG plumbing | Separate vector DB + glue code | Built-in HNSW with hybrid search |
| Context assembly | Custom packer per use case | One query with token budget |
| I/O overhead | Multiple DB round-trips | Single columnar read |
| Consistency | Distributed transaction headaches | Local ACID guarantees |
| Deployment | Manage 4 services | Single binary, embed anywhere |
Key Featuresβ
π§ Context Query Builder β Assemble system + user + history + retrieval under a token budget
π Hybrid Search β HNSW vectors + BM25 keywords with reciprocal rank fusion
πΈοΈ Graph Overlay β Lightweight relationship tracking for agent memory
β‘ Embedded-First β ~700KB binary, no runtime dependencies, SQLite-style simplicity
π Full ACID β MVCC + WAL + Serializable Snapshot Isolation
π Columnar Storage β Read only the columns you need
Why SochDB existsβ
Most "agent stacks" still glue together:
- a KV store (sessions / state)
- a vector DB (retrieval)
- a prompt packer (context budgeting, truncation)
- a relational DB (metadata)
β¦and then spend weeks maintaining brittle context assembly and token budgeting.
SochDB collapses that stack into one LLMβnative substrate: you store structured data + embeddings + history and ask the DB to produce a tokenβefficient context payload.
What you can rely on todayβ
β LLM + agent primitivesβ
- TOON: compact, model-friendly output for context windows
- Graph Overlay: lightweight agent-memory graph with BFS/DFS traversal and relationship tracking
- ContextQuery builder: token budgets, deduplication, and multi-source fusion
- Policy hooks: safety controls with pre-built policy templates and audit trails
- Tool routing: multi-agent coordination with dynamic discovery and load balancing
- Hybrid retrieval: vector + BM25 keyword with Reciprocal Rank Fusion (RRF)
- Multi-vector documents: chunk-level aggregation (max / mean / first)
- Vector search (HNSW): integrated into retrieval workflows
β Database fundamentalsβ
- SQL (SQL-92): SELECT / INSERT / UPDATE / DELETE / JOINs
- AST-based query executor: unified SQL processing with dialect normalization
- Multi-dialect compatibility: MySQL, PostgreSQL, SQLite
- Idempotent DDL:
CREATE TABLE IF NOT EXISTS,DROP TABLE IF EXISTS
- ACID transactions with MVCC
- WAL durability + group commit
- Serializable Snapshot Isolation (SSI)
- Columnar storage with projection pushdown (read only the columns you need)
- Sync-first architecture: async runtime (tokio) is optional
- ~500KB smaller binaries for embedded use cases
- Follows SQLite-style design for maximum compatibility
β Developer experienceβ
- Rust client:
sochdb - Python & Nodejs & Golang SDK with:
- Embedded mode (FFI) for lowest latency
- IPC mode (Unix sockets) for multi-process / service deployments
- Namespace isolation for multi-tenant apps
- Typed error taxonomy with remediation hints
- Bulk vector operations for high-throughput ingestion
Known limitsβ
- Single-node only (no replication / clustering yet)
SochDB in one pictureβ
| Problem | Typical approach | SochDB approach |
|---|---|---|
| Token waste | JSON/SQL payload bloat | TOON: dense, table-like output |
| RAG plumbing | External vector DB + glue | Built-in HNSW + quantization |
| Context assembly | multiple reads + custom packer | One context query with a budget |
| I/O amplification | row store reads all columns | columnar + projection pushdown |
Quick Installβ
- Rust
- Python
- Node.js
- Go
cargo add sochdb
use sochdb::Database;
fn main() -> anyhow::Result<()> {
let db = Database::open("./my_app_db")?;
db.with_transaction(|txn| {
txn.put(b"users/alice", br#"{"name": "Alice", "role": "admin"}"#)?;
Ok(())
})?;
if let Some(user) = db.get(b"users/alice")? {
println!("{}", String::from_utf8_lossy(&user));
}
Ok(())
}
pip install sochdb
from sochdb import Database
db = Database.open("./my_app_db")
with db.transaction() as txn:
txn.put(b"users/alice", b'{"name": "Alice", "role": "admin"}')
user = db.get(b"users/alice")
print(user.decode()) # {"name": "Alice", "role": "admin"}
db.close()
npm install @sochdb/sochdb
import { Database } from '@sochdb/sochdb';
const db = Database.open('./my_app_db');
await db.withTransaction(async (txn) => {
await txn.put('users/alice', '{"name": "Alice", "role": "admin"}');
});
const user = await db.get('users/alice');
console.log(user?.toString());
await db.close();
go get github.com/sochdb/sochdb-go@v0.4.3
package main
import (
"fmt"
sochdb "github.com/sochdb/sochdb-go"
)
func main() {
db, _ := sochdb.Open("./my_app_db")
defer db.Close()
db.WithTransaction(func(txn *sochdb.Transaction) error {
return txn.Put("users/alice", []byte(`{"name": "Alice", "role": "admin"}`))
})
user, _ := db.Get("users/alice")
fmt.Println(string(user))
}
Documentation Sectionsβ
π Getting Startedβ
Step-by-step guides to get you up and running quickly.
- Quick Start β 5-minute intro
- Installation β All platforms
- First App β Build something real
π Guidesβ
Task-oriented guides for specific use cases.
Language SDKs:
- Rust SDK β Native Rust guide
- Python SDK β Complete Python guide (v0.4.7)
- Node.js SDK β TypeScript/JavaScript guide (v0.5.1)
- Go SDK β Go client guide (v0.4.3)
Features:
- SQL Guide β Working with SQL queries
- Vector Search β HNSW indexing
- Bulk Operations β Batch processing
- Deployment β Production setup
AI Agent Safety & Memory:
- Policy & Safety Hooks β Pre/post operation validation
- Multi-Agent Tool Routing β Route tools across agents
- Graph Overlay β Lightweight graph for agent memory
- Context Query β Token-aware retrieval for LLMs
π‘ Conceptsβ
Deep dives into SochDB's architecture and design.
- Architecture β System design
- TOON Format β Token-optimized format
- Performance β Optimization guide
π API Referenceβ
Complete technical specifications.
- SQL API β SQL query reference
- Rust API β Crate documentation
- Python API β Full Python API docs
- Node.js API β TypeScript/JavaScript API
- Go API β Go package documentation
π οΈ Server Referenceβ
Deep technical documentation for SochDB servers and tools.
- IPC Server β Wire protocol & architecture
- gRPC Server β Vector search service
- Bulk Operations β High-performance tools
π³ Cookbookβ
Recipes for common tasks.
- Vector Indexing β Embedding workflows
- MCP Integration β Claude integration
- Logging β Observability setup
Quick Linksβ
| I want to... | Go to... |
|---|---|
| Get started in 5 minutes | Quick Start |
| Use Namespace & Collections | Python SDK |
| Use Priority Queues | Python SDK |
| Use Memory System | Node.js SDK |
| Use SQL queries | SQL Guide |
| Use the Rust SDK | Rust Guide |
| Use the Python SDK | Python Guide |
| Use the Node.js SDK | Node.js Guide |
| Use the Go SDK | Go Guide |
| Add vector search | Vector Search |
| Integrate with Claude (MCP) | MCP Integration |
| Enforce agent safety policies | Policy Hooks |
| Route tools across agents | Tool Routing |
| Model agent memory relationships | Graph Overlay |
| Build token-aware context | Context Query |
| Understand the architecture | Architecture |
| See the SQL API reference | SQL API |
External Linksβ
- sochdb.dev β Main website
- GitHub β Source code
- Python SDK β Python SDK repo
- Node.js SDK β Node.js SDK repo
- Go SDK β Go SDK repo
- Discussions β Community Q&A