v0.4.2-rc.3SQL-first database with realtime updates
Private, realtime storage for AI agents
Store messages, agent memory, embeddings, and tool logs. USER tables keep every query inside the signed-in user boundary, while `live()` streams current rows to browsers and agents in realtime. Run vector search with SQL, then keep recent data fast and move older history to cheaper storage.
1import { createClient, Auth, SeqId } from'@kalamdb/client';23const client = createClient({4 url: 'http://localhost:8080',5 authProvider: async () => Auth.jwt('<ACCESS_TOKEN>'),6});78const resumeFrom = SeqId.from('7262216745594062848');910const stopMessages = await client.live(11`SELECT id, room, role, content, created_at12 FROM chat.messages`,13 (rows) => {14// `chat.messages` can be a USER table.15// The same query runs for every signed-in customer, but KalamDB only16// returns that caller's rows.17renderRows(rows);18 },19 {20 subscriptionOptions: {21 last_rows: 200,22 from_seq_id: resumeFrom.toJSON(),23 },24 },25);2627await client.query(28'INSERT INTO chat.messages (room, role, content) VALUES ($1, $2, $3)',29 ['main', 'user', 'hello from the browser']30);
Architecture
KalamDB Architecture
See how frontend queries, PostgreSQL workflows, and live updates flow through the KalamDB runtime.
Remote modePostgreSQL + pg_kalam
PostgreSQL connects to a running KalamDB server through pg_kalam.
PostgreSQL keeps SQL parsing, planning, and the local relation surface. The pg_kalam extension reads the foreign server definition, mirrors CREATE TABLE ... USING kalamdb, and forwards scans and DML to KalamDB.
1
PostgreSQL parses and plans the query against the local table surface.
2
pg_kalam resolves the foreign server settings and tenant session context.
3
Mirrored DDL, reads, and writes are forwarded to the KalamDB server.
4
Rows come back as PostgreSQL tuples while KalamDB stays the source of truth.
CREATEEXTENSION pg_kalam;
CREATESERVER kalam_server
FOREIGNDATAWRAPPER pg_kalam
OPTIONS (
host '127.0.0.1',
port '9188'
);
CREATETABLE app.messages (
id BIGINTPRIMARYKEYDEFAULTSNOWFLAKE_ID(),
room TEXT,
content TEXT
) USING kalamdb;
Core Pillars
Core pillars for AI agents and chat apps
Keep each user or tenant in their own data space. Query USER tables directly, stream materialized rows in realtime, use topics for pub/sub, and move old history to object storage when you need to scale.
Live
Per-tenant isolation — no app-side filters
Every user gets a private tenant partition. The same SQL can run for every account, and USER tables still return only that caller's rows. No app-side WHERE user_id = ? glue.
Familiar SQL for storage, subscriptions, and handoffs
No custom language to learn. Write standard SQL to create tables, save state, and subscribe to live updates. Keep hot data on local disk and store long-term history in object storage.
kalamdb — SQL Console
CREATE TABLE agent.messages (
id BIGINT DEFAULT SNOWFLAKE_ID(),
role TEXT,
content TEXT,
user_id TEXT,
created TIMESTAMP
) WITH (TYPE='USER');
Data Flow
Live state timeline
Agent writes can enter through PostgreSQL with pg_kalam, land in KalamDB, and fan back out to live subscribers in realtime.
Agent Writes to PostgreSQL
An agent or backend worker writes memory, tool output, or chat state into PostgreSQL.
pg_kalam Forwards
The pg_kalam extension resolves the foreign server and forwards that write into KalamDB.
KalamDB Commits State
KalamDB becomes the source of truth, keeping recent rows hot and moving older history to lower-cost storage when needed.
Subscribers Receive Live Rows
Materialized query updates stream over WebSocket to matching apps, dashboards, and agents.
Agents Resume from Latest State
The next agent step reads the newest committed row set and continues from the same shared state loop.
User Data Surface
Each user scope supports files, vectors, tables, and indexes
KalamDB is more than chat messages. Inside each user space, store tables, vectors, and file records so your agents can find what they need fast.
Files
Store file metadata, ownership, and processing status in user tables.
Vectors
Store embeddings in SQL tables and rank similar rows with vector search.
Tables
Model messages, tool calls, checkpoints, and your app data as SQL tables.
Indexes
Add indexes for fast lookups as your agent workload grows.
Use Cases
Built for secure, multi-tenant agent workloads
AI Chat History
Per-user chat threads with materialized live rows, resume checkpoints, and full history replay.
Agent Memory & Tool Events
Store tool calls, checkpoints, and agent state in durable per-tenant tables.
Semantic Retrieval & RAG
Store embeddings alongside documents and files, then find the nearest rows with SQL vector search.
Human-in-the-Loop Workflows
Agents pause for approval, humans respond, and agents resume. Every step is saved in a private per-user history.
Realtime Dashboards
Live metrics, monitoring feeds, and notification streams with row-materialized SQL subscriptions.
Multi-tenant SaaS isolation
Ship one codebase for every customer. USER tables keep each tenant in its own partition, so the same query only returns that tenant's data.
Collaboration Feeds
Shared docs, boards, and multiplayer state with instant sync.
Tooling
Every tool you need, out of the box
KalamDB includes a web Admin UI and an interactive CLI. Explore data, run SQL, subscribe to live streams, and manage users without extra tools.
🧭
Admin UI — SQL Studio & Live Data
Live
A web admin console that ships with every instance. Browse namespaces, inspect tables, and run SQL in the built-in SQL Studio. Turn on Live query to make anySELECT stream updates as rows change. Explore topics and per-user data without writing app code.
A Postgres-style terminal for local and cloud instances. Connect, query, subscribe, export user data, and manage users from one binary. It includes history, \info, and tab-completion. Great for scripts and CI.