Skip to content

Architecture

Stack

  • Tauri v2 — Rust backend for project persistence, layer operations, and file validation
  • React — UI components (Canvas, Inspector, Toolbar, LayersPanel, Workspace, ProjectBar, ColorPicker, RecentProjects)
  • Zustand — State management with domain-driven stores (no Immer — plain spread operators for immutable updates)
  • Vite — Build tooling
  • Vitest — Test framework (13 test files, 236 tests)
  • pnpm workspaces — Monorepo with three packages
  • Claude Agent SDK — Multi-claude orchestration

Domain layer (packages/domain)

Pure TypeScript types with no runtime dependencies. Each file defines the shape of one domain concept:

FilePurpose
layer.tsLayer and LayerItem models — type, position, size, rotation, fill/stroke colors, visibility, locking
project.tsProject metadata — id, name, timestamps, schema version
command.tsCommandType enum (18 command types) and CommandResult for the dispatch system
viewport.tsViewportState (zoom/pan), zoom constants (0.1x — 5.0x), ContentBounds for fit-to-canvas
history.tsHistoryEntry, DocumentSnapshot, undoable vs non-undoable command classification, human-readable labels
selection.tsSelectionMode (replace/add/toggle), SelectionRect for marquee selection, SelectionBounds
persistence.tsProjectFile schema (version 1), RecentProject, DirtyState, validation result types
workspace.tsPanelId (layers/canvas/inspector/toolbar), PanelVisibility, WorkspaceState
color.tsColorValue type (hex strings), default fill (#2a2a38), default stroke (undefined — no stroke)

State layer (packages/state)

Zustand stores that implement domain behavior. Each store is a standalone create() call with typed state and actions:

StoreResponsibility
documentStoreLayer CRUD, item add/move/resize/delete, fill/stroke color changes
selectionStoreSingle-select, multi-select with modes (replace/add/toggle), marquee selectByRect, selectAll, invertSelection, getSelectionBounds
viewportStoreZoom in/out/to/reset, pan absolute/relative, fitToCanvas with content bounds
commandStoreCentral command dispatcher — routes 18 command types to the correct store, records history
historyStoreUndo/redo stack (max 100 entries), document snapshots, saved-state baseline tracking
persistenceStoreNew/save/save-as/open project via Tauri invoke, recent projects list, dirty/saving/loading state
workspaceStorePanel visibility toggles (layers, canvas, inspector, toolbar), active panel tracking
dirtyTrackerCross-store subscriber that marks persistenceStore dirty when documentStore changes after a project load

Rust backend (apps/desktop/src-tauri)

The Tauri backend exposes these commands to the frontend via invoke:

ModuleCommands
commands/project.rsnew_project, save_project, save_project_as, load_project, validate_project_file, get_recent_projects, add_recent_project
commands/layer.rscreate_layer, rename_layer, toggle_layer_visibility, delete_layer
commands/ping.rsping — health check that returns a timestamped pong response
error.rsAppError struct with code/message/hint shape

Projects are saved as .studioflow JSON files (schema version 1). Recent projects are stored in %LOCALAPPDATA%/studioflow/recent-projects.json (max 10 entries).

React components (apps/desktop/src)

ComponentRole
WorkspaceRoot layout — arranges Toolbar, LayersPanel, Canvas, and Inspector based on panel visibility
ToolbarMain toolbar with panel toggles, New Layer, Undo/Redo, Duplicate/Delete selection actions, keyboard shortcuts (Ctrl+Z, Ctrl+Shift+Z, Ctrl+D, Ctrl+A, Delete, arrow nudge)
ProjectBarSub-toolbar for project lifecycle — New, Open, Save, Save As with dirty indicator
CanvasViewport with zoom/pan transform, item rendering, click-to-select, drag-to-move, wheel zoom, Alt+drag pan, marquee rubber-band selection
LayersPanelLayer list with visibility/lock toggles, reorder up/down, inline rename (double-click), delete
InspectorContext-sensitive property editor — layer properties, single-item position/size/rotation/colors, multi-item batch editing with mixed-value indicators
ColorPickerHex color input with “mixed” state for multi-selection
RecentProjectsRecent project list with inline or modal overlay modes

Multi-claude architecture

StudioFlow uses the Claude Agent SDK to run independent agent sessions:

  • Builders execute in isolated git worktrees with full write access
  • Verifiers run as read-only sessions checking verification points
  • Integrators merge builder output through a controlled session
  • Packets define allowed/forbidden files per role to enforce boundaries

Phase 5 demonstrated 4 builder packets across 2 parallel waves. Phase 6 proved independent execution under the SDK runtime.