Architecture
Drusite is local-first: every device holds a full, encrypted copy of the workspaces it syncs, and edits there first. The server is where devices meet, and where the work that needs every page (server search, Ask, meeting jobs, publishing, agents) happens for standard workspaces.
┌──────────── Device (desktop, phone, browser, agent device) ────────────┐
│ UI (Svelte 5) │
│ │ Core API (generated TypeScript types) │
│ drusite-core ── Loro documents ── SQLCipher store (key in the OS) │
│ │ search (words, and meaning with a model), Markdown folder, MCP │
└────┼────────────────────────────────────────────────────────────────────┘
│ WebSocket: sync protocol 2 (drusite-proto), DPoP-bound tokens
┌────┼──────────────────────── drusite-server ────────────────────────────┐
│ axum: sign-in, sync hub, search, Ask, AI, meetings, publish, MCP │
│ Cedar policy ─ row-level security │
└──┬───────────────────────┬──────────────────────┬───────────────────────┘
│ │ │
PostgreSQL 16+ S3-compatible store Key source
+ pgvector (attachments, (env, file, or
(accounts, documents, recordings) OpenBao/Vault Transit)
history, search)
The documents
- One Loro document per page, holding its blocks, plus one document per workspace holding the page tree, titles, properties, database schemas and row values. Loro is a CRDT: edits from any number of devices merge without a central lock, and every change is kept, which is where version history comes from.
- Restricted pages (private, or shared with some people) are listed in tree documents of their own, which only the people they’re shared with can sync.
- The block model follows Notion’s: pages of blocks, databases whose rows are pages, with Notion’s property types and formula language.
The crates
| Crate | Job |
|---|---|
drusite-model | IDs, the page and block schema, schema versioning |
drusite-crdt | The block model on Loro: one document per page, plus the workspace document |
drusite-proto | The sync protocol |
drusite-formula | Notion’s formula language: parser, type checker, evaluator |
drusite-db | Databases: views computed (formulas, rollups, relations, filters, groups), rows as Markdown |
drusite-markdown | Markdown in and out |
drusite-core | The client engine and the Core API the UI talks to: the store, sync, search, Ask, import and export, the Markdown folder |
drusite-e2ee | End-to-end encryption’s keys and formats, with golden test vectors; no I/O |
drusite-ai | The AI provider interface and its adapters: chat, embeddings, transcription |
drusite-audio | Audio decoding and cutting for meeting transcription |
drusite-mcp | The MCP tools, shared by the server, the desktop app and the agent device |
drusite-dpop | Proof-of-possession tokens (DPoP) for devices |
drusite-server | The server binary |
drusite-agent | The agent device (drusite agent) |
drusite-app | The Tauri 2 shell: the Core API over Tauri |
tauri-plugin-drusite | Platform code: keys in the Keychain or Android’s keystore, signing in through the system browser, recording |
drusite-wasm | The browser adapter: the core as WebAssembly |
xtask | Repository tooling: performance budgets, bindings, version bumps, the docs |
ui/ | The frontend (TypeScript and Svelte 5), which reaches the core only through ui/src/core/client.ts |
The server
One binary with its modules inside:
- Sign-in (
auth): passkeys, passwords with TOTP, magic links and OIDC, all ending in an OAuth 2.1 authorization for the app, with DPoP-bound tokens. - Sync (
sync): a hub per workspace that takes pushes, checks them against the policy, stores them, and fans them out; it compacts each document’s log into snapshots. - Keys (
keys,crypto): each standard workspace has its own key, wrapped by the master key; everything stored is sealed with it. - Policy (
policy): who may do what is a Cedar policy, checked on every request, and repeated in PostgreSQL by row-level security, so a bug in one is caught by the other. - Search (
search): a background indexer writing words (tsvector) and vectors (pgvector) for standard workspaces. - Ask, AI and meetings (
ask,ai,meetings): retrieval, prompts and streaming answers; the model catalog; meeting jobs that resume after a restart. - Publish (
publish): server-rendered HTML for published pages, optionally on a listener of its own. - MCP (
mcp): the agents’ endpoint, with OAuth consent and an activity log for undo. - The web app (
web): the built UI, served at/.
It keeps no state of its own between requests, so it scales out behind a load balancer.
End-to-end encrypted workspaces
For an encrypted workspace, devices seal every document entry and file before it leaves them, and the server stores and relays what it can’t open, checking signatures and membership but never contents. Search, Ask, meetings and agents move to the devices (or to an agent device). The design is in End-to-end encryption.