Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:869413421 Ai moive studio Canvas Document Management

From Leeroopedia
Knowledge Sources
Domains Architecture, UI
Last Updated 2026-10-23 12:00 GMT

Overview

Technique for managing an infinite-canvas document model where text, image, and video nodes are connected via typed edges to form generation workflows.

Description

Canvas Document Management provides a graph-based data model for visual workflow building. A CanvasDocument contains CanvasItems (nodes) and CanvasConnections (edges). Each item has a type (text, image, video), position, dimensions, content, and a generation configuration. Connections link items via source/target handles to form a directed graph representing data flow.

Key operations:

  • Document CRUD: Create, list, update, delete canvas documents per user
  • Item CRUD: Create, update, delete individual nodes with position, content, and config
  • Connection CRUD: Create and delete typed edges between items
  • Graph save: Atomic save of the entire graph state (items + connections), upserting incoming items and deleting items not in the incoming list
  • Media sanitization: Media URLs in item content are sanitized to object keys for storage

Usage

Use this principle when building visual workflow editors that need a persistent graph model. Apply when users construct generation pipelines by connecting nodes on an infinite canvas. Use when node content may contain media references that need URL-to-key normalization.

Theoretical Basis

The graph model:

G=(V,E),V={i1,…,in},E={(s,t,hs,ht)}

Where V is the set of canvas items, E is the set of connections with source/target items and handle specifications.

# Abstract graph save (atomic upsert)
existing = {item.id: item for item in load_items(document)}
incoming_ids = {item["id"] for item in incoming_items}

# Delete items not in incoming list
for item in existing.values():
    if item.id not in incoming_ids:
        delete(item)

# Upsert incoming items
for payload in incoming_items:
    item = existing.get(payload["id"]) or create_new(payload)
    update_fields(item, payload)

# Replace all connections
delete_all_connections(document)
for conn in incoming_connections:
    create_connection(conn)

Practical Guide

  • Use atomic graph save for full-state persistence (upsert items, replace connections)
  • Sanitize media URLs to object keys before storage to avoid storing presigned URLs
  • Validate that connection source/target items belong to the same document
  • Support z-index ordering for visual layering
  • Track generation status per item (idle, processing, completed, failed)

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment