# codevideo/codevideo-cli architecture

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

- Interactive diagram: https://gitdiagram.com/codevideo/codevideo-cli
- Repository: https://github.com/codevideo/codevideo-cli

## Overview

##### Project type and purpose
- This is an open-source CLI tool (“codevideo-cli”) written in Go, with a small Node.js helper (“puppeteer-runner”).
- Its purpose is to generate “CodeVideos” by driving a headless browser (via Puppeteer) against an embedded static web UI, capturing frames, stitching them into a video, and optionally uploading or emailing results.

##### File structure
- Top-level:
– Dockerfile, .github/workflows (CI/CD), go.mod/go.sum
– main.go: entrypoint that parses flags (mode, project data, serve, etc.)
– cli/: the core subpackages for the interactive command:
- config/: load .env and CLI flags
- detector/: detect input type (actions, lesson, course, Git repo)
- generator/: orchestrate video generation steps
- renderer/: assemble images/frames into MP4
- staticserver/: embed and serve the Gatsby-produced static UI
– puppeteer-runner/: Node.js script that Puppeteer uses to visit pages and record frames
– server/: HTTP server mode (–mode=serve) that exposes REST endpoints for generating videos
– cloud/, mail/, files/: modules for optional upload, email, file management
– elevenlabs/: wrapper for ElevenLabs TTS API
– utils/: helper conversions, hashing, port discovery, resource usage
– data/: sample JSON for actions, lessons, courses
– types/, constants/: shared data types and constants

##### README for additional insights
- Describes installation (brew, binaries, build-from-source)
- CLI usage patterns: local generation, server mode, Docker
- Explains how to swap out the static “public” folder for custom UI
- Mentions external dependency: ElevenLabs API key

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User interactions
    subgraph "CLI Mode" 
        direction TB
        CLI["CLI Frontend<br/>(main.go)"]:::cli
        CLIEntry["CLI Entrypoint<br/>(cli/cli.go)"]:::cli
        Config["Config Loader<br/>(config.go)"]:::pkg
        Detector["Detector<br/>(detector.go)"]:::pkg
        Generator["Generator<br/>(generator.go)"]:::pkg
        subgraph "Static Server & UI" 
            direction TB
            StaticServer["Static Server<br/>(staticserver.go)"]:::ui
            Public["Embedded UI<br/>(public/)"]:::ui
        end
        Puppeteer["Puppeteer Runner<br/>(recordVideoV3.js)"]:::ui
        Renderer["Renderer<br/>(renderer.go)"]:::post
        TempFS["Temp Frames<br/>(filesystem)"]:::external
        OutputFS["Output FS"]:::external
        Mail["Mail Service<br/>(mail.go)"]:::post
        Cloud["Cloud Upload<br/>(cloud.go)"]:::post
        ElevenLabs["ElevenLabs TTS<br/>(elevenlabs.go)"]:::external
        Files["File Management<br/>(files.go)"]:::pkg
        Types["Shared Types<br/>(types.go)"]:::pkg
        Consts["Shared Consts<br/>(constants.go)"]:::pkg
        Utils["Utils<br/>(utils/)"]:::pkg
        Data["Sample Data<br/>(data/)"]:::external

        CLI --> CLIEntry
        CLIEntry --> Config
        Config --> Detector
        Detector --> Generator
        Generator --> StaticServer
        StaticServer --> Public
        Generator -->|"spawns"| Puppeteer
        Puppeteer -->|"writes frames"| TempFS
        TempFS --> Renderer
        Renderer --> OutputFS
        OutputFS --> Mail
        OutputFS --> Cloud
        Generator --> ElevenLabs
        Generator --> Files
        Generator --> Types
        Generator --> Consts
        Generator --> Utils
        Detector --> Data
    end

    subgraph "Server Mode" 
        direction TB
        HTTPClient["HTTP Client"]:::cli
        ServerAPI["Server API<br/>(server.go)"]:::server
        HTTPClient --> ServerAPI
        ServerAPI --> Config
        ServerAPI --> Detector
        ServerAPI --> Generator
    end

    %% Click events
    click CLI "https://github.com/codevideo/codevideo-cli/blob/main/main.go"
    click CLIEntry "https://github.com/codevideo/codevideo-cli/blob/main/cli/cli.go"
    click Config "https://github.com/codevideo/codevideo-cli/blob/main/cli/config/config.go"
    click Detector "https://github.com/codevideo/codevideo-cli/blob/main/cli/detector/detector.go"
    click Generator "https://github.com/codevideo/codevideo-cli/blob/main/cli/generator/generator.go"
    click StaticServer "https://github.com/codevideo/codevideo-cli/blob/main/cli/staticserver/staticserver.go"
    click Public "https://github.com/codevideo/codevideo-cli/tree/main/cli/staticserver/public/"
    click Puppeteer "https://github.com/codevideo/codevideo-cli/blob/main/puppeteer-runner/recordVideoV3.js"
    click Renderer "https://github.com/codevideo/codevideo-cli/blob/main/cli/renderer/renderer.go"
    click ServerAPI "https://github.com/codevideo/codevideo-cli/blob/main/server/server.go"
    click ElevenLabs "https://github.com/codevideo/codevideo-cli/blob/main/elevenlabs/elevenlabs.go"
    click Mail "https://github.com/codevideo/codevideo-cli/blob/main/mail/mail.go"
    click Cloud "https://github.com/codevideo/codevideo-cli/blob/main/cloud/cloud.go"
    click Files "https://github.com/codevideo/codevideo-cli/blob/main/files/files.go"
    click Types "https://github.com/codevideo/codevideo-cli/blob/main/types/types.go"
    click Consts "https://github.com/codevideo/codevideo-cli/blob/main/constants/constants.go"
    click Utils "https://github.com/codevideo/codevideo-cli/tree/main/utils/"
    click Data "https://github.com/codevideo/codevideo-cli/tree/main/data/"

    %% Styles
    classDef cli fill:#BBDEFB,stroke:#1E88E5,color:#0D47A1
    classDef server fill:#B3E5FC,stroke:#0288D1,color:#01579B
    classDef ui fill:#C8E6C9,stroke:#43A047,color:#1B5E20
    classDef post fill:#FFE0B2,stroke:#FB8C00,color:#E65100
    classDef pkg fill:#E1BEE7,stroke:#8E24AA,color:#4A148C
    classDef external fill:#F5F5F5,stroke:#9E9E9E,color:#424242,stroke-dasharray: 5 5
```
