AiiB

technology / decisions

What we chose,and what we did not.

This is a record of decisions, not a list of libraries. Every choice has a reason and a cost. The yardstick: documents remain as assets, and nothing ties you to a particular AI or service.

app shell

How much of the app shell to own

We use the OS WebView and write only the native parts in Rust.

Chosen
Tauri 2 (OS WebView plus Rust), shipping a static React and Next.js export
Not chosen
Electron (bundles a browser engine), per-OS native interfaces
Deciding factor
The download stays small, one codebase serves Mac and Windows, and it runs inside the Mac sandbox
What it costs
We keep absorbing the differences between WKWebView and WebView2

languages

Which language for what

The line is not “which could write this” but “could we recover if it broke”.

TypeScript
Interface, template definitions, document semantics. Changes often and benefits from types that describe structure
Rust
Saving, sync, images, keys, OS integration. Work that cannot be recovered if it fails, or must not block the interface
Node.js
The AI loop and MCP server. The SDKs are there, and it can be a process separate from the interface and Rust
What it costs
Three runtimes. To avoid copying knowledge across languages, Rust handles edit updates without interpreting their content

data and sync

Where data lives and how edits merge

We decided first that it must work with no server, and chose from there.

Chosen
Embedded SQLite, with CRDT merging (Yjs in the interface, yrs in Rust with the same format)
Not chosen
A server database, last-write-wins sync
Deciding factor
It works without a server, and edits made offline on both sides merge to the same result regardless of order. yrs compacts updates without the interface
What it costs
Edit logs grow and need compacting. yrs is pinned to 0.26 because of the Rust version

rendering

What draws slides and designs

We prototyped and measured a Rust GPU renderer, then decided not to ship it for now. Being new is not a reason to adopt something.

Chosen
HTML and SVG on screen, DrawingML for Office
Not chosen
Vello (Rust GPU rendering). The prototype stays, unintegrated until it is needed
Deciding factor
Measurements gave no reason to prefer it over today’s SVG on speed, expressiveness or size. On Mac, SVG and Canvas2D were faster
What it costs
Output is not pixel-identical across operating systems, and it cannot draw without a browser engine

office export

How to hand off to Office

The priority is that recipients can edit in their own Office.

Chosen
Generate Office elements directly (pptxgenjs, docx). Equations go from KaTeX’s MathML to Word equations
Not chosen
Pasting images, converting through HTML
Deciding factor
Tables stay tables, charts keep their data, equations stay equations. And we do not maintain our own LaTeX parser
What it costs
Matching both the preview and Office. Both are drawn from the same definitions, and automated checks watch for drift

image processing

Where to shrink images

Pasted images live inside the document, so this decides how heavy documents get.

Chosen
Process in Rust (fast_image_resize, jpeg-encoder)
Not chosen
The browser canvas
Deciding factor
Measured at 22–38 ms in Rust against 56–112 ms for canvas (three screenshots and one photo). Results match on Mac and Windows, and the interface does not stall
What it costs
More parts. The standard image crate’s JPEG output was 20–30% larger, so encoding uses a separate part

ai connection

How to connect AI

We chose not to fold AI into the product.

Chosen
MCP and your own API key. Local models through llama.cpp’s OpenAI-compatible API
Not chosen
Bundling AI costs into the product, integrations tied to one AI
Deciding factor
When a better AI arrives, switch and keep your assets. With no AI costs of our own, flat-rate AI apps connect at no added cost
Keys
API keys never reach the interface. Rust reads them from the OS credential store and sends them only to allowed destinations
What it costs
Absorbing differences between AIs. Each one needs its own verification; MCP is verified with Claude so far

template selection

How AI chooses a template

Before adding search infrastructure, we reworked the information it chooses from.

Chosen
Two stages: narrow by when to use and when not to, then rank by how templates are used
Not chosen
Embedding vector search
Deciding factor
Measured: applying the usage distribution to the narrowed list raised top-1 accuracy from 30.9% to 44.7%, with no search infrastructure in the download
What it costs
Every new template needs its when-to-use and when-not-to-use. Automated checks catch omissions

dependency policy

Dependency policy

version
Pin versions and upgrade what passes the checks
alignment
Align Rust dependencies with the versions Tauri uses
tls
Fixed to rustls, avoiding differences between OS certificate stores
store builds
Store binaries do not include features that run arbitrary programs
new dependency
Adopted after confirming the benefit outweighs size and startup cost