# voylinsgamedevjourney/gozen architecture

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

- Interactive diagram: https://gitdiagram.com/voylinsgamedevjourney/gozen
- Repository: https://github.com/voylinsgamedevjourney/gozen

## Overview

##### Project Type and Purpose
- GoZen is a desktop video editing application built on the Godot game engine.
- It integrates a custom GDExtension (C++) module to wrap FFmpeg for video/audio decoding, encoding, and rendering.
- Its goal is to provide a minimalist, performant NLE (non-linear editor) with a clean UI and cross-platform support (Linux, Windows, AppImage).

##### File Structure
- Top-level:
- build.py & libs/ – Python scripts and SCons files to fetch dependencies and build FFmpeg + GDExtension plugin.
- src/ – Godot project folder, containing scenes/, scripts/, shaders/, theming/, translations/, assets/.
- .github/ – CI workflows for building packages on Linux, Windows, RPM, DEB, AppImage.
- src/components:
- scenes/ – UI scenes (editor, timeline, menus, popups, render screen, audio meter).
- scripts/ – GDScript classes: UI widgets, data models (project_data, clip_data, settings_data), managers (file_manager, render_manager, input_manager, threader, thumbnailer).
- gozen.gdextension – metadata linking Godot to the compiled C++ extension.
- assets/, shaders/, theming/, translations/ – static resources loaded at runtime.

##### README Insights
- Build process: run build.py in libs/ to compile FFmpeg and GDExtension, then open the Godot project.
- Dependencies: Python, git-svn, SCons for Linux builds; C++ toolchain for GDExtension.
- Architecture hint: Godot+GDExtension boundary for performance-critical FFmpeg tasks.

##### Main Components
a. UI Layer (Godot Scenes & GDScripts)
- Media Pool, Timeline, Render Screen, Settings Menu, Audio Meter, Effects Panel, etc.
- GDScript “classes” and “globals” that drive UI behavior and state (e.g., project_manager, input_manager, popup_manager).
b. Core Engine (Godot)
- The host runtime that loads scenes, scripts, assets, and the GDExtension.
c. GDExtension Module (C++ / libs/gde_gozen)
- C++ code wrapping FFmpeg APIs (gozen_encoder, gozen_audio, gozen_video).
- Exposed to Godot via gdextension symbols (register_types.cpp).
d. External Libraries
- FFmpeg (libavcodec, libavformat, libavfilter, etc.) compiled via the build scripts.
e. Data Layer & Managers
- FileManager (I/O), ProjectManager (session), RenderManager (invoke encoding), Threader (multithreading), Thumbnailer.
f. File System & OS
- Local disk I/O for loading media files, writing export outputs.
- Python build scripts, SCons, GitHub Actions workflows.

##### Relationships & Data Flows
- User → Godot UI (scene) interactions trigger GDScripts → invoke Managers (e.g., file_manager.load(), render_manager.start_render()).
- Managers call GDExtension API functions → FFmpeg decodes/encodes frames → data buffers flow back to Godot for display or to disk for export.
- Threader manages background jobs for decoding, rendering, thumbnail generation.
- Localization, theming, and assets are loaded by Godot at startup.

##### Architectural Patterns & Principles
- MVC-like separation: Scenes (Views) + GDScript classes/data models (Models) + Managers (Controllers).
- Plugin architecture: core in Godot, performance layer in C++ GDExtension.
- Multithreaded processing for keep-UI responsive.
- Resource-driven: external .tres, .cfg, .gdshader files for profiles, themes, shaders.

