# xzdarcy/react-timeline-editor architecture

> Architecture diagram of the GitHub repository xzdarcy/react-timeline-editor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/xzdarcy/react-timeline-editor
- Repository: https://github.com/xzdarcy/react-timeline-editor

## Overview

##### Main Components Layer
- Following key sub-components (found in src/components):
- ControlArea
- EditArea (with DragLines, EditAction, EditRow)
- TimeArea
- Cursor
- RowRND (Resizable and Draggable Row component)

##### Core Engine Layer
- Engine system (from src/engine)
- Following engine components:
- Emitter (Event handling system)
- Engine (Core timeline logic)
- Events (Event definitions)

##### Data Flow Layer
- Data flow between components using the following interfaces (from src/interface):
- TimelineRow
- TimelineEffect
- Action
- Effect

##### Feature Integration Layer
- Integration points for:
- Audio Control
- Lottie Animations
- Custom Effects
- Grid Snap System
- Auxiliary Line System

##### Component Relationships
- Bi-directional data flow between Engine and UI components
- Event propagation paths
- Demonstrate how effects and actions are connected to the timeline

##### Specific Elements
- Timeline Component (Main container)
- Edit Area with drag-and-drop functionality
- Time Area with scale representation
- Control Area for timeline manipulation
- Engine core with event system
- Data model structure (TimelineRow, Actions, Effects)

##### Technical Details
- React Component hierarchy
- Event emission system
- Hook integration points (useAutoScroll, useDragLine)
- External dependency integration (audio, lottie)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Main
        Timeline["Timeline Component"]
        click Timeline "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/components/timeline.tsx"
    end

    subgraph UI_Components
        ControlArea["Control Area"]
        click ControlArea "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/components/control_area/index.tsx"
        
        EditArea["Edit Area"]
        click EditArea "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/components/edit_area/edit_area.tsx"
        
        TimeArea["Time Area"]
        click TimeArea "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/components/time_area/time_area.tsx"
        
        Cursor["Cursor"]
        click Cursor "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/components/cursor/cursor.tsx"
        
        RowRND["Row RND"]
        click RowRND "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/components/row_rnd/row_rnd.tsx"
        
        DragLines["Drag Lines"]
        click DragLines "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/components/edit_area/drag_lines.tsx"
        
        EditAction["Edit Action"]
        click EditAction "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/components/edit_area/edit_action.tsx"
        
        EditRow["Edit Row"]
        click EditRow "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/components/edit_area/edit_row.tsx"
    end

    subgraph Engine_Layer
        Engine[("Engine Core")]
        click Engine "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/engine/engine.ts"
        
        Emitter[("Event Emitter")]
        click Emitter "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/engine/emitter.ts"
        
        Events[("Events System")]
        click Events "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/engine/events.ts"
    end

    subgraph Data_Interfaces
        ActionInterface["Action Interface"]
        click ActionInterface "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/interface/action.ts"
        
        EffectInterface["Effect Interface"]
        click EffectInterface "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/interface/effect.ts"
        
        TimelineInterface["Timeline Interface"]
        click TimelineInterface "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/interface/timeline.ts"
    end

    subgraph Feature_Integration
        AudioControl["Audio Control"]
        click AudioControl "https://github.com/xzdarcy/react-timeline-editor/blob/master/docs/engine/engine-basic/audioControl.ts"
        
        LottieControl["Lottie Control"]
        click LottieControl "https://github.com/xzdarcy/react-timeline-editor/blob/master/docs/engine/engine-basic/lottieControl.ts"
        
        GridSnap["Grid Snap System"]
        AuxiliaryLine["Auxiliary Line System"]
    end

    subgraph Hooks
        DragLineHook["Drag Line Hook"]
        click DragLineHook "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/components/edit_area/hooks/use_drag_line.ts"
        
        AutoScrollHook["Auto Scroll Hook"]
        click AutoScrollHook "https://github.com/xzdarcy/react-timeline-editor/blob/master/src/components/row_rnd/hooks/useAutoScroll.ts"
    end

    %% Relationships
    Timeline --> ControlArea
    Timeline --> EditArea
    Timeline --> TimeArea
    Timeline --> Cursor
    Timeline --> RowRND

    EditArea --> DragLines
    EditArea --> EditAction
    EditArea --> EditRow

    Engine --> Emitter
    Engine --> Events

    Timeline --> Engine
    Engine --> ActionInterface
    Engine --> EffectInterface
    Engine --> TimelineInterface

    Engine --> AudioControl
    Engine --> LottieControl
    Engine --> GridSnap
    Engine --> AuxiliaryLine

    EditArea --> DragLineHook
    RowRND --> AutoScrollHook

    %% Styling
    classDef component fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef engine fill:#90EE90,stroke:#333,stroke-width:2px
    classDef interface fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef integration fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef hook fill:#F08080,stroke:#333,stroke-width:2px

    class Timeline,ControlArea,EditArea,TimeArea,Cursor,RowRND,DragLines,EditAction,EditRow component
    class Engine,Emitter,Events engine
    class ActionInterface,EffectInterface,TimelineInterface interface
    class AudioControl,LottieControl,GridSnap,AuxiliaryLine integration
    class DragLineHook,AutoScrollHook hook
```
