# gorilla-devs/gdlauncher-carbon architecture

> Architecture diagram of the GitHub repository gorilla-devs/gdlauncher-carbon, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gorilla-devs/gdlauncher-carbon
- Repository: https://github.com/gorilla-devs/gdlauncher-carbon

## Overview

##### Project Type and Purpose
- GDLauncher is a full-stack, multi-component desktop application (with accompanying website) built to manage Minecraft installations, mod loaders, mods, and modpacks.
- The application is built using Rust for the core native backend and SolidJS (with Electron/Vite) for the UI. There is also a marketing/documentation website powered by Astro.
- The project is organized as a monorepo with separate parts for the desktop app, website, multiple Rust crates (backend modules), shared packages (UI components, configs, internationalization), and scripts/configurations for CI/CD and development.

##### Main Components
a. Desktop Application (Electron):
- Desktop app folder under apps/desktop with multiple subdirectories:
- Main process and preload (apps/desktop/packages/main, apps/desktop/packages/preload)
- Main window UI (apps/desktop/packages/mainWindow) implemented in SolidJS/React.
- Testing, build scripts, configuration files (vite.config, electron-builder, etc.).
- This part handles the user interface and interacts with native functionalities (auto-updates, mod installations, instance management, Java management, etc.).

b. Website (Marketing Site):
- Located under apps/website. Built with Astro.
- It serves content such as blog posts, documentation, download links, and community links.
- It interacts with static assets (images, fonts, public files) and uses custom components.

c. Backend/Native Core (Rust Crates):
- The “crates” directory contains several Rust crates such as:
- carbon_app – the core backend handling API endpoints, business logic (accounts, metrics, instance management, mod platforms etc.)
- Additional crates like carbon_compression, carbon_frontend, carbon_net, carbon_parsing, carbon_platforms, carbon_repos, carbon_rt_path – each addressing specialized functionalities.
- They interact with databases via Prisma (as evidenced by the prisma migrations in crates/carbon_repos) and potentially with external APIs (e.g., CurseForge, Modrinth).
- Communication between the UI (Electron app) and this native core is established through a combination of direct native calls or bindings (rspc bindings) and auto-generation of types.

d. Shared Packages and Libraries:
- Packages directory holds modules like:
- packages/ui – common UI components used by the desktop app.
- packages/i18n – internationalization support.
- packages/config – configuration and theme settings.
- packages/core_module – possibly a shared logic library.
- These libraries are used across both the desktop app and possibly other parts of the project.

##### Relationships and Interactions
- The desktop application (frontend) communicates with the Rust core (backend) via established API channels (rspc bindings or native integration) to fetch game version data, mod information, and perform instance management.
- The backend (within crates folder) aggregates data from external sources (CurseForge, Modrinth) and handles tasks like mod downloads, Java installation management, and metrics logging.
- The website component is separate from the desktop flow but shares the same overall repository and branding. It serves as a static/public information and download portal.
- Shared packages (configuration, UI components, i18n) are used by both desktop and web applications ensuring consistency.

