# wangqr/aegisub architecture

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

- Interactive diagram: https://gitdiagram.com/wangqr/aegisub
- Repository: https://github.com/wangqr/aegisub

## Overview

##### Main Components Identification

The system should be divided into these major components:

a. Core Components:
- Subtitle Engine (libaegisub/ass/*)
- Audio System (src/audio_*)
- Video System (src/video_*)
- User Interface (src/* UI-related files)
- Automation System (automation/*)

b. Supporting Components:
- File I/O (libaegisub/common/*)
- Character Encoding (libaegisub/common/charset*)
- Scripting Engine (LuaJIT integration)
- Spellchecking System (src/spellchecker*)

##### Component Relationships

**[User Interface Layer]**
- ↑↓
**[Core Controllers]**
- ↑↓
**[Processing Layer]**
- ↑↓
**[Provider Layer]**
- ↑↓
**[External Libraries]**

##### Detailed Component Breakdown

a. User Interface Layer (Purple):
- Main Frame (src/frame_main)
- Dialogs (src/dialog_*)
- Visual Tools (src/visual_tool_*)
- Grid Interface (src/grid_*)

b. Core Controllers (Blue):
- Subtitle Controller (src/subs_controller)
- Audio Controller (src/audio_controller)
- Video Controller (src/video_controller)
- Project Manager (src/project)

c. Processing Layer (Green):
- ASS Parser/Writer
- Audio Processors
- Video Processors
- Automation Engine

d. Provider Layer (Orange):
- Video Providers (FFMS2, Avisynth)
- Audio Providers
- Subtitle Providers
- Spellcheck Providers

e. External Libraries (Gray):
- wxWidgets
- Boost
- FFmpeg
- libass
- LuaJIT

##### Data Flow Indicators

- Subtitle data flow
- Audio/Video stream flow
- User input flow
- Automation script execution flow

##### Cross-Platform Elements

Platform-specific implementations:
- Windows-specific (src/windows/*)
- Unix-specific (src/unix/*)
- macOS-specific (src/osx/*)

##### Implementation Notes

Notes for:
- Build system integration (CMake/autoconf)
- Plugin architecture
- Scripting interface
- Resource management

- Rectangles: Core components
- Rounded rectangles: UI elements
- Hexagons: External dependencies
- Diamonds: Decision points

Remember to maintain a balance between detail and clarity, focusing on the architectural relationships while avoiding overwhelming detail at the implementation level.

This design should reflect Aegisub's modular architecture while showing how components interact to provide subtitle editing functionality across different platforms.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#E6E6FA,stroke:#333
    classDef core fill:#ADD8E6,stroke:#333
    classDef processing fill:#90EE90,stroke:#333
    classDef provider fill:#FFB347,stroke:#333
    classDef external fill:#D3D3D3,stroke:#333
    classDef platform fill:#FFC0CB,stroke:#333

    %% User Interface Layer
    subgraph UI
        MainFrame["Main Frame"]:::ui
        Dialogs["Dialogs"]:::ui
        VisualTools["Visual Tools"]:::ui
        GridInterface["Grid Interface"]:::ui
    end

    %% Core Controllers
    subgraph Controllers
        SubController["Subtitle Controller"]:::core
        AudioController["Audio Controller"]:::core
        VideoController["Video Controller"]:::core
        ProjectManager["Project Manager"]:::core
    end

    %% Processing Layer
    subgraph Processing
        SubEngine["Subtitle Engine"]:::processing
        AudioProc["Audio Processors"]:::processing
        VideoProc["Video Processors"]:::processing
        AutoEngine["Automation Engine"]:::processing
        CharEncoding["Character Encoding"]:::processing
        SpellCheck["Spellchecking System"]:::processing
        FileIO["File I/O"]:::processing
        ScriptEngine["Scripting Engine"]:::processing
    end

    %% Provider Layer
    subgraph Providers
        VideoProviders["Video Providers"]:::provider
        AudioProviders["Audio Providers"]:::provider
        SubProviders["Subtitle Providers"]:::provider
        SpellProviders["Spellcheck Providers"]:::provider
    end

    %% External Libraries
    subgraph External
        wxWidgets["wxWidgets"]:::external
        Boost["Boost"]:::external
        FFmpeg["FFmpeg"]:::external
        libass["libass"]:::external
        LuaJIT["LuaJIT"]:::external
    end

    %% Platform-Specific
    subgraph Platform
        Windows["Windows"]:::platform
        Unix["Unix"]:::platform
        MacOS["macOS"]:::platform
    end

    %% Relationships
    UI --> Controllers
    Controllers --> Processing
    Processing --> Providers
    Providers --> External
    Platform --> Controllers

    %% Click events
    click SubEngine "https://github.com/wangqr/Aegisub/tree/dev/libaegisub/ass/"
    click AudioController "https://github.com/wangqr/Aegisub/blob/dev/src/audio_controller.cpp"
    click VideoController "https://github.com/wangqr/Aegisub/blob/dev/src/video_controller.cpp"
    click MainFrame "https://github.com/wangqr/Aegisub/blob/dev/src/frame_main.cpp"
    click AutoEngine "https://github.com/wangqr/Aegisub/tree/dev/automation/"
    click FileIO "https://github.com/wangqr/Aegisub/blob/dev/libaegisub/common/io.cpp"
    click CharEncoding "https://github.com/wangqr/Aegisub/blob/dev/libaegisub/common/charset.cpp"
    click ScriptEngine "https://github.com/wangqr/Aegisub/tree/dev/libaegisub/lua/"
    click SpellCheck "https://github.com/wangqr/Aegisub/blob/dev/src/spellchecker.cpp"

    %% Legend
    subgraph Legend
        UI_L["UI Components"]:::ui
        Core_L["Core Components"]:::core
        Proc_L["Processing Components"]:::processing
        Prov_L["Providers"]:::provider
        Ext_L["External Libraries"]:::external
        Plat_L["Platform-Specific"]:::platform
    end
```
