# wulkano/kap architecture

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

- Interactive diagram: https://gitdiagram.com/wulkano/kap
- Repository: https://github.com/wulkano/kap

## Overview

##### Main Components

a. Frontend Layer (Renderer)
- Next.js-based UI components
- Main windows: Cropper, Editor, Preferences, Exports
- Components directory structure

b. Backend Layer (Main Process)
- Electron main process components
- Screen recording engine (Aperture)
- Video processing and conversion services
- Plugin system

c. Core Services
- Recording service
- Export service
- Plugin management
- Settings management
- Analytics service

##### Architecture Representation

**┌─ User Interface Layer ─────────────────────┐**
- ┌─────────┐ ┌─────────┐ ┌───────────────┐ │
- Cropper │ │ Editor  │ │ Preferences   │ │
- ┘ └─────────┘ └───────────────┘ │
- ┬───────────────────────┘

**┌─ IPC Bridge ──────┼───────────────────────┐**
- ┬┴───────────────────────┘

**┌─ Main Process ───┼───────────────────────┐**
- ┌─────────────┐ │ ┌──────────────────┐   │
- Recording   │ │ │ Video Processing │   │
- ┘ │ └──────────────────┘   │

- ┌─────────────┐ │ ┌──────────────────┐   │
- Plugins   │ │ │     Export       │   │
- ┘ │ └──────────────────┘   │
- ┼─────────────────────────┘

**┌─ System Level ──┼─────────────────────────┐**
- ┌─────────────┐│ ┌──────────────────┐    │
- Aperture   ││ │  System APIs     │    │
- ┘│ └──────────────────┘    │
- ┼──────────────────────────┘

##### Important Elements to Highlight

a. Data Flow
- IPC communication between renderer and main process
- Plugin data flow
- Export pipeline flow

b. Key Features
- Screen recording workflow
- Video conversion pipeline
- Plugin system architecture
- Export system

##### Additional Details

Annotations for:
- Built-in plugins
- Supported export formats
- System requirements
- External service integrations (Sentry, analytics)

##### Technical Stack Indicators

Technologies used:
- Electron
- Next.js
- TypeScript
- FFmpeg
- Native macOS APIs

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef main fill:#2ecc71,stroke:#27ae60,color:white
    classDef system fill:#e67e22,stroke:#d35400,color:white
    classDef plugin fill:#9b59b6,stroke:#8e44ad,color:white
    classDef service fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        UI[User Interface]:::ui
        Main[Main Process]:::main
        System[System Level]:::system
        Plugin[Plugin System]:::plugin
        Service[Services]:::service
    end

    %% User Interface Layer
    subgraph Frontend
        Cropper["Cropper Window"]:::ui
        Editor["Editor Window"]:::ui
        Preferences["Preferences Window"]:::ui
        Exports["Exports Window"]:::ui
        
        UIComponents["UI Components"]:::ui
        EditorComp["Editor Components"]:::ui
        CropperComp["Cropper Components"]:::ui
        PrefComp["Preferences Components"]:::ui
        ExportsComp["Exports Components"]:::ui
    end

    %% Main Process Layer
    subgraph MainProcess
        WinManager["Window Manager"]:::main
        WinConfig["Window Configurations"]:::main
        
        subgraph CoreServices
            ExportService["Export Service"]:::service
            Settings["Settings Management"]:::service
            Analytics["Analytics Service"]:::service
            RecHistory["Recording History"]:::service
        end
        
        subgraph VideoProcessing
            ConvService["Conversion Service"]:::main
            H264Conv["H264 Converter"]:::main
        end
        
        subgraph PluginSystem
            PluginManager["Plugin Manager"]:::plugin
            PluginService["Plugin Service"]:::plugin
            BuiltInPlugins["Built-in Plugins"]:::plugin
        end
    end

    %% System Level Layer
    subgraph SystemLevel
        Aperture["Aperture"]:::system
        SysPerms["System Permissions"]:::system
        ErrorReport["Error Reporting"]:::system
        SysAPIs["System APIs"]:::system
    end

    %% Relationships
    Cropper --> WinManager
    Editor --> WinManager
    Preferences --> WinManager
    Exports --> WinManager

    WinManager --> WinConfig
    WinManager --> CoreServices
    
    ExportService --> ConvService
    ConvService --> H264Conv
    
    PluginManager --> PluginService
    PluginService --> BuiltInPlugins
    
    ConvService --> Aperture
    Aperture --> SysAPIs
    
    CoreServices --> ErrorReport
    CoreServices --> SysPerms

    %% UI Component Relationships
    Cropper --> CropperComp
    Editor --> EditorComp
    Preferences --> PrefComp
    Exports --> ExportsComp

    %% Click Events
    click Cropper "https://github.com/wulkano/kap/blob/main/renderer/pages/cropper.js"
    click Editor "https://github.com/wulkano/kap/blob/main/renderer/pages/editor.tsx"
    click Preferences "https://github.com/wulkano/kap/blob/main/renderer/pages/preferences.js"
    click Exports "https://github.com/wulkano/kap/blob/main/renderer/pages/exports.tsx"
    click Aperture "https://github.com/wulkano/kap/blob/main/main/aperture.ts"
    click ConvService "https://github.com/wulkano/kap/tree/main/main/converters/"
    click H264Conv "https://github.com/wulkano/kap/blob/main/main/converters/h264.ts"
    click PluginManager "https://github.com/wulkano/kap/tree/main/main/plugins/"
    click BuiltInPlugins "https://github.com/wulkano/kap/tree/main/main/plugins/built-in/"
    click PluginService "https://github.com/wulkano/kap/blob/main/main/plugins/service.ts"
    click ExportService "https://github.com/wulkano/kap/blob/main/main/export.ts"
    click Settings "https://github.com/wulkano/kap/blob/main/main/common/settings.ts"
    click Analytics "https://github.com/wulkano/kap/blob/main/main/common/analytics.ts"
    click RecHistory "https://github.com/wulkano/kap/blob/main/main/recording-history.ts"
    click WinManager "https://github.com/wulkano/kap/blob/main/main/windows/manager.ts"
    click WinConfig "https://github.com/wulkano/kap/blob/main/main/windows/config.ts"
    click EditorComp "https://github.com/wulkano/kap/tree/main/renderer/components/editor/"
    click CropperComp "https://github.com/wulkano/kap/tree/main/renderer/components/cropper/"
    click PrefComp "https://github.com/wulkano/kap/tree/main/renderer/components/preferences/"
    click ExportsComp "https://github.com/wulkano/kap/tree/main/renderer/components/exports/"
    click SysPerms "https://github.com/wulkano/kap/blob/main/main/common/system-permissions.ts"
    click ErrorReport "https://github.com/wulkano/kap/blob/main/main/utils/sentry.ts"
```
