# bwasti/mebm architecture

> Architecture diagram of the GitHub repository bwasti/mebm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bwasti/mebm
- Repository: https://github.com/bwasti/mebm

## Overview

##### Project type and purpose
- mebm is a browser‐based, single‐page video editor built entirely in HTML, CSS, and JavaScript.
- Its purpose is to let users import media, create simple keyframe animations of images and text, and export a WebM video via linear interpolation between keyframes.

##### File structure
- Top level:
- index.html (entry-point)
- reset.css, style.css (global and application styling)
- script.js (all of the application logic)
- README_assets (example JSON, demo video)
- No backend or server components—everything lives client-side
- No build scripts or transpilers; direct use of browser APIs

##### README for additional insights
- Core features: import via drag-drop or URL, play/pause controls, layer selection, zoom, move, keyframe add/remove, export to WebM
- Under the hood: keyframe timeline (blue markers), linear interpolation, WebM encoding by “playing to end” and grabbing the stream

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "User Interface" 
        direction TB
        UI_HTML["User Interface\n(index.html)"]:::ui
        CSS_RESET["reset.css"]:::ui
        CSS_STYLE["style.css"]:::ui
    end

    %% Core Logic Modules
    subgraph "Core Logic (script.js)" 
        direction TB
        Controller["Event Controller"]:::core
        Model["Application Model / State"]:::core
        Timeline["Timeline & Layer Components"]:::core
        KeyframeManager["Keyframe Manager & Interpolation Engine"]:::core
        Renderer["Canvas Renderer"]:::core
        Importer["Media Importer"]:::core
        Exporter["Exporter / Encoder"]:::core
    end

    %% Browser APIs
    subgraph "Browser APIs"
        direction TB
        FileReaderAPI["FileReader API"]:::api
        CanvasAPI["Canvas API"]:::api
        MediaRecorderAPI["MediaRecorder API"]:::api
    end

    %% Interactions
    User["User"]:::external
    User -->|"interacts with"| UI_HTML
    UI_HTML -->|"triggers events"| Controller
    CSS_RESET --> Controller
    CSS_STYLE --> Controller

    Controller -->|"updates"| Model
    Controller -->|"initiate import"| Importer
    Importer -->|"reads media"| FileReaderAPI
    FileReaderAPI -->|"raw media"| Model

    Controller -->|"render frame"| Renderer
    Controller -->|"play timeline"| Exporter

    Model -->|"layer/keyframe data"| Timeline
    Timeline -->|"UI feedback"| Controller

    Model -->|"data for interpolation"| KeyframeManager
    KeyframeManager -->|"frame data"| Renderer

    Renderer -->|"draw frame"| CanvasAPI
    CanvasAPI -->|"renders on DOM"| UI_HTML

    Exporter -->|"capture frames"| CanvasAPI
    Exporter -->|"encode WebM"| MediaRecorderAPI
    MediaRecorderAPI -->|"download video"| User

    %% Click Events
    click UI_HTML "https://github.com/bwasti/mebm/blob/main/index.html"
    click CSS_RESET "https://github.com/bwasti/mebm/blob/main/reset.css"
    click CSS_STYLE "https://github.com/bwasti/mebm/blob/main/style.css"
    click Controller "https://github.com/bwasti/mebm/blob/main/script.js"
    click Model "https://github.com/bwasti/mebm/blob/main/script.js"
    click Timeline "https://github.com/bwasti/mebm/blob/main/script.js"
    click KeyframeManager "https://github.com/bwasti/mebm/blob/main/script.js"
    click Renderer "https://github.com/bwasti/mebm/blob/main/script.js"
    click Importer "https://github.com/bwasti/mebm/blob/main/script.js"
    click Exporter "https://github.com/bwasti/mebm/blob/main/script.js"
    click FileReaderAPI "https://github.com/bwasti/mebm/blob/main/script.js"
    click CanvasAPI "https://github.com/bwasti/mebm/blob/main/script.js"
    click MediaRecorderAPI "https://github.com/bwasti/mebm/blob/main/script.js"
    click ExampleJSON "https://github.com/bwasti/mebm/blob/main/README_assets/example.json"
    click UsageVideo "https://github.com/bwasti/mebm/blob/main/README_assets/usage.mp4"

    %% Styles
    classDef ui fill:#add8e6,stroke:#000,stroke-width:1px
    classDef core fill:#90ee90,stroke:#000,stroke-width:1px
    classDef api fill:#dda0dd,stroke:#000,stroke-width:1px
    classDef external fill:#ffa500,stroke:#000,stroke-width:1px
```
