# jackhumbert/let_there_be_flight architecture

> Architecture diagram of the GitHub repository jackhumbert/let_there_be_flight, 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/jackhumbert/let_there_be_flight
- Repository: https://github.com/jackhumbert/let_there_be_flight

## Overview

- Core Mod Logic (the “Mod Core”): This includes the main entry point (src/red4ext/Main.cpp) and the overall orchestration of the mod’s hooking/injection into Cyberpunk 2077. It encompasses the FlightSystem, FlightController, and the various flight submodules.
- Flight Subsystems: Break these down further into:
– Flight Mechanics & Configuration: Components include FlightConfiguration, FlightEvents, FlightSettings, and the configuration classes (like CarFlightConfiguration, SixWheelCarFlightConfiguration, etc.).
– Visual Components: Camera (FlightCamera), UI elements (handled partly in Redscript under src/redscript/UI), and any particle or effects code.
– Audio Components: The FMOD integration provided under src/fmod_studio and the Audio code in src/red4ext/Audio (including FmodHelper). These handle the custom audio effects like explosion audio cues and engine sounds.
- Hooking & Patching Infrastructure: This includes the Hooks folder in src/red4ext where game functions are intercepted (e.g., FPPCamera_Update, Entity_InitializeComponents, etc.) to inject new behavior.
- Scripting & Extensions: The Redscript directory (src/redscript) contains flight scripts, compatibility patches, and additional extensions that provide gameplay behavior. Also, note the experiments folder that shows prototypes and example scripts.
- Build and Deployment: The presence of CMake files (CMakeLists.txt, cmake configuration scripts) and related build/dependency folders indicate a robust build system with external dependency integration.
- External Dependencies/Integrations: Clearly denote connections to dependent projects such as:
– RED4ext (for game mod injection)
– TweakXL and ArchiveXL (for asset packaging and tweaks)
– Input Loader (for handling customized control mappings)
– Redscript (scripting layer for game behavior)
– FMOD Studio (for managing the mod’s audio system)

##### Relationships and Data Flow
- Data flow from user inputs (captured via Input Loader) to the FlightController in the mod core.
- Interconnections where the FlightController interacts with the FlightSystem (updating vehicle state, triggering flight mode) and then calls into separate subsystems (camera updates, audio cues via FmodHelper, visual effects, etc.).
- Arrowed dependencies where the mod core communicates with the scripted behavior in Redscript, and both layers access configuration data (from XMLs in src/input_loader and configuration files in red4ext directories).
- Build system, where CMake aggregates all the submodules and integrates the external dependencies from the deps folder.

