# contextdb

An embedded database for AI agent memory that unifies relational storage, graph traversal and vector similarity search under one set of transactions, replacing a typical stack of SQLite plus a separate vector store.

contextdb combines relational tables, graph traversal and vector similarity search inside one embedded, single-file database with unified MVCC transactions, aimed at applications that would otherwise stitch together SQLite for state, a separate vector database for embeddings, and application code for graph queries and validation. It enforces policy constraints such as state-machine transitions, DAG structure and cascading updates directly in the database, rejecting an invalid state change rather than relying on application-level checks or triggers.

Each agent, device or service runs its own local contextdb, and separate instances sync bidirectionally through a central server over WebSocket, so knowledge one agent learns becomes available to others with per-table conflict resolution and no port forwarding or VPN required. It uses PostgreSQL-compatible SQL, pgvector-style syntax for vector search, and an SQL/PGQ-style bounded graph query for traversal, and is currently a Rust library and command-line tool, with Python and TypeScript bindings planned.

Website: https://contextdb.tech
