The first design goal in AtomCut's architecture doc isn't about rendering, or performance, or the timeline. It's this: everything a project is lives in one versioned, zod-validated JSON document, and nothing editor-specific ever leaks into it. That sentence sounds like housekeeping. In practice it's the reason playback, scrubbing, MP4 export, undo, and a sandboxed third-party plugin are all the same kind of thing under the hood, instead of four systems that each have to be kept honest against the other three.
The document is the product
Here's the goal as written:
// ARCHITECTURE.md
1. **The document is the product.** Everything a project *is* — frames,
text, styles, ranges, animations, keyframes, sounds, captions, timing —
lives in one versioned, zod-validated JSON document (`AtomCutDocument`).
The web editor renders it; future native plugins (Premiere MOGRT, Resolve
Fusion, Blender bpy) read the same file and rebuild it with native
primitives. Nothing editor-specific ever leaks into the document.The test for "nothing editor-specific leaks in" is concrete: if a value only means something to the React app (a scroll position, a panel's open/closed state, which tool is selected), it does not go in AtomCutDocument. If it's a fact about the animation itself (a clip's start time, a keyframe's easing, a caption's word timing), it does, typed and validated. The schema currently sits at version 71 (packages/core/src/schema/document.ts), and the document is the actual save file: what you get when you export a project is this JSON, not a proprietary binary blob.
Purity is what makes the rest possible
The second goal follows directly from the first: @atomcut/core has no DOM and no React. The function that turns a document into a picture is deterministic — (document, time) → what you see — and every consumer of "what does this look like right now" calls the same function:
// ARCHITECTURE.md
2. **Core is pure.** `@atomcut/core` has no DOM, no React. Animation
evaluation (`evaluateTextGlyphs`, `evaluateCaptionGlyphs`,
`evaluateClipPose`, `buildSoundCues`) is deterministic:
`(document, time) → visual/audio state`. That's what makes playback,
scrubbing, MP4/WebM/PNG-sequence export, and future server rendering
the *same code path*.I don't think this is a novel idea — plenty of editors separate a model from a view. What I'd say is that it's easy to state and hard to actually hold onto once a feature needs "just one" DOM measurement inside the evaluation path, and the payoff only shows up much later: there's no separate "export renderer" that can silently drift from the "preview renderer," because architecturally there's nowhere for a second one to live.
Every one of 71 migrations still runs
A typed schema is only as good as its ability to open old files. AtomCut's migrations are a plain object keyed by version, each one upgrading a document by exactly one step:
// packages/core/src/io/index.ts
type Migration = (raw: Record<string, unknown>) => Record<string, unknown>;
/**
* Version migrations, applied in order from the file's version up to current.
* `migrations[n]` upgrades a version-n document to version n+1.
*/
const migrations: Record<number, Migration> = {
// v1 → v2: single `frame` config becomes `frames[]` (artboards); fps and
// duration move to the document root; visual clips gain `frameId`; captions
// gain the same in/out `animations` contract as text clips.
1: (raw) => {
const frame = (raw.frame ?? {}) as Record<string, unknown>;
const frameId = createId("frame");
// ... builds frames[] from the old single `frame` config, stamps
// frameId onto every visual clip, and returns the upgraded document.
},
// (69 more steps, v2 → v3 through v70 → v71)
};parseDocument walks that chain from whatever version a file claims up to DOCUMENT_VERSION, one step at a time:
// packages/core/src/io/index.ts
while (version < DOCUMENT_VERSION) {
const migrate = migrations[version];
if (!migrate) throw new DocumentParseError(`No migration path from document version ${version}.`);
data = migrate(data);
version++;
}There are 70 of these migration functions carrying a document from v1 to today's v71, and none of them have been deleted or collapsed — a project saved on day one of this schema still opens, one small upgrade at a time, in the current app. The trade is that io/index.ts only grows; every past decision about the document's shape stays legible as a diff instead of being silently reinterpreted.
Undo is a patch on the same document, not a second document
Undo could easily have been its own subsystem: a history of full document snapshots, diffed for display. AtomCut's store instead runs every mutation through immer's produceWithPatches and keeps only the forward and inverse patches:
// packages/core/src/history/document-store.ts
/**
* The document store: single source of truth for the (undoable) document.
*
* Every `update` runs an immer recipe and records only the resulting patches
* (forward + inverse) — memory cost is proportional to what changed, never a
* full snapshot. Continuous gestures (slider drags, typing, clip drags) pass a
* `mergeKey`; consecutive updates with the same key within the merge window
* coalesce into a single history entry, so undo granularity matches user
* intent instead of input events.
*/The mergeKey detail matters more than it looks. Without it, dragging a slider for two seconds at 60fps would push around 120 history entries, and one undo would step back a barely-perceptible fraction of the drag. With it, every update sharing a key inside a merge window becomes one entry, one undo, one whole gesture reversed, because the store is asking "does this look like a continuation of the last thing you did" rather than "did another mutation happen."
What a plugin gets from all of this
This is where the design goal stops being an internal nicety and becomes an actual product surface. A plugin is a floating window running in a sandboxed iframe with a null origin — it can't reach into the host page, read files, or touch your account. The only door out is a small set of typed calls, each gated behind a capability the plugin declared up front:
// packages/plugin-sdk/src/capabilities.ts
export const CAPABILITIES = {
"document:read": "Read the document — its frames, layers and properties.",
"document:write": "Create, edit and remove layers in the document.",
"selection:read": "See and react to what the user has selected.",
"ui:notify": "Show toast messages in the editor.",
} as const;Because the document is already the one typed, validated boundary that every internal feature reads and writes through, exposing a slice of it to a plugin doesn't require a parallel API surface. document:write for a plugin goes through the same store, the same patches, the same undo stack as a first-party panel — a plugin's edit is exactly as reversible as your own. That's not a feature I had to build for plugins specifically; it fell out of the document already being the single source of truth.
The manifest that declares which capabilities a plugin wants is itself a versioned, zod-validated schema, for the same reason the document is:
// packages/plugin-sdk/src/manifest.ts
export const pluginManifestSchema = z.object({
manifestVersion: z.literal(MANIFEST_VERSION),
id: z.string().regex(PLUGIN_ID_RE, "id must be reverse-DNS style, e.g. com.acme.confetti"),
name: z.string().min(1).max(60),
version: z.string().regex(SEMVER_RE, "version must be semver, e.g. 1.0.0"),
capabilities: z.array(z.enum(capabilityKeys)).default([]),
window: pluginWindowSchema.default({}),
});The schema lives in packages/core/src/schema, the plugin SDK in packages/plugin-sdk, and the docs page a plugin author actually starts from is /docs/plugins. The repo is here.
