Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

CrateJob
drusite-modelIDs, the page and block schema, schema versioning
drusite-crdtThe block model on Loro: one document per page, plus the workspace document
drusite-protoThe sync protocol
drusite-formulaNotion’s formula language: parser, type checker, evaluator
drusite-dbDatabases: views computed (formulas, rollups, relations, filters, groups), rows as Markdown
drusite-markdownMarkdown in and out
drusite-coreThe client engine and the Core API the UI talks to: the store, sync, search, Ask, import and export, the Markdown folder
drusite-e2eeEnd-to-end encryption’s keys and formats, with golden test vectors; no I/O
drusite-aiThe AI provider interface and its adapters: chat, embeddings, transcription
drusite-audioAudio decoding and cutting for meeting transcription
drusite-mcpThe MCP tools, shared by the server, the desktop app and the agent device
drusite-dpopProof-of-possession tokens (DPoP) for devices
drusite-serverThe server binary
drusite-agentThe agent device (drusite agent)
drusite-appThe Tauri 2 shell: the Core API over Tauri
tauri-plugin-drusitePlatform code: keys in the Keychain or Android’s keystore, signing in through the system browser, recording
drusite-wasmThe browser adapter: the core as WebAssembly
xtaskRepository 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.