# committeeofzero/impacto architecture

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

- Interactive diagram: https://gitdiagram.com/committeeofzero/impacto
- Repository: https://github.com/committeeofzero/impacto

## Overview

This project – impacto – is an open‐source reimplementation of the "MAGES" visual novel engine. In essence, it is a cross-platform game engine written in C++ that supports multiple graphics backends (OpenGL, DirectX 9, experimental Vulkan) and audio systems, and it is designed to run original visual novel game data on a variety of platforms (Windows, Linux, Android, Switch, and even WebAssembly via Emscripten).

##### Main Project Components
- Engine Core: At the heart is the core engine found in the “src” directory (main.cpp, game.cpp, and various utility modules). This is where key game loop logic, memory management, and engine control routines are implemented.
- Subsystems:
– Rendering: Multiple rendering backends are provided in “src/renderer” (with directories for OpenGL, DirectX 9, Vulkan) along with shader programs in “src/shaders”. This subsystem handles 2D/3D graphics, scene management, and windowing.
– Audio: Located primarily in “src/audio”, with support for various audio backends such as OpenAL, FFMPEG-based players, and others (e.g., atrac9, vorbis). It manages audio streams, channels, and system integration.
– Input: The “src/inputsystem” and “src/vm/interface/input.cpp” modules capture device input and user interactions.
– Virtual Machine: The “src/vm” directory contains the VM engine responsible for interpreting or executing script instructions (control flow, dialogue, graphics-related operations, etc.).
– I/O and Data Management: The “src/io” folder and “src/data” provide file/archive management (such as reading game archives, asset data, manifests, etc.).
– Profiles: The “profiles” directory holds data and scripts (in Lua and other config files) that define game-specific behaviors, HUD elements, and dialogue for different supported titles.
- Platform-Specific Code:
– Android: The “android” subdirectory contains Android-specific project files and Java/C++ interface code, indicating that the engine’s cross-platform strategy includes native Android support.
– Docker / CI: Configuration files under “.github/workflows” and the “docker” folder indicate the use of containerized builds and CI pipelines.
- Build System: With CMake files (CMakeLists.txt, CMakePresets.json, and toolchain files like HorizonNX.toolchain) and vcpkg.json for dependency management, the build architecture is central to the development strategy.

##### Out Relationships and Interactions
- How the Engine Core communicates with each subsystem. For instance:
– The Core delegates rendering calls to the appropriate backend (e.g., OpenGL, DX9, or Vulkan) as selected by configuration or runtime parameters.
– Input events (from windowing or mobile-specific Android code) are routed into the engine’s input processor and then interpreted by the VM for game logic.
– Audio management involves pushing streams from the engine down to audio backends (OpenAL or FFMPEG) and back for user interactions.
– The UI/HUD layer interacts with both the rendering system and control flow managed by the VM.
– Data loading (from archives with CPK, AFS, or other formats) directly feeds into game assets used by rendering, audio, and profiles.
- Cross-platform abstraction layers, such as platform-specific initialization code (e.g., Android, Windows) and how these layered components call into the engine’s core library.

##### Architectural Patterns and Design Principles
- Modular Design: The file tree reflects a modular decomposition with clear separations between subsystems (audio, renderer, input, UI, VM, etc.).
- Cross-Platform Abstraction: Multiple toolchains and platform-specific directories (android, triplets, docker environments) demonstrate a design that abstracts low-level platform differences.
- Extensibility: The “profiles” directory, with many game-specific configuration and script files, illustrates a design intent that supports extensibility and easy adaptation for multiple games.
- Separation of Concerns: By splitting rendering, audio, data I/O, and user interface into distinct components, each module can evolve independently yet interact with the engine core through well-defined interfaces.