##### Architectural Patterns to Highlight
- Separation of Concerns: Clearly dividing the UI (Electron/React components) from the native backend logic (Rust crates).
- Modular design: Both the desktop app and backend are split into many modular components and libraries, making it easier to extend or modify behavior.
- Client–Server Communication (even if on the same machine): The frontend communicates with the native backend via dedicated channels.
- Monorepo Structure: Use of shared packages among Electron, website, and Rust modules, all driven by pnpm/turbo.json for consistent versioning and building.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Desktop Application (Electron)
    subgraph "Desktop Application (Electron)"
        DP_Main["Main Process (Electron)"]:::electron
        DP_Preload["Preload Scripts (Electron)"]:::electron
        DP_Renderer["MainWindow Renderer (UI)"]:::electron
    end

    %% Rust Backend
    subgraph "Rust Backend"
        RB_CarbonApp["carbon_app"]:::rust
        RB_Compression["carbon_compression"]:::rust
        RB_Frontend["carbon_frontend"]:::rust
        RB_Net["carbon_net"]:::rust
        RB_Parsing["carbon_parsing"]:::rust
        RB_Platforms["carbon_platforms"]:::rust
        RB_Repos["carbon_repos"]:::rust
        RB_RtPath["carbon_rt_path"]:::rust
    end

    %% Website (Astro)
    subgraph "Website (Astro)"
        W_Astro["Astro Website"]:::astro
    end

    %% Shared Packages
    subgraph "Shared Packages"
        SP_UI["UI Components"]:::shared
        SP_i18n["Internationalization (i18n)"]:::shared
        SP_Config["Configuration"]:::shared
        SP_Core["Core Module"]:::shared
    end

    %% Connections between Desktop Application and Rust Backend
    DP_Renderer -->|"API_call"| RB_CarbonApp
    DP_Preload -->|"Init_binding"| RB_CarbonApp

    %% Connections within Rust Backend (delegation to ancillary crates)
    RB_CarbonApp -->|"delegates"| RB_Compression
    RB_CarbonApp -->|"delegates"| RB_Frontend
    RB_CarbonApp -->|"delegates"| RB_Net
    RB_CarbonApp -->|"delegates"| RB_Parsing
    RB_CarbonApp -->|"delegates"| RB_Platforms
    RB_CarbonApp -->|"delegates"| RB_Repos
    RB_CarbonApp -->|"delegates"| RB_RtPath

    %% Connections between Desktop Application and Shared Packages
    DP_Renderer -->|"uses"| SP_UI
    DP_Renderer -->|"uses"| SP_i18n
    DP_Renderer -->|"uses"| SP_Config

    %% Connections between Website and Shared Packages
    W_Astro -->|"uses"| SP_UI
    W_Astro -->|"uses"| SP_Config

    %% Styling Classes
    classDef electron fill:#C0E8F0,stroke:#333,stroke-width:2px;
    classDef rust fill:#F0C0C0,stroke:#333,stroke-width:2px;
    classDef astro fill:#D0F0C0,stroke:#333,stroke-width:2px;
    classDef shared fill:#E0C0F0,stroke:#333,stroke-width:2px;

    %% Click Events for Desktop Application
    click DP_Main "https://github.com/gorilla-devs/gdlauncher-carbon/tree/develop/apps/desktop/packages/main"
    click DP_Preload "https://github.com/gorilla-devs/gdlauncher-carbon/tree/develop/apps/desktop/packages/preload"
    click DP_Renderer "https://github.com/gorilla-devs/gdlauncher-carbon/tree/develop/apps/desktop/packages/mainWindow"

    %% Click Event for Website
    click W_Astro "https://github.com/gorilla-devs/gdlauncher-carbon/tree/develop/apps/website"

    %% Click Events for Rust Backend
    click RB_CarbonApp "https://github.com/gorilla-devs/gdlauncher-carbon/tree/develop/crates/carbon_app"
    click RB_Compression "https://github.com/gorilla-devs/gdlauncher-carbon/tree/develop/crates/carbon_compression"
    click RB_Frontend "https://github.com/gorilla-devs/gdlauncher-carbon/tree/develop/crates/carbon_frontend"
    click RB_Net "https://github.com/gorilla-devs/gdlauncher-carbon/tree/develop/crates/carbon_net"
    click RB_Parsing "https://github.com/gorilla-devs/gdlauncher-carbon/tree/develop/crates/carbon_parsing"
    click RB_Platforms "https://github.com/gorilla-devs/gdlauncher-carbon/tree/develop/crates/carbon_platforms"
    click RB_Repos "https://github.com/gorilla-devs/gdlauncher-carbon/tree/develop/crates/carbon_repos"
    click RB_RtPath "https://github.com/gorilla-devs/gdlauncher-carbon/tree/develop/crates/carbon_rt_path"

    %% Click Events for Shared Packages
    click SP_UI "https://github.com/gorilla-devs/gdlauncher-carbon/tree/develop/packages/ui"
    click SP_i18n "https://github.com/gorilla-devs/gdlauncher-carbon/tree/develop/packages/i18n"
    click SP_Config "https://github.com/gorilla-devs/gdlauncher-carbon/tree/develop/packages/config"
    click SP_Core "https://github.com/gorilla-devs/gdlauncher-carbon/tree/develop/packages/core_module"
```
