# conghoan9/stockcut architecture

> Architecture diagram of the GitHub repository conghoan9/stockcut, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/conghoan9/stockcut
- Repository: https://github.com/conghoan9/stockcut

## Overview

This repository appears to implement a browser-based video editor backed by a native/WASM timeline, effects, audio, text, and rendering engine, with a separate AI-assisted video and language-model subsystem. The main user workflow is editing a project on the timeline and previewing or exporting its rendered result; the source excerpts show native orchestration and ABI capabilities, but not the complete browser wiring. AI generation and training are distinct capabilities. No README was provided, and several front-end and AI modules were not sampled, so uncertain links are omitted rather than inferred.

Main entry points: [`js/editor.js`](https://github.com/conghoan9/stockcut/blob/main/js/editor.js) (Editor interface), [`native/app/manager.cpp`](https://github.com/conghoan9/stockcut/blob/main/native/app/manager.cpp) (Engine manager), [`native/render/renderer.cpp`](https://github.com/conghoan9/stockcut/blob/main/native/render/renderer.cpp) (Renderer), [`native/app/engine.cpp`](https://github.com/conghoan9/stockcut/blob/main/native/app/engine.cpp) (WASM exports)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_editor["Editor interface"]
  node_editor_ui["Editor interface<br/>[editor.js]"]
  node_project_state["Project state<br/>[project.js]"]
  node_preview["Preview<br/>[preview.js]"]
  node_timeline_ui["Timeline editor<br/>[timeline-engine.js]"]
  node_media_resources["Media resources<br/>[resource-system.js]"]
  node_export["Export<br/>[export.js]"]
  node_wasm_bridge["WASM bridge<br/>[wasm-bridge.js]"]
end

subgraph group_timeline["Project timeline"]
  node_timeline_position["Timeline position<br/>[position.h]"]
  node_timeline_runtime["Timeline runtime<br/>[runtime.h]"]
  node_project_compiler["Project compiler<br/>[compiler.cpp]"]
  node_timeline_geometry["Timeline geometry<br/>[bitboard.h]"]
end

subgraph group_engine["Native engine"]
  node_app_manager["Engine manager<br/>[manager.cpp]"]
  node_wasm_abi["WASM exports<br/>[engine.cpp]"]
  node_render["Renderer<br/>[renderer.cpp]"]
  node_audio["Audio DSP<br/>[dsp.cpp]"]
  node_text_flow["Text layout<br/>[flow.cpp]"]
  node_effects["Effect engine<br/>[engine.cpp]"]
  node_text_engine["Text flow engine<br/>[flow.h]"]
  node_effect_algebra["Effect algebra<br/>[algebra.h]"]
  node_effect_fuse["Effect fusion<br/>[fuse.h]"]
  node_effect_registry["Effect registry<br/>[registry.h]"]
  node_audio_script["Audio scripting<br/>[script.h]"]
end

subgraph group_ai["AI capabilities"]
  node_agent_runtime["Agent runtime<br/>[agent-runtime.js]"]
  node_video_agent["Video agent<br/>[video-agent.js]"]
  node_llm_app["LLM interface<br/>[app.js]"]
end

subgraph group_foundation["Engine foundations"]
  node_core_math["Math utilities<br/>[calc.h]"]
  node_core_data["Data structures<br/>[ds.h]"]
  node_core_hash["Hash primitives<br/>[hash.h]"]
  node_core_mark["Mark tracking<br/>[mark.h]"]
  node_core_memory["Memory utilities<br/>[memory.h]"]
  node_core_parse["Parsing primitives<br/>[parse.h]"]
  node_core_types["Core types<br/>[types.h]"]
  node_geometry["Rectangle geometry<br/>[rect.h]"]
end

node_user(("Editor user"))

node_user -->|"edits project"| node_editor_ui
node_editor_ui -.->|"updates state"| node_project_state
node_editor_ui -.->|"edits timeline"| node_timeline_ui
node_editor_ui -.->|"views preview"| node_preview
node_editor_ui -.->|"manages media"| node_media_resources
node_editor_ui -.->|"requests export"| node_export
node_wasm_bridge -.->|"bridges calls"| node_app_manager
node_app_manager -->|"patches timeline"| node_project_compiler
node_app_manager -.->|"updates position"| node_timeline_position
node_wasm_abi -->|"syncs audio"| node_audio
node_wasm_abi -->|"computes mask"| node_timeline_geometry
node_wasm_abi -->|"sets render scale"| node_render
node_wasm_abi -->|"accesses text buffers"| node_text_engine
node_render -->|"references runtime"| node_timeline_runtime
node_render -->|"references manager"| node_app_manager
node_render -->|"references effects"| node_effect_algebra
node_app_manager -->|"invalidates text cache"| node_render
node_agent_runtime -.->|"coordinates agent"| node_video_agent
node_llm_app -.->|"uses agent"| node_agent_runtime
node_timeline_runtime -.->|"maintains state"| node_timeline_position
node_text_engine -->|"uses parsing"| node_core_parse
node_text_engine -->|"uses math"| node_core_math
node_effect_algebra -->|"uses geometry"| node_geometry
node_effect_algebra -->|"uses bitboard"| node_timeline_geometry
node_effect_registry -->|"declares interface"| node_effect_algebra
node_audio_script -->|"uses types"| node_core_types
node_core_data -->|"uses memory"| node_core_memory
node_core_data -->|"uses marks"| node_core_mark
node_core_types -->|"references memory"| node_core_memory
node_core_types -->|"references marks"| node_core_mark

click node_editor_ui "https://github.com/conghoan9/stockcut/blob/main/js/editor.js"
click node_project_state "https://github.com/conghoan9/stockcut/blob/main/js/project.js"
click node_preview "https://github.com/conghoan9/stockcut/blob/main/js/preview.js"
click node_timeline_ui "https://github.com/conghoan9/stockcut/blob/main/js/timeline-engine.js"
click node_media_resources "https://github.com/conghoan9/stockcut/blob/main/js/resource-system.js"
click node_export "https://github.com/conghoan9/stockcut/blob/main/js/export.js"
click node_wasm_bridge "https://github.com/conghoan9/stockcut/blob/main/js/wasm-bridge.js"
click node_app_manager "https://github.com/conghoan9/stockcut/blob/main/native/app/manager.cpp"
click node_wasm_abi "https://github.com/conghoan9/stockcut/blob/main/native/app/engine.cpp"
click node_render "https://github.com/conghoan9/stockcut/blob/main/native/render/renderer.cpp"
click node_audio "https://github.com/conghoan9/stockcut/blob/main/native/audio/dsp.cpp"
click node_text_flow "https://github.com/conghoan9/stockcut/blob/main/native/text/flow.cpp"
click node_effects "https://github.com/conghoan9/stockcut/blob/main/native/effect/engine.cpp"
click node_timeline_position "https://github.com/conghoan9/stockcut/blob/main/native/timeline/position.h"
click node_timeline_runtime "https://github.com/conghoan9/stockcut/blob/main/native/timeline/runtime/runtime.h"
click node_project_compiler "https://github.com/conghoan9/stockcut/blob/main/native/timeline/project/compiler.cpp"
click node_timeline_geometry "https://github.com/conghoan9/stockcut/blob/main/native/timeline/bitboard.h"
click node_text_engine "https://github.com/conghoan9/stockcut/blob/main/native/text/flow.h"
click node_core_math "https://github.com/conghoan9/stockcut/blob/main/native/core/calc.h"
click node_core_data "https://github.com/conghoan9/stockcut/blob/main/native/core/ds.h"
click node_core_hash "https://github.com/conghoan9/stockcut/blob/main/native/core/hash.h"
click node_core_mark "https://github.com/conghoan9/stockcut/blob/main/native/core/mark.h"
click node_core_memory "https://github.com/conghoan9/stockcut/blob/main/native/core/memory.h"
click node_core_parse "https://github.com/conghoan9/stockcut/blob/main/native/core/parse.h"
click node_core_types "https://github.com/conghoan9/stockcut/blob/main/native/core/types.h"
click node_effect_algebra "https://github.com/conghoan9/stockcut/blob/main/native/effect/algebra.h"
click node_effect_fuse "https://github.com/conghoan9/stockcut/blob/main/native/effect/fuse.h"
click node_effect_registry "https://github.com/conghoan9/stockcut/blob/main/native/effect/registry.h"
click node_geometry "https://github.com/conghoan9/stockcut/blob/main/native/geom/rect.h"
click node_audio_script "https://github.com/conghoan9/stockcut/blob/main/native/audio/script.h"
click node_agent_runtime "https://github.com/conghoan9/stockcut/blob/main/LLM/agent/agent-runtime.js"
click node_video_agent "https://github.com/conghoan9/stockcut/blob/main/LLM/agent/video-agent.js"
click node_llm_app "https://github.com/conghoan9/stockcut/blob/main/LLM/js/app.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_editor_ui,node_project_state,node_preview,node_timeline_ui,node_media_resources,node_export,node_wasm_bridge,node_user toneBlue
class node_timeline_position,node_timeline_runtime,node_project_compiler,node_timeline_geometry toneAmber
class node_app_manager,node_wasm_abi,node_render,node_audio,node_text_flow,node_effects,node_text_engine,node_effect_algebra,node_effect_fuse,node_effect_registry,node_audio_script toneMint
class node_agent_runtime,node_video_agent,node_llm_app toneRose
class node_core_math,node_core_data,node_core_hash,node_core_mark,node_core_memory,node_core_parse,node_core_types,node_geometry toneIndigo
```

## Components

### Editor interface

- [Editor interface](https://github.com/conghoan9/stockcut/blob/main/js/editor.js): `js/editor.js`
- [Project state](https://github.com/conghoan9/stockcut/blob/main/js/project.js): `js/project.js`
- [Preview](https://github.com/conghoan9/stockcut/blob/main/js/preview.js): `js/preview.js`
- [Timeline editor](https://github.com/conghoan9/stockcut/blob/main/js/timeline-engine.js): `js/timeline-engine.js`
- [Media resources](https://github.com/conghoan9/stockcut/blob/main/js/resource-system.js): `js/resource-system.js`
- [Export](https://github.com/conghoan9/stockcut/blob/main/js/export.js): `js/export.js`
- [WASM bridge](https://github.com/conghoan9/stockcut/blob/main/js/wasm-bridge.js): `js/wasm-bridge.js`

### Project timeline

- [Timeline position](https://github.com/conghoan9/stockcut/blob/main/native/timeline/position.h): `native/timeline/position.h`
- [Timeline runtime](https://github.com/conghoan9/stockcut/blob/main/native/timeline/runtime/runtime.h): `native/timeline/runtime/runtime.h`
- [Project compiler](https://github.com/conghoan9/stockcut/blob/main/native/timeline/project/compiler.cpp): `native/timeline/project/compiler.cpp`
- [Timeline geometry](https://github.com/conghoan9/stockcut/blob/main/native/timeline/bitboard.h): `native/timeline/bitboard.h`

### Native engine

- [Engine manager](https://github.com/conghoan9/stockcut/blob/main/native/app/manager.cpp): `native/app/manager.cpp`
- [WASM exports](https://github.com/conghoan9/stockcut/blob/main/native/app/engine.cpp): `native/app/engine.cpp`
- [Renderer](https://github.com/conghoan9/stockcut/blob/main/native/render/renderer.cpp): `native/render/renderer.cpp`
- [Audio DSP](https://github.com/conghoan9/stockcut/blob/main/native/audio/dsp.cpp): `native/audio/dsp.cpp`
- [Text layout](https://github.com/conghoan9/stockcut/blob/main/native/text/flow.cpp): `native/text/flow.cpp`
- [Effect engine](https://github.com/conghoan9/stockcut/blob/main/native/effect/engine.cpp): `native/effect/engine.cpp`
- [Text flow engine](https://github.com/conghoan9/stockcut/blob/main/native/text/flow.h): `native/text/flow.h`
- [Effect algebra](https://github.com/conghoan9/stockcut/blob/main/native/effect/algebra.h): `native/effect/algebra.h`
- [Effect fusion](https://github.com/conghoan9/stockcut/blob/main/native/effect/fuse.h): `native/effect/fuse.h`
- [Effect registry](https://github.com/conghoan9/stockcut/blob/main/native/effect/registry.h): `native/effect/registry.h`
- [Audio scripting](https://github.com/conghoan9/stockcut/blob/main/native/audio/script.h): `native/audio/script.h`

### AI capabilities

- [Agent runtime](https://github.com/conghoan9/stockcut/blob/main/LLM/agent/agent-runtime.js): `LLM/agent/agent-runtime.js`
- [Video agent](https://github.com/conghoan9/stockcut/blob/main/LLM/agent/video-agent.js): `LLM/agent/video-agent.js`
- [LLM interface](https://github.com/conghoan9/stockcut/blob/main/LLM/js/app.js): `LLM/js/app.js`

### Engine foundations

- [Math utilities](https://github.com/conghoan9/stockcut/blob/main/native/core/calc.h): `native/core/calc.h`
- [Data structures](https://github.com/conghoan9/stockcut/blob/main/native/core/ds.h): `native/core/ds.h`
- [Hash primitives](https://github.com/conghoan9/stockcut/blob/main/native/core/hash.h): `native/core/hash.h`
- [Mark tracking](https://github.com/conghoan9/stockcut/blob/main/native/core/mark.h): `native/core/mark.h`
- [Memory utilities](https://github.com/conghoan9/stockcut/blob/main/native/core/memory.h): `native/core/memory.h`
- [Parsing primitives](https://github.com/conghoan9/stockcut/blob/main/native/core/parse.h): `native/core/parse.h`
- [Core types](https://github.com/conghoan9/stockcut/blob/main/native/core/types.h): `native/core/types.h`
- [Rectangle geometry](https://github.com/conghoan9/stockcut/blob/main/native/geom/rect.h): `native/geom/rect.h`

### Other components

- **Editor user**

## Connections

- Editor user → Editor interface: edits project
- Editor interface → Project state: updates state
- Editor interface → Timeline editor: edits timeline
- Editor interface → Preview: views preview
- Editor interface → Media resources: manages media
- Editor interface → Export: requests export
- WASM bridge → Engine manager: bridges calls
- Engine manager → Project compiler: patches timeline (evidence: `native/app/manager.cpp`)
- Engine manager → Timeline position: updates position (evidence: `native/app/manager.cpp`)
- WASM exports → Audio DSP: syncs audio (evidence: `native/app/engine.cpp`)
- WASM exports → Timeline geometry: computes mask (evidence: `native/app/engine.cpp`)
- WASM exports → Renderer: sets render scale (evidence: `native/app/engine.cpp`)
- WASM exports → Text flow engine: accesses text buffers (evidence: `native/app/engine.cpp`)
- Renderer → Timeline runtime: references runtime (evidence: `native/render/renderer.cpp`)
- Renderer → Engine manager: references manager (evidence: `native/render/renderer.cpp`)
- Renderer → Effect algebra: references effects (evidence: `native/render/renderer.cpp`)
- Engine manager → Renderer: invalidates text cache (evidence: `native/app/manager.cpp`)
- Agent runtime → Video agent: coordinates agent
- LLM interface → Agent runtime: uses agent
- Timeline runtime → Timeline position: maintains state
- Text flow engine → Parsing primitives: uses parsing (evidence: `native/text/flow.cpp`)
- Text flow engine → Math utilities: uses math (evidence: `native/text/flow.cpp`)
- Effect algebra → Rectangle geometry: uses geometry (evidence: `native/effect/algebra.h`)
- Effect algebra → Timeline geometry: uses bitboard (evidence: `native/effect/algebra.h`)
- Effect registry → Effect algebra: declares interface (evidence: `native/effect/algebra.h`)
- Audio scripting → Core types: uses types (evidence: `native/audio/script.h`)
- Data structures → Memory utilities: uses memory (evidence: `native/core/ds.h`)
- Data structures → Mark tracking: uses marks (evidence: `native/core/ds.h`)
- Core types → Memory utilities: references memory (evidence: `native/core/types.h`)
- Core types → Mark tracking: references marks (evidence: `native/core/types.h`)
