跪拜 Guibai
← All articles
Frontend · GitHub · Algorithms

Mindlink: An AI Document Editor Built on Block Trees, CRDT Sync, and Private Deployment

By 徐小夕 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Self-hosted teams can now get block-based editing, CRDT real-time sync, and AI features without letting document content leave their own infrastructure. The JSON Schema export and plugin hooks also make Mindlink usable as an embeddable editor base for knowledge bases, work-order systems, and internal CMS products, not as another SaaS platform to migrate into.

Summary

Mindlink is a self-hosted AI document editor whose core bet is that a document is not a styled HTML string but an ordered tree of addressable blocks. Each block carries id, type, data, and toolsets, which gives deterministic cross-client rendering, block-granular diffs, and a registration-based extension system that does not require kernel changes. Collaboration runs on CRDT rather than OT: terminals merge edits causally, can keep writing through network loss, and avoid the delete-resurrection bug that plagues operation-ordered sync.

Sync traffic stays small with a binary incremental-frame protocol: a typical keystroke produces a frame under 200 bytes, and the server only forwards frames and appends a change log. Documents are sharded into collaboration rooms with snapshots and online member lists, and reconnection uses baseline exchange, delta catch-up, and continuous push. Rendering avoids whole-page flicker by hashing block content into semantic fingerprints, applying only insert/delete/move/content-change DOM operations, and anchoring the cursor to moved blocks.

The architecture splits into presentation, kernel, collaboration, and service layers. The kernel does not assume a backend exists, so Mindlink can run fully offline as a frontend component, while the service layer is replaceable and built for one-click private deployment: reverse proxy, process daemon, embedded database, and a storage abstraction that switches between SQLite, MySQL, and Postgres. Six plugin hooks add custom block types, toolsets, slash commands, import/export pipelines, AI provider routing, and themes; block data exports as standard JSON Schema. The stated performance targets are block insert under 100ms, 1000-block document open under 500ms, and first-screen static resources under 30KB gzipped.

Takeaways
— Mindlink stores documents as ordered arrays of blocks; each block has an id, a type, data, and a set of toolsets.
— The block model replaces HTML-string storage, so rendering is deterministic and diffs are scoped to individual blocks.
— Mindlink uses CRDT instead of OT because CRDT has no central authority, supports offline edits, and prevents deleted text from reappearing.
— Every local edit is encoded as a 20–400 byte binary frame; a normal keystroke produces a frame under 200 bytes.
— Each document is a separate collaboration room holding a CRDT snapshot and online member list; reconnection syncs through baseline exchange, delta catch-up, and continuous push.
— Rendering applies semantic fingerprint hashing, position-plus-content diffing, and cursor anchoring to avoid full-page redraws when remote changes arrive.
— The architecture has four layers: presentation, kernel, collaboration, and service; the kernel can run without a backend and each layer can be replaced independently.
— The server exposes only REST and a long-connection gateway, keeps domain modules cohesive, and abstracts storage so SQLite, MySQL, or Postgres can be selected.
— Extension hooks cover block types, toolsets, slash commands, import/export pipelines, AI provider adapters, and theme/CSS injection; block data exports as JSON Schema.
— Performance targets are block insert under 100ms, 1000-block document open under 500ms, keystroke frame under 200 bytes, and first-screen static resources under 30KB gzipped.
Conclusions

The stated view of documents as information carriers, with formatting as one property, justifies the block model. Once tables, whiteboards, mind maps, and business components are block types, the extension API matters more than the formatting toolbar.

Making AI a customer-routed, off-by-default adapter is what lets Mindlink call itself an AI document editor while keeping “data never leaves the intranet” true. Without that design choice, the AI feature would fail the compliance test that private deployment is meant to pass.

Positioning Mindlink as an editor base, not a full platform, avoids head-on competition with Feishu, Tencent Docs, and Notion. It also turns developers who build knowledge bases and work-order systems into distribution channels for the underlying editor.

The performance targets are unglamorous, and that is the point: sub-200 byte sync frames and sub-500ms open times for a thousand-block document are the thresholds that make offline-first collaboration feel tolerable on weak networks.

Concepts & terms
Block-based document model
A document is an ordered array of blocks, each with its own id, type, data, and toolsets, instead of a styled HTML string. This makes rendering deterministic, keeps diffs and sync at block granularity, and lets new block types plug in without changing editor kernel code.
CRDT (Conflict-Free Replicated Data Type)
A data structure that lets multiple replicas edit independently and merge deterministically without a central server. Commutativity and idempotence guarantee all replicas converge to the same state regardless of merge order, which supports offline editing.
OT (Operational Transformation)
The older collaborative editing approach where a central server orders operations before applying them. It depends on the server being authoritative and can produce ordering bugs such as deleted text reappearing.
Incremental frame protocol
A sync format that sends only the changed state as compact binary frames, each tagged with a causal baseline version number. Mindlink encodes a typical keystroke in under 200 bytes instead of transferring the whole document.
Semantic fingerprint diff
A rendering optimization that hashes normalized block content and structure to detect whether the meaning of a block changed, ignoring typographic details. Blocks whose fingerprint is unchanged are skipped during redraw, preventing whole-page flicker.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