##### Architectural Patterns and Design Principles
- Modular Design: The code is split into clear modules—each specialized for a particular function (e.g., audio, physics, UI, flight mechanics).
- Hooking/Injection Pattern: Show how the Hooks components intercept game functions so that the mod can inject its own logic.
- Event-Driven Flow: The flight events, user inputs, and audio/visual triggers can be depicted as asynchronous events driving changes.
- Configurability: The configuration files and the use of specialized configuration classes (evident in the README snippet) demonstrate a design aimed at making the mod highly customizable.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Mod
    subgraph "Core Mod"
        Core["Mod Core"]:::mod
    end

    %% Flight Subsystems
    subgraph "Flight Subsystems"
        FS["Flight System"]:::subsystem
        FC["Flight Controller"]:::subsystem
        FConf["Flight Configuration"]:::subsystem
        FEv["Flight Events"]:::subsystem
        FSet["Flight Settings"]:::subsystem
    end

    %% Visual Components
    subgraph "Visual Components"
        FCam["Flight Camera"]:::visual
        UI["UI Elements & Visual Scripts"]:::visual
    end

    %% Audio Components
    subgraph "Audio Components"
        FMOD["FMOD Studio Integration"]:::audio
        FAudio["Audio Code"]:::audio
        FHelper["FmodHelper"]:::audio
        RAudio["Redscript Audio Scripts"]:::audio
    end

    %% Hooking & Patching Infrastructure
    subgraph "Hooking & Patching"
        Hooks["Hooks/Injection"]:::hooks
    end

    %% Scripting & Extensions
    subgraph "Scripting & Extensions"
        Redscript["Redscript Game Logic & Extensions"]:::scripting
    end

    %% Build and Deployment
    subgraph "Build & Deployment"
        Build["Build System"]:::build
    end

    %% External Dependencies/Integrations
    subgraph "External Dependencies"
        RED4["RED4ext SDK"]:::dependency
        FMODdep["FMOD Studio"]:::dependency
        Tweak["TweakXL"]:::dependency
        Archive["ArchiveXL"]:::dependency
        Input["Input Loader"]:::dependency
        ModSet["Mod Settings"]:::dependency
    end

    %% Interconnections - Data Flow and Dependencies
    %% User input flows from Input Loader to Flight Controller
    Input -->|"suppliesInput"| FC

    %% Core orchestration and hooking
    Core -->|"orchestrates"| FC
    Hooks -->|"injects"| Core

    %% Flight subsystem interactions
    FC -->|"initiates"| FS
    FC -->|"updates"| FCam
    FC -->|"updates"| UI

    %% Flight System triggers events in audio and visual layers
    FS -->|"triggers"| FAudio
    FAudio -->|"utilizes"| FHelper
    FS -->|"emits events"| FEv
    FS -->|"configures"| FConf
    FS -->|"applies"| FSet

    %% Core calls into scripting extensions
    Core -->|"callsScript"| Redscript

    %% Build system aggregates core and subsystems
    Build -->|"builds"| Core
    Build -->|"builds"| FS
    Build -->|"builds"| FC
    Build -->|"builds"| FConf
    Build -->|"builds"| FEv
    Build -->|"builds"| FSet

    %% External dependencies integrations
    RED4 -->|"integrates"| Core
    FMODdep -->|"supports"| FMOD
    Tweak -->|"assists"| Build
    Archive -->|"assists"| Build
    ModSet -->|"configures"| Build

    %% Connect audio components with FMOD Studio Integration
    FMOD -->|"providesAudio"| FAudio
    FMOD -->|"providesAudio"| RAudio

    %% Styles
    classDef mod fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef subsystem fill:#ccffcc,stroke:#009900,stroke-width:2px;
    classDef visual fill:#ccccff,stroke:#0000ff,stroke-width:2px;
    classDef audio fill:#ffffcc,stroke:#999900,stroke-width:2px;
    classDef hooks fill:#ffccff,stroke:#cc0099,stroke-width:2px;
    classDef scripting fill:#ccffff,stroke:#009999,stroke-width:2px;
    classDef build fill:#e0e0e0,stroke:#666666,stroke-width:2px;
    classDef dependency fill:#f0e68c,stroke:#b8860b,stroke-width:2px;

    %% Click Events for Component Mapping
    click Core "https://github.com/jackhumbert/let_there_be_flight/blob/main/src/red4ext/Main.cpp"
    click FS "https://github.com/jackhumbert/let_there_be_flight/blob/main/src/red4ext/FlightSystem.cpp"
    click FC "https://github.com/jackhumbert/let_there_be_flight/blob/main/src/red4ext/FlightController.cpp"
    click FConf "https://github.com/jackhumbert/let_there_be_flight/blob/main/src/red4ext/FlightConfiguration.cpp"
    click FEv "https://github.com/jackhumbert/let_there_be_flight/blob/main/src/red4ext/FlightEvents.cpp"
    click FSet "https://github.com/jackhumbert/let_there_be_flight/blob/main/src/red4ext/FlightSettings.cpp"
    click FCam "https://github.com/jackhumbert/let_there_be_flight/blob/main/src/red4ext/Camera/FlightCamera.cpp"
    click UI "https://github.com/jackhumbert/let_there_be_flight/blob/main/src/redscript/UI/hudFlightController.reds"
    click FMOD "https://github.com/jackhumbert/let_there_be_flight/tree/main/src/fmod_studio"
    click FAudio "https://github.com/jackhumbert/let_there_be_flight/blob/main/src/red4ext/Audio/FlightAudio.cpp"
    click FHelper "https://github.com/jackhumbert/let_there_be_flight/blob/main/src/red4ext/Audio/FmodHelper.cpp"
    click RAudio "https://github.com/jackhumbert/let_there_be_flight/blob/main/src/redscript/Audio/FlightAudio.reds"
    click Hooks "https://github.com/jackhumbert/let_there_be_flight/tree/main/src/red4ext/Hooks"
    click Redscript "https://github.com/jackhumbert/let_there_be_flight/tree/main/src/redscript"
    click Build "https://github.com/jackhumbert/let_there_be_flight/blob/main/CMakeLists.txt"
    click RED4 "https://github.com/jackhumbert/let_there_be_flight/blob/main/deps/red4ext.sdk"
    click FMODdep "https://github.com/jackhumbert/let_there_be_flight/tree/main/deps/fmod"
    click Tweak "https://github.com/jackhumbert/let_there_be_flight/tree/main/deps/tweak_xl"
    click Archive "https://github.com/jackhumbert/let_there_be_flight/tree/main/deps/archive_xl"
    click Input "https://github.com/jackhumbert/let_there_be_flight/tree/main/deps/input_loader"
    click ModSet "https://github.com/jackhumbert/let_there_be_flight/tree/main/deps/mod_settings"
```
