# jbilcke-hf/clapper architecture

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

- Interactive diagram: https://gitdiagram.com/jbilcke-hf/clapper
- Repository: https://github.com/jbilcke-hf/clapper

## Overview

##### High-Level Architecture Overview
The system can be broken down into these main components:

a. Frontend Layer:
- Next.js web application (packages/app)
- Electron desktop application wrapper
- React-based UI components
- Timeline visualization system (packages/timeline)

b. Core Services Layer:
- Editor Services (project, script, workflow, entity, filter editors)
- Renderer Service
- I/O Service
- Assistant Service
- Audio/Video Processing Services
- Broadcast Service

c. Integration Layer:
- AI Provider Integrations (OpenAI, HuggingFace, etc.)
- File System Operations
- Media Processing

##### Key Components to Highlight

a. Services Architecture:
**Core Services**
- Editor Services
- Project Editor
- Script Editor
- Workflow Editor
- Entity Editor
- Filter Editor
- Renderer Service
- I/O Service
- Assistant Service
- Audio Service
- Broadcast Service

b. Workflow System:
**Workflow System**
- Providers
- ComfyUI
- Stability AI
- Replicate
- Other AI Services
- Workflow Editor
- Workflow Execution Engine

##### Data Flow Representation

Flow of data through:
- User Input → Editor Services
- Editor Services → Workflow Engine
- Workflow Engine → AI Providers
- AI Providers → Renderer
- Renderer → Timeline Display

##### Integration Points

Connections with:
- AI Service Providers
- File System
- Media Processing Tools
- External APIs

##### Key Design Elements

Use these visual elements:
- Clear boundaries between layers
- Interface points between components

##### Implementation Details

- Service communication patterns
- State management flow
- File processing pipeline
- Real-time update mechanisms

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        NextApp["Next.js App"]
        ElectronApp["Electron App"]
        UIComponents["UI Components"]
        Timeline["Timeline System"]
        Monitor["Monitor/Player"]
        Toolbars["Toolbars"]
        Forms["Forms"]
        Dialogs["Dialogs"]
    end

    subgraph CoreServices
        subgraph EditorServices
            ProjectEd["Project Editor"]
            ScriptEd["Script Editor"]
            WorkflowEd["Workflow Editor"]
            EntityEd["Entity Editor"]
            FilterEd["Filter Editor"]
        end
        
        RendererSvc["Renderer Service"]
        IOSvc["I/O Service"]
        AssistantSvc["Assistant Service"]
        AudioSvc["Audio Service"]
        BroadcastSvc["Broadcast Service"]
        CoreEngine["Core Engine"]
        DataModels["Data Models"]
        ScriptAnalysis["Script Analysis"]
    end

    subgraph Integration
        subgraph AIProviders
            ComfyUI["ComfyUI"]
            StabilityAI["Stability AI"]
            Replicate["Replicate"]
            OtherAI["Other AI Services"]
        end
        FileSystem["File System Operations"]
        MediaProc["Media Processing"]
    end

    %% Frontend connections
    NextApp --> UIComponents
    ElectronApp --> NextApp
    UIComponents --> Timeline
    UIComponents --> Monitor
    UIComponents --> Toolbars
    UIComponents --> Forms
    UIComponents --> Dialogs

    %% Core Services connections
    EditorServices --> CoreEngine
    CoreEngine --> DataModels
    CoreEngine --> ScriptAnalysis
    RendererSvc --> Timeline
    IOSvc --> FileSystem
    AssistantSvc --> AIProviders
    AudioSvc --> MediaProc
    BroadcastSvc --> MediaProc

    %% Integration connections
    AIProviders --> RendererSvc
    FileSystem --> IOSvc
    MediaProc --> RendererSvc

    %% Click events
    click NextApp "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/app"
    click ElectronApp "https://github.com/jbilcke-hf/clapper/blob/main/packages/app/main.js"
    click UIComponents "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/components"
    click Timeline "https://github.com/jbilcke-hf/clapper/tree/main/packages/timeline/src"
    click Monitor "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/components/monitor"
    click Toolbars "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/components/toolbars"
    click Forms "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/components/forms"
    click Dialogs "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/components/dialogs"
    click ProjectEd "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/components/editors/ProjectEditor"
    click ScriptEd "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/components/editors/ScriptEditor"
    click WorkflowEd "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/components/editors/WorkflowEditor"
    click EntityEd "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/components/editors/EntityEditor"
    click FilterEd "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/components/editors/FilterEditor"
    click RendererSvc "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/services/renderer"
    click IOSvc "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/services/io"
    click AssistantSvc "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/services/assistant"
    click AudioSvc "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/services/audio"
    click BroadcastSvc "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/services/broadcast"
    click CoreEngine "https://github.com/jbilcke-hf/clapper/tree/main/packages/engine/src"
    click DataModels "https://github.com/jbilcke-hf/clapper/tree/main/packages/clap/src"
    click ScriptAnalysis "https://github.com/jbilcke-hf/clapper/tree/main/packages/broadway/src"
    click AIProviders "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/app/api/resolve/providers"
    click FileSystem "https://github.com/jbilcke-hf/clapper/tree/main/packages/io/src"
    click MediaProc "https://github.com/jbilcke-hf/clapper/tree/main/packages/app/src/services/io"

    %% Styling
    classDef frontend fill:#a8d1ff,stroke:#333
    classDef core fill:#90EE90,stroke:#333
    classDef integration fill:#FFB347,stroke:#333
    classDef ai fill:#DDA0DD,stroke:#333

    class NextApp,ElectronApp,UIComponents,Timeline,Monitor,Toolbars,Forms,Dialogs frontend
    class ProjectEd,ScriptEd,WorkflowEd,EntityEd,FilterEd,RendererSvc,IOSvc,AssistantSvc,AudioSvc,BroadcastSvc,CoreEngine,DataModels,ScriptAnalysis core
    class FileSystem,MediaProc integration
    class ComfyUI,StabilityAI,Replicate,OtherAI ai
```
