SQL-native database + reactive realtime

Private, real-time chat storage for AI apps

Messages, agent memory, and tool logs — isolated per user, and streamed live to clients. Scales as history explodes: hot stays fast, cold moves to low-cost object storage with replay.

KALAMDB_JWT_SECRET="$(openssl rand -base64 32)" \
curl -sSL https://kalamdb.org/docker-compose.yml | docker-compose -f - up -d
KalamDB — Sample Code
1-- chat.messages is a per-user table.
2-- Every user sees their own isolated data automatically (no user_id column needed).
3CREATE TABLE chat.messages (
4  id         BIGINT DEFAULT SNOWFLAKE_ID(),
5  thread_id  TEXT,
6  role       TEXT,         -- 'user' | 'assistant' | 'tool'
7  content    TEXT,
8  created_at TIMESTAMP
9) WITH (TYPE='USER');
10
11-- Topic routing and consumption
12CREATE TOPIC chat.message_events PARTITIONS 2;
13ALTER TOPIC chat.message_events
14ADD SOURCE chat.messages
15ON INSERT
16WITH (payload = 'full');
17
18-- User sends a message (written into their own private space)
19INSERT INTO chat.messages (thread_id, role, content, created_at)
20VALUES ('thread_42', 'user', 'Can you check my invoice?', NOW());
21
22-- Agent worker consumes message events to trigger processing (e.g. tool calls/thinking/replying/streaming)
23CONSUME FROM chat.message_events GROUP 'chat-worker-1' FROM LATEST LIMIT 50;
24  -- Agent writes back impersonation (same user scope; still isolated)
25  EXECUTE AS USER 'service_bot' (
26    INSERT INTO chat.messages (conversation_id, role_id, content)
27    VALUES (1, 'assistant', 'I processed your request')
28  );
29ACK chat.message_events GROUP 'chat-worker-1' UPTO OFFSET 50;
30
31-- User live subscribes to new messages in a thread.
32-- NOTE: No `user_id = ...` — the connection is already scoped to the user.
33SUBSCRIBE TO chat.messages
34WHERE thread_id = 'thread_42'
35OPTIONS (last_rows = 20);
36

Core pillars for AI chat + agent infrastructure

The default building blocks for private per-user data, topics + pub/sub, live SQL subscriptions, and agent workloads — built to handle the data explosion agents create.

🔐
Live

Per-user isolation by default

Each user gets a private data space. No user_id filters. Share only when you choose.

Read more →
📬
Live / Planned

Topics + Pub/Sub streams

Publish events to topics and subscribe from any client or agent — built-in fanout. Replay + consumer groups can be marked planned.

Read more →
📡
Live

Live queries (SQL subscriptions)

SUBSCRIBE TO any query — clients stay up to date as data changes (messages, state, tool logs).

Read more →
🗄️
Live

Bring your own storage

Use S3 / Blob / GCS / local for cold history so costs scale with storage, not always-on compute.

Read more →
📦
Live

Sharded by nature + columnar cold storage

Isolation creates natural shards per user. Older history can compact into efficient columnar files in object storage for lower cost and faster scans.

Read more →
🧩
Live

High availability clustering (Raft)

Nodes form a Raft cluster with leader election and failover, keeping chat and subscriptions online.

Read more →
🦀
Live

Predictable performance (Rust)

Low-latency writes and stable throughput for chat + high-volume agent events.

Read more →
🛡️
Planned

Client-side encryption

Encrypt before data leaves the device. KalamDB stores ciphertext — you control the keys.

Read more →
🧭
Live

Admin UI: SQL Studio, Live Data and more

Web admin console for instances, users, and streams with a built-in SQL Studio, live SUBSCRIBE TO rows/events, topic browsing, replay controls (if enabled), and per-user namespace exploration.

Read more →
⌨️
Live

CLI tool (kalamdb)

Postgres-like CLI for local + cloud instances with core commands: connect, query, subscribe, export, delete-user, show-users, show-storage.

Read more →

KalamDB Architecture

End-to-end system architecture for query execution, storage tiers, and real-time data flow.

KalamDB architecture diagram

Familiar SQL for storage, subscriptions, and handoffs

No custom DSL. No vendor lock-in SDK. Write standard SQL to create tables, insert state, and subscribe to live updates across local disk and object storage backends powered by Rust object_store.

kalamdb — SQL Console
CREATE TABLE agent.messages (
  id       BIGINT DEFAULT SNOWFLAKE_ID(),
  role     TEXT,
  content  TEXT,
  user_id  TEXT,
  created  TIMESTAMP
) WITH (TYPE='USER');

Live state timeline

Write state, trigger filtered subscriptions, sync users and agents instantly.

Agent Writes

Memory or tool-call state is inserted via SQL

KalamDB Persists

Hot writes in RocksDB, cold data in object storage via Rust object_store

Subscribers Notified

Filtered live updates pushed over WebSocket

Agents Resume

UI and agents continue from latest state

Each user scope supports files, vectors, tables, and indexes

KalamDB is not only chat rows. Inside each user boundary, you can organize structured tables, vector-enabled records, file metadata, and indexes for fast retrieval by agents.

🗂️

Files

Store file metadata, ownership, and processing status in user-scoped tables.

🧠

Vectors

Keep embeddings with user records so agents can run semantic memory retrieval.

🧱

Tables

Model messages, tool calls, checkpoints, and domain entities as normal SQL tables.

📇

Indexes

Create indexes inside tables for low-latency lookups and scalable agent workloads.

Built for modern application workloads

💬

AI Chat History

Per-user thread memory with real-time message streaming and full history replay.

🤖

Agent Memory & Tool Events

Store tool calls, checkpoints, and agent state in durable per-tenant tables.

👥

Human-in-the-Loop

Agents pause for approval, humans respond, agents resume — all through shared state.

📊

Realtime Dashboards

Live metrics, monitoring feeds, and notification streams via SQL subscriptions.

🔔

App notifications

Deliver in-app notifications and alerts with SQL subscriptions and replayable history.

🔄

Collaboration Feeds

Shared docs, boards, and multiplayer state with instant sync across clients.

Every tool you need, out of the box

KalamDB ships with a full web-based Admin UI and an interactive CLI — no third-party clients required to explore data, run queries, subscribe to live streams, or manage users.

🧭

Admin UI — SQL Studio & Live Data

Live

A web-based admin console bundled with every instance. Browse namespaces, inspect tables, and run any SQL directly in the built-in SQL Studio. Flip on Live query to turn any SELECT into a real-time subscription — rows update as data lands. Explore topics, replay consumer offsets, and drill into per-user data spaces without writing a single line of application code.

Read more →
⌨️

CLI — Interactive Database Terminal

Live

A Postgres-style interactive terminal for local and cloud instances. Connect, query, subscribe, export user data, and manage users from a single binary. Supports command history, \info for session details, and full tab-completion. Ideal for scripting, CI pipelines, and quick inspection without opening a browser.

Read more →

Give every user isolated data. Give every agent access.

One database for per-user isolation, agent collaboration, and realtime subscriptions. Start building in minutes.