Introducing a new way to review your PRs.

Read the announcement

walterlow / freecut

FreeCut is a professional-grade video editor that runs entirely in your browser. Professional video editing, zero installation. Create stunning videos with multi-track editing, keyframe animations, real-time preview, and high-quality exports.

View on GitHub

19 documents · Updated Oct 30, 2026

docs / project-lifecycle

Project lifecycle

A project is the unit of work that connects an edit, its media links, and its delivery settings. The lifecycle starts when an engineer creates or imports a project, continues as the editor loads and saves it, and ends when the project is restored or removed from the workspace.

Lifecycle model

The project-facing features guide a project from a workspace entry to an active edit and back to durable storage. The storage layer supplies the workspace and file records, while the project layer decides when those records represent a visible project.

This diagram shows the main project path and the two ways work can enter the workspace.

flowchart TD
    A[Workspace access] --> B{Project source}
    B -->|New project| C[Project settings]
    B -->|Bundle import| D[Validate and extract]
    C --> E[Create project record]
    D --> E
    E --> F[Projects list]
    F --> G[Select project]
    G --> H[Open editor]
    H --> I[Load and migrate edit]
    I --> J[Save project changes]
    J --> F
    F --> K[Move to trash]
    K -->|Restore| F
    K -->|Delete forever| L[Remove project and eligible media]
    H --> M[Bundle export]

Workspace access

The workspace is the user-selected folder that makes project routes storage-dependent. Before the Projects page or editor can run, the workspace gate finds or requests a read/write folder handle, checks permission, and sets that folder as the active storage root. If permission is lost during a session, the gate stops protected routes until the user reconnects the folder. WorkspaceGate and WorkspaceRoot define this boundary.

References: src/…/workspace-gate.tsx• L4-20 src/…/workspace-gate.tsx• L55-80 src/…/root.ts• L22-47

Project creation

Creation begins on the Projects page and uses a form for the project name, description, canvas size, and frame rate. The project feature creates a new identity and initial metadata, then writes the project before it opens the editor. A failed write rolls back the visible list so the page does not present a project that storage did not accept. ProjectForm and project helpers define the user input and initial project shape. ProjectStore coordinates the state change and write.

The headless project API supports the same creation boundary for external callers. When a caller supplies an ID, a request left pending by a process failure can be recovered by adopting an exact matching project, rerunning creation only when the project is absent, and rejecting a different project under the same ID. Without a caller-supplied ID, a pending request remains indeterminate instead of creating a possible duplicate. Headless create recovery verifies these outcomes.

References: src/…/project-form.tsx• L25-75 src/…/project-helpers.ts• L137-166 src/…/project-store.ts• L139-161 headless/serve.mjs• L147-175 headless/project-create-recovery.test.mjs• L82-147

Project selection

The Projects page is the project switch point. It loads visible projects from the workspace and lets the user search, sort, and filter them by project metadata. Selecting a card or its open action navigates to the editor with the project ID. The project route checks that the project exists, passes the small set of editor metadata needed to start, and leaves the full edit load to the editor lifecycle. ProjectList, ProjectCard, and the editor route define this flow.

The app also remembers the last editor project ID for reload and update recovery. This cache helps restore navigation, but it is not a source of project data. Last editor project provides that narrow navigation aid.

References: src/…/index.tsx• L43-52 src/…/project-list.tsx• L79-98 src/…/project-card.tsx• L142-163 src/…/$projectId.tsx• L4-38 src/…/last-editor-project.ts• L11-42

Editor persistence

Opening a project loads its saved edit into the editor state. The load path applies project migrations and current data defaults before it hydrates the editor, then checks whether timeline items still point to available media. Saving performs the reverse: it captures the editor state as a project timeline, removes session-only media URLs, updates the project record, and refreshes the project cover when possible. This keeps the project file independent from short-lived browser URLs. Timeline persistence owns this editor-to-project boundary.

Project metadata and timeline data travel together as the project record. Media bytes and derived media data remain separate. The project timeline refers to media by ID, so the editor can resolve current media access when it loads instead of relying on stale URLs.

References: src/…/timeline-persistence.ts• L916-1063 src/…/timeline-persistence.ts• L1065-1075 src/…/timeline-persistence.ts• L1233-1340 src/…/project.ts• L22-49

Project removal and recovery

Normal deletion moves a project to workspace trash instead of destroying it at once. The live project list hides trashed projects, while the Trash section can restore them or request permanent deletion. Permanent deletion removes the project record and asks the media layer to remove media that no longer has another project reference.

The delete action can also remove files from a project-specific external folder. That choice is explicit and cannot be undone by restoring the project. Without that choice, the project content stays available for restore until the trash purge policy removes it. ProjectStore and TrashSection define these user-visible states.

References: src/…/project-store.ts• L233-388 src/…/trash-section.tsx• L4-23 src/…/paths.ts• L79-89

Bundle exchange

Bundles move a project between workspaces or machines with the edit and its media. Export gathers the project record and associated media, writes a manifest with content hashes, and packages the project data in a .freecut.zip file. Import validates the archive before extraction, writes media to a user-selected folder, creates a new project identity, and remaps timeline media references to the new media records.

The bundle can also carry an optional project cover and saved animation presets. A lightweight JSON snapshot is a separate exchange form for project structure and media references; it does not carry media files. See Project bundle workflows for the detailed archive and snapshot flows.

References: src/…/bundle-export-service.ts• L73-255 src/…/bundle-import-service.ts• L46-244 src/…/bundle-timeline.ts• L6-61 src/…/bundle.ts• L23-151 src/…/json-export-service.ts• L24-86

System boundaries

Project-facing features express user actions and project state. Storage infrastructure owns the durable workspace records and browser file access. Keeping these roles separate lets the editor work with a project model without exposing workspace file layout to every feature.