##### Technologies & Frameworks
- Godot Engine (v4.x)
- GDExtension (native C++)
- FFmpeg libraries (LGPL/GPL)
- Python + SCons for build automation
- GitHub Actions for CI and packaging
- XCF, TRES, GDScript, GDSHADER, localization .po files

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Interaction
    User["User"]:::external

    %% UI Layer
    subgraph "UI Layer" 
        direction TB
        Scenes["UI Scenes\n(src/scenes/)"]:::gdscript
        ScriptsGroup["GDScript Scripts"] 
        direction TB
        DataModels["Data Models\n(src/scripts/classes/)"]:::gdscript
        Managers["Managers & Controllers\n(src/scripts/globals/)"]:::gdscript
    end

    %% Static Resources
    subgraph "Static Resources"
        direction TB
        Assets["Assets\n(src/assets/)"]:::resources
        Shaders["Shaders\n(src/shaders/)"]:::resources
        Theming["Theming\n(src/theming/)"]:::resources
        Translations["Translations\n(src/translations/)"]:::resources
    end

    %% Core Engine
    subgraph "Godot Engine"
        direction TB
        Engine["Godot Engine\n(v4.x)"]:::godotEngine
        ProjectFile["Project File\n(src/project.godot)"]:::godotEngine
        GdextMeta["GDExtension Metadata\n(src/gozen.gdextension & .uid)"]:::godotEngine
    end

    %% Native Plugin
    subgraph "GDExtension Plugin (C++)"
        direction TB
        Plugin["libs/gde_gozen/"]:::native
    end

    %% External Libraries & Build
    subgraph "FFmpeg & Build Automation"
        direction TB
        FFmpegLibs["FFmpeg Source\n(libs/ffmpeg/)"]:::external
        BuildGroup["Build Scripts"] 
        direction TB
        BuildPy["build.py"]:::external
        SCons["libs/SConstruct"]:::external
        DownloadDeps["libs/download_deps.py"]:::external
        BuildDeps["libs/build_deps.py"]:::external
        BuildFF["libs/build_ffmpeg.py"]:::external
    end

    %% CI Pipeline
    CI["CI Workflows\n(.github/workflows/)"]:::resources

    %% Filesystem
    FS["File System\n(Disk I/O)"]:::resources

    %% Connections
    User -->|"interacts with"| Scenes
    Scenes -->|"loads & binds"| Engine
    DataModels -->|"defines data"| Engine
    Managers -->|"controls & invokes"| Engine
    Scenes --> Managers
    Managers -->|"calls plugin API"| Plugin
    Engine -->|"loads plugin"| Plugin
    Plugin -->|"wraps FFmpeg"| FFmpegLibs
    Plugin -->|"returns decoded/encoded data"| Engine
    Engine -->|"loads resources"| Assets
    Engine -->|"loads resources"| Shaders
    Engine -->|"loads resources"| Theming
    Engine -->|"loads resources"| Translations
    Engine -->|"reads/writes media"| FS
    BuildPy -->|"orchestrates build"| FFmpegLibs
    BuildPy -->|"orchestrates build"| Plugin
    CI -->|"triggers build"| BuildPy

    %% Click Events
    click Scenes "https://github.com/voylinsgamedevjourney/gozen/tree/master/src/scenes/"
    click DataModels "https://github.com/voylinsgamedevjourney/gozen/tree/master/src/scripts/classes/"
    click Managers "https://github.com/voylinsgamedevjourney/gozen/tree/master/src/scripts/globals/"
    click Assets "https://github.com/voylinsgamedevjourney/gozen/tree/master/src/assets/"
    click Shaders "https://github.com/voylinsgamedevjourney/gozen/tree/master/src/shaders/"
    click Theming "https://github.com/voylinsgamedevjourney/gozen/tree/master/src/theming/"
    click Translations "https://github.com/voylinsgamedevjourney/gozen/tree/master/src/translations/"
    click ProjectFile "https://github.com/voylinsgamedevjourney/gozen/blob/master/src/project.godot"
    click GdextMeta "https://github.com/voylinsgamedevjourney/gozen/blob/master/src/gozen.gdextension"
    click Plugin "https://github.com/voylinsgamedevjourney/gozen/tree/master/libs/gde_gozen/"
    click FFmpegLibs "https://github.com/voylinsgamedevjourney/gozen/tree/master/libs/ffmpeg/"
    click BuildPy "https://github.com/voylinsgamedevjourney/gozen/blob/master/build.py"
    click SCons "https://github.com/voylinsgamedevjourney/gozen/tree/master/libs/SConstruct"
    click DownloadDeps "https://github.com/voylinsgamedevjourney/gozen/blob/master/libs/download_deps.py"
    click BuildDeps "https://github.com/voylinsgamedevjourney/gozen/blob/master/libs/build_deps.py"
    click BuildFF "https://github.com/voylinsgamedevjourney/gozen/blob/master/libs/build_ffmpeg.py"
    click CI "https://github.com/voylinsgamedevjourney/gozen/tree/master/.github/workflows/"

    %% Styles
    classDef godotEngine fill:#AEDFF7,stroke:#3399FF,color:#000
    classDef gdscript fill:#D0E8FF,stroke:#3399FF,color:#000
    classDef native fill:#B6E2A1,stroke:#33A533,color:#000
    classDef external fill:#FFD98E,stroke:#FFAA00,color:#000
    classDef resources fill:#E0E0E0,stroke:#888,color:#000
    classDef externalResources fill:#F0F0F0,stroke:#AAA,color:#000
    classDef external,resources externalResources
```
