How akhil373/freecut works
Purpose and Entry Points
FreeCut is a local-first, browser-based multitrack video editor. The React application boots through src/main.tsx, initializes app concerns in src/bootstrap.ts, and renders the routed shell from src/app.tsx. TanStack Router routes users through workspace selection, projects, editor, docs, and changelog; the primary editing route is src/routes/editor/$projectId.tsx with lazy editor loading in src/routes/editor/$projectId.lazy.tsx.
A separate Node/headless automation surface exists under headless/, centered on headless/server.mjs and headless/agent.mjs; browser-facing headless support is in src/headless/main.ts.
Workspace, Projects, and Persistence
The chosen local workspace folder is the system of record. Storage is implemented as plain workspace files behind File System Access API/OPFS adapters, not a remote backend. src/infrastructure/storage/workspace-fs/bootstrap.ts establishes workspace storage; src/infrastructure/storage/workspace-fs/projects.ts manages project files; src/infrastructure/storage/workspace-fs/media.ts manages local media records.
Project UI/state sits in src/features/projects/stores/project-store.ts; schema/version migration is isolated in src/shared/projects/migrations/migrations.ts. Project bundles cross an explicit import/export boundary via src/features/project-bundle/schemas/project-schema.ts and bundle services.
Editorial Data Model and Timeline
The timeline is the authoritative editable composition model: sequences, tracks, items, transitions, markers, keyframes, and media dependencies. Core stores include src/features/timeline/stores/timeline-store.ts, src/features/timeline/stores/items-store.ts, and src/features/timeline/stores/sequences-store.ts. Mutation logic is separated into action modules such as src/features/timeline/stores/actions/item-actions.ts and src/features/timeline/stores/actions/edit/trim-actions.ts, supporting undoable editing workflows.
src/features/timeline/components/timeline.tsx presents this model. Media drops and editing gestures flow from UI/hooks into timeline actions, updating persistent project state; preview and export consume snapshots rather than owning editorial state.
Playback, Composition Runtime, and Preview
The runtime translates a timeline/composition frame into positioned media, text, shapes, masks, effects, transitions, and audio. src/runtime/player/Player.tsx and src/runtime/player/clock/Clock.ts provide frame-accurate playback coordination. src/runtime/composition-runtime/components/composition-content.tsx assembles item rendering, while src/runtime/composition-runtime/utils/scene-assembly.ts builds frame scene state.
The preview feature hosts this runtime and editing overlays: src/features/preview/components/preview-stage.tsx, src/features/preview/hooks/use-preview-renderer-controller.ts, and src/features/preview/stores/playback-store.ts. Interactive gizmos commit transforms back through timeline state, maintaining a boundary between transient preview interaction and persisted edits.
Media Ingestion and Background Processing
The media library imports and links local files, then coordinates metadata extraction, thumbnails, waveforms, proxies, subtitle scanning, transcription, interpolation, and upscale jobs. Its central service is src/features/media-library/services/media-library-service.ts; background task orchestration is src/features/media-library/services/background-media-work.ts; worker-backed processing includes src/features/media-library/workers/media-processor.worker.ts.
Media resolution/storage bridges browser file handles and OPFS caches through src/infrastructure/browser/opfs-file-access.ts and workspace media storage. This layer feeds timeline placement, preview decoders, and export sources.
GPU, Local AI, and Animation
Platform-intensive capabilities are infrastructure rather than feature-owned logic. WebGPU compositing is centered on src/infrastructure/gpu-compositor/compositor-pipeline.ts; GPU effects and transitions are registered through src/infrastructure/gpu-effects/registry.ts and src/infrastructure/gpu-transitions/registry.ts.
Keyframes evaluate through feature utilities such as src/features/keyframes/utils/interpolation.ts and are edited in src/features/keyframes/components/dopesheet-editor/index.tsx. Local analysis/ML runs in workers: scene detection at src/infrastructure/analysis/scene-detection.ts, embeddings at src/infrastructure/analysis/embeddings/embeddings-worker.ts, and transcription workers under src/features/media-library/transcription/workers/.
Export and Render Queue
Export converts a timeline snapshot into a render job, selects viable browser render paths, composites frames, encodes/remuxes media, and writes output locally. Job construction begins in src/features/export/utils/build-render-job.ts; the client render engine is src/features/export/utils/client-render-engine.ts; heavy work moves to src/features/export/workers/export-render.worker.ts.
src/features/export/components/render-queue-runner.tsx executes persisted queue entries. Export depends on WebCodecs, GPU/Canvas paths, browser codec availability, and local workspace output; it has no server-side rendering service.
Architectural Boundaries and Runtime Requirements
Feature modules communicate across feature boundaries through local deps/* contract adapters—for example src/features/export/deps/timeline-contract.ts and src/features/preview/deps/player-contract.ts—rather than broad direct imports. Shared types in src/types/ and framework-neutral primitives in src/shared/ support those contracts.
The production runtime is a modern Chromium browser requiring WebGPU, WebCodecs, Web Workers, AudioWorklets, OPFS, and File System Access API. External network services are optional/content-oriented (for example src/features/lottie-browser/services/lottiefiles-api.ts); editing, storage, AI inference, preview, and export are designed to remain on-device.
Main entry points: project-store.ts Project state · timeline-store.ts Timeline composition · item-actions.ts Timeline actions · media-library-service.ts Media library
Components 23
Application
- Browser entry
src/main.tsx - App initialization
src/bootstrap.ts - Routed app shell
src/app.tsx - Editor route
src/routes/editor/$projectId.lazy.tsx - Headless automation · Separate Node/headless control surface.
headless/server.mjs
Editorial state
- Project state
src/features/projects/stores/project-store.ts - Project bundle boundary
src/features/project-bundle/schemas/project-schema.ts - Timeline composition · Sequences, tracks, items, transitions, markers, and keyframes.
src/features/timeline/stores/timeline-store.ts - Timeline actions
src/features/timeline/stores/actions/item-actions.ts - Timeline editor
src/features/timeline/components/timeline.tsx
Media pipeline
- Media library
src/features/media-library/services/media-library-service.ts - Background media work · Coordinates metadata, proxies, thumbnails, waveforms, and AI jobs.
src/features/media-library/services/background-media-work.ts - Media processor
src/features/media-library/workers/media-processor.worker.ts
Preview and rendering
- Preview stage · Hosts runtime and transient editing overlays.
src/features/preview/components/preview-stage.tsx - Frame player
src/runtime/player/Player.tsx - Composition runtime
src/runtime/composition-runtime/components/composition-content.tsx - Render queue
src/features/export/components/render-queue-runner.tsx - Render job builder
src/features/export/utils/build-render-job.ts - Export renderer · Composites, encodes, and writes output locally.
src/features/export/workers/export-render.worker.ts
Local platform
- Workspace storage · Local workspace is the system of record.
src/infrastructure/storage/workspace-fs/bootstrap.ts - Project files
src/infrastructure/storage/workspace-fs/projects.ts - OPFS media access
src/infrastructure/browser/opfs-file-access.ts - GPU compositor
src/infrastructure/gpu-compositor/compositor-pipeline.ts
Connections 26
- Browser entry → App initialization: initializes
- App initialization → Routed app shell: starts
- Routed app shell → Editor route: routes to
- Editor route → Project state: opens project
- Workspace storage → Project files: establishes
- Project files → Project state: persists
- Project state → Project bundle boundary: imports / exports
- Project state → Timeline composition: owns composition
- Timeline editor → Timeline actions: editing gestures
- Timeline actions → Timeline composition: mutates
- Media library → Background media work: schedules processing
- Background media work → Media processor: dispatches
- Media library → OPFS media access: resolves local media
- OPFS media access → Workspace storage: bridges files and cache
- Media library → Timeline actions: places media
- Timeline composition → Preview stage: composition snapshot
- Preview stage → Frame player: coordinates playback
- Frame player → Composition runtime: renders frames
- Composition runtime → GPU compositor: composites with
- Timeline actions → Preview stage: committed edits
- Timeline composition → Render job builder: snapshot
- Render job builder → Render queue: enqueues
- Render queue → Export renderer: executes
- Export renderer → GPU compositor: composites frames
- Export renderer → Workspace storage: writes output
- Headless automation → Routed app shell: browser-facing control