Project-facing responsibilities

The project feature owns the visible project list, form input, selection, editor navigation, trash actions, and bundle commands. Its state uses project IDs and project objects as the contract with storage. It may update the visible state before a write completes, but it must restore that state when the write fails.

Project data includes identity, name, description, timestamps, delivery metadata, and the timeline. A project may also hold a root-folder reference used for media relinking and relative path display. The project model does not mean that media bytes are embedded in the project.

References: src/…/project-store.ts• L24-88 src/…/project.ts• L22-49 src/…/project-card.tsx• L169-185

Storage infrastructure responsibilities

Storage infrastructure exposes project operations through the storage boundary and maps them to the active workspace. Each project has a durable project record under its project ID, while a workspace index provides a fast visible list. The project records are authoritative; the index can be rebuilt when it is missing or stale.

File-system handles are not written into project JSON. The storage layer keeps them in its handle registry and attaches them when it reads the project. This preserves a portable JSON record while still allowing the app to use a user-granted folder for local media work.

Headless lifecycle storage adds a separate service boundary for API clients. It uses atomic project writes, per-project coordination, revisions for save conflicts, and an idempotency ledger for retried requests. These controls protect durable workspace state without changing the project-facing model.

References: src/…/index.ts• L1-17 src/…/projects.ts• L1-10 src/…/projects.ts• L88-139 src/…/projects.ts• L176-245 src/…/workspace-index.ts• L17-59 headless/…/lifecycle-store.mjs• L55-230 headless/…/idempotency.mjs• L75-171

Project and media relationships

The project record stores the edit structure, while media records store file identity and access details. A project-media association connects the two. This link allows one media record to serve more than one project and lets permanent project deletion clean up only media that has no remaining project use.

Bundle import creates new media records when it extracts files. Bundle export starts from the project-media associations rather than from file paths inside the timeline. This is why media ID remapping is a required part of import and why a missing association can produce an incomplete transfer.

References: src/…/index.ts• L48-56 src/…/bundle-export-service.ts• L85-97 src/…/bundle-import-service.ts• L75-169 src/…/project-store.ts• L362-388

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to the Project shape or schema version must remain aligned with editor load/save, migration rules, bundle data, snapshot validation, and headless create recovery matching.
  • Changes to timeline media references must update both bundle conversion and import remapping. Check root timelines and nested compositions.
  • Changes to project paths or index entries must preserve the relationship between the authoritative project records, the visible list, trash markers, and headless resource listing.
  • Changes to root-folder fields must preserve the split between serializable project data and the handle registry.
  • Changes to deletion or media association rules must preserve restore behavior and reference-aware media cleanup.
  • Changes to the editor route metadata contract must stay aligned with the full project load that follows navigation.
  • Changes to headless create retries must preserve request-hash checks, deterministic-ID matching, and the distinction between safe recovery and indeterminate replay.

Important failure modes

TriggerConsequenceGuard
The workspace folder is missing, unsupported, or no longer permittedProtected project and editor routes cannot read or write project dataWorkspaceGate blocks those routes and offers folder selection or reconnect.
A project is missing or has a trash markerThe project does not appear in the live list and the editor route rejects its IDNormal reads exclude trashed projects; the Trash section uses its separate listing.
index.json is missing or corruptThe project list can lose its fast index viewStorage rebuilds the index from project directories and treats project records as the source of truth.
A bundle checksum or required archive file is invalidImport stops before it creates the projectBundle validation checks the manifest, checksum, project data, and declared media files.
A media file cannot be read during exportThe resulting bundle can omit that media and no longer represent the full editExport logs the missing file; callers must treat the reported media count and result as the transfer boundary.
External-folder cleanup removes files before soft-delete failsThe project and its local media can become inconsistentThe delete flow requests permission first and reports a distinct partial-deletion error instead of pretending the action was undone.
A retried headless create finds the same ID with different project parametersThe service could overwrite or misidentify an existing projectDeterministic recovery returns PROJECT_CREATE_CONFLICT and leaves the pending ledger for inspection.
A pending headless create has no caller-supplied IDThe service cannot know whether the original create committedIdempotency returns IDEMPOTENCY_INDETERMINATE and does not run the create again.

Key files

FileWhy to read it
src/…/project-store.tsMain project state contract for load, create, update, duplicate, trash, restore, and permanent delete.
src/…/project-helpers.tsInitial project shape, identity creation, duplication, and project-list naming rules.
src/…/project-form.tsxUser-facing project creation and edit settings.
src/…/project-list.tsxProject discovery, filtering, selection, and import entry point.
src/…/project-card.tsxProject open, duplicate, delete, and root-folder cleanup choices.
src/…/$projectId.tsxBoundary that validates a selected project before editor startup.
src/…/timeline-persistence.tsBoundary between live editor state and the saved project timeline.
src/…/projects.tsDurable project reads and writes and the relationship between project records and the workspace index.
src/…/root.tsActive workspace root and permission-loss signal.
src/…/workspace-gate.tsxWorkspace permission and route access policy.
src/…/bundle-export-service.tsProject and media collection for archive export.
src/…/bundle-import-service.tsArchive validation, extraction, project creation, and media linking.
src/…/bundle-timeline.tsConversion of project media IDs to portable bundle references and back.
src/…/bundle.tsBundle contract and result shapes shared by import and export.
headless/serve.mjsHeadless project API boundary, including deterministic create recovery and resource persistence.
headless/…/idempotency.mjsRetry ledger and rules for replay, conflict, and indeterminate pending requests.
headless/…/lifecycle-store.mjsHeadless durable project records, atomic writes, revisions, and workspace coordination.
headless/project-create-recovery.test.mjsRecovery contract for absent, matching, conflicting, and non-deterministic project creates.