##### Technologies and Frameworks
- Languages and Core Libraries: C++ is used throughout. OpenGL is the primary graphics API (with experimental support for Vulkan and DirectX 9).
- Build Tools: CMake is used for project configuration and build management, supported by toolchain files and CI pipelines.
- Scripting: Lua files under various “profiles” directories for configuring game behaviors indicate scripting integration.
- Audio: OpenAL (in src/audio/openal), FFMPEG components, and specialized libraries for handling specific audio formats.
- CI/CD: GitHub Actions workflows and Docker files are central to the build/test infrastructure.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Engine Core Section
    subgraph "Engine Core"
        CE["Core Engine"]:::core
        GL["Game Loop"]:::core
        CU["Core Utilities"]:::core
    end
    CE --> GL
    CE --> CU

    %% Subsystems
    subgraph "Subsystems"
        RS["Rendering Subsystem"]:::subsystem
        SP["Shader Programs"]:::subsystem
        AS["Audio Subsystem"]:::subsystem
        OA["OpenAL Audio"]:::subsystem
        IS["Input System"]:::subsystem
        II["Input Interface"]:::subsystem
        UI["UI & HUD"]:::subsystem
        HM["HUD Modules"]:::subsystem
        VM["Virtual Machine"]:::subsystem
        IO["I/O and Data Management"]:::subsystem
        PF["Profiles/Configurations"]:::subsystem
    end
    RS --> SP
    AS --> OA
    IS --> II
    UI --> HM

    %% Platform Layer
    subgraph "Platform Layer"
        AP["Platform (Android)"]:::platform
    end

    %% Build & Integration
    subgraph "Build & Integration"
        BS["Build System & Dependencies"]:::build
        CI["CI/CD & Container Builds"]:::build
        CP["CMakePresets.json"]:::build
        HT["HorizonNX.toolchain"]:::build
        VP["vcpkg.json"]:::build
        DB["Docker Builds"]:::build
    end
    BS --> CP
    BS --> HT
    BS --> VP
    CI --> DB

    %% Relationships from Core Engine to Subsystems
    CE -->|"delegates"| RS
    CE -->|"delegates"| AS
    CE -->|"delegates"| IS
    CE -->|"delegates"| UI
    CE -->|"delegates"| VM
    CE -->|"feeds"| IO
    CE -->|"overrides"| PF

    %% Cross-Subsystem Interactions
    IS -->|"inputEvents"| VM
    UI -->|"renderCalls"| RS
    IO -->|"assetData"| RS
    IO -->|"assetData"| AS
    IO -->|"assetData"| PF

    %% Platform Connections
    AP -->|"providesInput"| IS
    AP -->|"initializes"| CE

    %% Build Connections
    BS -->|"builds"| CE
    CI -->|"triggersBuilds"| BS

    %% Click Events
    click CE "https://github.com/committeeofzero/impacto/blob/master/src/main.cpp"
    click GL "https://github.com/committeeofzero/impacto/blob/master/src/game.cpp"
    click CU "https://github.com/committeeofzero/impacto/tree/master/src/"
    click RS "https://github.com/committeeofzero/impacto/tree/master/src/renderer"
    click SP "https://github.com/committeeofzero/impacto/tree/master/src/shaders"
    click AS "https://github.com/committeeofzero/impacto/tree/master/src/audio"
    click OA "https://github.com/committeeofzero/impacto/tree/master/src/audio/openal"
    click IS "https://github.com/committeeofzero/impacto/tree/master/src/inputsystem"
    click II "https://github.com/committeeofzero/impacto/blob/master/src/vm/interface/input.cpp"
    click UI "https://github.com/committeeofzero/impacto/tree/master/src/ui"
    click HM "https://github.com/committeeofzero/impacto/tree/master/src/hud"
    click VM "https://github.com/committeeofzero/impacto/tree/master/src/vm"
    click IO "https://github.com/committeeofzero/impacto/tree/master/src/io"
    click PF "https://github.com/committeeofzero/impacto/tree/master/profiles"
    click AP "https://github.com/committeeofzero/impacto/tree/master/android"
    click BS "https://github.com/committeeofzero/impacto/blob/master/CMakeLists.txt"
    click CP "https://github.com/committeeofzero/impacto/blob/master/CMakePresets.json"
    click HT "https://github.com/committeeofzero/impacto/blob/master/HorizonNX.toolchain"
    click VP "https://github.com/committeeofzero/impacto/blob/master/vcpkg.json"
    click CI "https://github.com/committeeofzero/impacto/tree/master/.github/workflows"
    click DB "https://github.com/committeeofzero/impacto/tree/master/docker"

    %% Class Definitions for Colors
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px;
    classDef subsystem fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef platform fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef build fill:#FFB6C1,stroke:#333,stroke-width:2px;
```
