SochDB Documentation
Welcome to the official SochDB documentation. SochDB is The LLM-Native Database β a high-performance database designed specifically for AI applications, usable embedded or as a server.
Current Version: v2.0.3 (Core engine) | Python SDK v0.5.9 | Node.js SDK v0.5.3 | Go SDK v0.4.5
SochDB ships under a split license. The core engine (the Rust workspace β the sochdb crate, server, and MCP) is AGPL-3.0-or-later, with commercial licensing available. The language SDKs (Python, Node.js, Go) are Apache-2.0.
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) | β | β |
| SQL (user-facing) | β joins, aggregates, GROUP BY | β | β | β | β |
| 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 β’ Performance β’ 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 (+ a grep lane) with Reciprocal Rank Fusion (RRF)
- Multi-vector documents: chunk-level aggregation (max / mean / first)
- Vector search (HNSW): integrated into retrieval workflows
The context builder, policy hooks, tool routing, and graph overlay are real importable modules in the Rust and Node.js SDKs. In the Python SDK they are example patterns (shipped in sochdb-python-examples, not importable SDK classes) β Python's first-class agent surface is the AgentMemory API. See Agent Memory and the per-language SDK guides.
β Database fundamentalsβ
- SQL:
SELECT/INSERT/UPDATE/DELETEplus DDL (CREATE/DROP TABLE,CREATE/DROP INDEX,ALTER TABLE)- Joins:
INNER,LEFT,RIGHT,FULL, andCROSS - Aggregates & GROUP BY:
COUNT,SUM,AVG,MIN,MAX(plusMEDIANandSTDDEVvia the SQL aggregate path), withHAVING EXPLAIN: textual query-plan output via the Volcano executorVECTOR_SEARCH(...): vector similarity directly in SQL- AST-based query executor: unified Volcano operator engine with dialect normalization
- Multi-dialect compatibility: MySQL, PostgreSQL, SQLite
- Idempotent DDL:
CREATE TABLE IF NOT EXISTS,DROP TABLE IF EXISTS
- Joins:
- 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
β Server (v2.0)β
Run SochDB as a service with the sochdb-grpc-server binary and connect over multiple protocols.
- Authentication & RBAC: API keys (SHA-256, or HMAC-SHA256 with a pepper), JWT validation (HS256, validation-only), TLS/mTLS, and
Owner/Editor/Viewerroles with per-namespace scoping - CDC & subscriptions: WAL-derived change-data-capture stream with gRPC
Subscribe/WatchKeyand table/operation filtering - Observability: Prometheus metrics endpoint (
/metrics) and a health endpoint - WebSocket gateway: JSON protocol for SQL, KV, and subscribe messages
- Postgres wire protocol: connect with
psqland standard Postgres drivers (simple-query mode) - At-rest encryption: AES-256-GCM-SIV engine for data blocks, WAL, and checkpoints (library API)
- Agent memory: episodic write/search with bi-temporal point-in-time queries and token-budgeted context
Upgrading from v0.4.x? See the v2.0 migration guide.
β 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 today (no built-in replication or clustering). A server node can fan out to clients over gRPC, WebSocket, and Postgres wire, and the CDC subscription stream is the building block for downstream replication, but the engine itself does not yet replicate or shard across nodes.
The AES-256-GCM-SIV encryption engine is a shipped, unit-tested library API, but it is not yet wired to a server CLI flag β sochdb-grpc-server does not construct an encryption engine on its main path. Treat it as an available API / planned wiring, not a runtime toggle. See Encryption.
The Postgres-wire endpoint supports simple-query only, has no auth (trust), and is cleartext (no TLS). Keep it loopback-only unless you accept the risk, and pass --pg-data-dir to back it with real persistent SQL. See Postgres Wire.
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.put(b"users/alice", br#"{"name": "Alice", "role": "admin"}"#)?;
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';
// EmbeddedDatabase.open() is synchronous
const db = Database.open('./my_app_db');
await db.withTransaction(async (txn) => {
await txn.put(
Buffer.from('users/alice'),
Buffer.from('{"name": "Alice", "role": "admin"}'),
);
});
const user = await db.get(Buffer.from('users/alice'));
console.log(user?.toString());
db.close();
go get github.com/sochdb/sochdb-go
The Go SDK is remote-first by default; the embedded engine lives in the
embedded subpackage and requires the sochdb_embedded build tag
(go build -tags sochdb_embedded).
package main
import (
"fmt"
"github.com/sochdb/sochdb-go/embedded"
)
func main() {
db, _ := embedded.Open("./my_app_db")
defer db.Close()
db.Put([]byte("users/alice"), []byte(`{"name": "Alice", "role": "admin"}`))
user, _ := db.Get([]byte("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 (crate
sochdbv2.0.3) - Python SDK β Complete Python guide (v0.5.9)
- Node.js SDK β TypeScript/JavaScript guide (v0.5.3)
- Go SDK β Go client guide (v0.4.5)
Features:
- SQL Guide β Working with SQL queries
- Vector Search β HNSW indexing
- Bulk Operations β Batch processing
- Deployment β Production setup
AI Agent Safety & Memory:
- Agent Memory β Episodic write/search with bi-temporal queries
- 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
Server & Operations:
- Security β Auth, RBAC, TLS/mTLS, API keys & JWT
- Encryption β At-rest AES-256-GCM-SIV (library API)
- CDC & Subscriptions β Change-data-capture streams
- Observability β Prometheus metrics & health checks
- Migration to v2.0 β Upgrade from v0.4.x
π‘ 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
- WebSocket Gateway β JSON protocol for SQL/KV/subscribe
- Postgres Wire β Connect with
psqland Postgres drivers - 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 |
| Use agent memory | Agent Memory |
| Secure the server (auth/RBAC) | Security |
| Stream changes (CDC) | CDC & Subscriptions |
| Scrape Prometheus metrics | Observability |
Connect with psql | Postgres Wire |
| Upgrade from v0.4.x | Migration to v2.0 |
| Use the Node.js API | Node.js API |
| Use the Go API | Go API |
| 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