# williamvenner/gmpublisher architecture

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

- Interactive diagram: https://gitdiagram.com/williamvenner/gmpublisher
- Repository: https://github.com/williamvenner/gmpublisher

## Overview

Here are the key lessons you can draw from gmpublisher’s structure and setup—insights you can apply to other projects:

1. Clear Frontend–Backend Separation  
   • Keep UI and core logic in distinct directories (e.g. `app/` for Svelte, `src-tauri/` for Rust).  
   • Enables independent development, testing, and tooling for each layer.  

2. Leverage a Lightweight Desktop Framework  
   • Tauri (Rust + Web UI) makes for a small, efficient alternative to Electron.  
   • Rust backend yields a native-performance core, while Svelte gives you a modern reactive UI.  

3. Organize Code by Feature/Domain  
   • Group related modules (e.g. `src-tauri/src/steam/`, `src-tauri/src/gma/`, `src-tauri/src/util/`).  
   • Feature-based layout improves discoverability and reduces entanglement.  

4. Share Core Logic Between CLI and GUI  
   • Expose the same Rust command/logic layer to both the desktop UI and a standalone CLI (`cli.rs`, `commands.rs`).  
   • Maximizes reuse and keeps business logic in one place.  

5. Embrace Configuration-as-Code  
   • Maintain `tauri.conf.json`, `Cargo.toml`, `vite.config.js`, `svelte.config.js`, `jsconfig.json`, `.cargo/config.toml`.  
   • Version-controlling those configs ensures everyone builds the same way.  

6. Provide Comprehensive Internationalization  
   • Store translations in dedicated JSON files (`i18n/*.json`).  
   • Centralize language keys in code (`i18n.js`) to make adding new locales trivial.  

7. Modularize Utility Functions  
   • Keep helper routines in `src-tauri/src/util/` (e.g. path helpers, JSON escape, custom locks).  
   • Encourages reuse and easier unit testing of non-UI code.  

8. Integrate Native SDKs Safely  
   • Bundle Steamworks headers/libs under `src-tauri/lib/steam_api/`, then wrap them in a Rust-safe interface (`steam/*.rs`).  
   • Build steps (`build.rs`, `copySharedLibs.js`) ensure the right binaries get into the final app.  

9. Automate Packaging and Distribution  
   • Include platform-specific installer definitions (MSI under `src-tauri/msi/`).  
   • Use CI workflows (`.github/workflows/build.yml`) to produce release artifacts automatically.  

10. Invest in Documentation and Discovery  
   • A thorough README with screenshots, feature list, and download links sets user expectations.  
   • Embedding ‘how-to’ tutorials and linking to videos helps onboard new users quickly.  

11. Adopt Multithreading for Performance-Critical Work  
   • Rust’s threading makes tasks like bulk downloads or GMA extraction speedy.  
   • Keep long-running tasks off the UI thread to maintain a responsive interface.  

12. Organize Static Assets for the Frontend  
   • Group CSS, fonts, images, and sounds under `public/` with subdirs (`css/`, `img/`, `sound/`).  
   • Simplifies asset management and caching strategy.  

13. Keep Code Style Consistent  
   • Use `.editorconfig`, `rustfmt.toml`, and linting rules so all contributors follow the same conventions.  

14. Provide Feedback and Error Reporting  
   • Centralize error reporting in plugins (`app/plugins/ErrorReporter.js`), and surface errors in a modal.  
   • Improves debuggability and user trust.  

15. Build Extensibility into the UI  
   • Use Svelte components (modals, context menus, sidebars) and a plugin pattern to add new UI features without bloating core code.  

Applying these practices will help you create well-structured, performant, maintainable, and user-friendly applications in any language or framework.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    FE["Frontend Layer"]:::frontend
    subgraph "Frontend Components"
        UIComp["UI Components\n(Modal, ContextMenu,\nNavSidebar)"]:::frontend
        ErrorRep["Error Reporter Plugin"]:::frontend
        I18nLoad["Language Keys Loader\n(i18n.js)"]:::frontend
        subgraph "Static Frontend Assets"
            CSS["CSS"]:::assets
            Fonts["Fonts"]:::assets
            Images["Images"]:::assets
            Sounds["Sounds"]:::assets
        end
        subgraph "Frontend Configs"
            ViteCfg["Vite Config"]:::config
            SvelteCfg["Svelte Config"]:::config
            JSProjCfg["JS Project Config"]:::config
        end
    end

    %% Backend Layer
    BE["Backend Layer\n(Tauri/Rust)"]:::backend
    subgraph "Rust Feature Modules"
        SteamMod["Steam Integration"]:::backend
        GMAMod["GMA Handling"]:::backend
        UtilMod["Utility Functions"]:::util
    end
    subgraph "CLI & Logic"
        CLI["CLI\n(cli.rs)"]:::backend
        Cmd["Commands\n(commands.rs)"]:::backend
    end
    subgraph "Backend Configs"
        TauriCfg["Tauri Config"]:::config
        CargoToml["Cargo Manifest"]:::config
        CargoCfg["Cargo Config"]:::config
        RustfmtCfg["Rustfmt Config"]:::config
    end

    %% SDK Bindings
    SteamSDK["Native Steam SDK Bindings"]:::util

    %% Packaging & CI
    subgraph "Packaging & Distribution"
        MSI["MSI Installer Definitions"]:::ci
        CIWF["CI Build Workflow"]:::ci
    end

    %% Documentation & Code Style
    Docs["README.md"]:::docs
    subgraph "Code Style Configs"
        EditorCfg["EditorConfig"]:::docs
    end

    %% Relationships
    FE -->|"invokes via Tauri API"| BE
    FE --> UIComp
    FE --> ErrorRep
    FE --> I18nLoad
    FE --> CSS
    FE --> Fonts
    FE --> Images
    FE --> Sounds
    FE --> ViteCfg
    FE --> SvelteCfg
    FE --> JSProjCfg

    BE --> CLI
    BE --> Cmd
    BE --> SteamMod
    BE --> GMAMod
    BE --> UtilMod
    SteamMod --> SteamSDK
    UtilMod --> UtilMod
    BE --> TauriCfg
    BE --> CargoToml
    BE --> CargoCfg
    BE --> RustfmtCfg

    BE --> MSI
    BE --> CIWF

    Docs --> EditorCfg

    %% Click Events
    click FE "https://github.com/williamvenner/gmpublisher/tree/master/app/"
    click UIComp "https://github.com/williamvenner/gmpublisher/tree/master/app/components/"
    click ErrorRep "https://github.com/williamvenner/gmpublisher/blob/master/app/plugins/ErrorReporter.js"
    click I18nLoad "https://github.com/williamvenner/gmpublisher/blob/master/app/i18n.js"
    click CSS "https://github.com/williamvenner/gmpublisher/tree/master/public/css/"
    click Fonts "https://github.com/williamvenner/gmpublisher/tree/master/public/fonts/"
    click Images "https://github.com/williamvenner/gmpublisher/tree/master/public/img/"
    click Sounds "https://github.com/williamvenner/gmpublisher/tree/master/public/sound/"
    click ViteCfg "https://github.com/williamvenner/gmpublisher/blob/master/vite.config.js"
    click SvelteCfg "https://github.com/williamvenner/gmpublisher/blob/master/svelte.config.js"
    click JSProjCfg "https://github.com/williamvenner/gmpublisher/blob/master/jsconfig.json"
    click BE "https://github.com/williamvenner/gmpublisher/tree/master/src-tauri/"
    click SteamMod "https://github.com/williamvenner/gmpublisher/tree/master/src-tauri/src/steam/"
    click GMAMod "https://github.com/williamvenner/gmpublisher/tree/master/src-tauri/src/gma/"
    click UtilMod "https://github.com/williamvenner/gmpublisher/tree/master/src-tauri/src/util/"
    click CLI "https://github.com/williamvenner/gmpublisher/blob/master/src-tauri/src/cli.rs"
    click Cmd "https://github.com/williamvenner/gmpublisher/blob/master/src-tauri/src/commands.rs"
    click TauriCfg "https://github.com/williamvenner/gmpublisher/blob/master/src-tauri/tauri.conf.json"
    click CargoToml "https://github.com/williamvenner/gmpublisher/blob/master/src-tauri/Cargo.toml"
    click CargoCfg "https://github.com/williamvenner/gmpublisher/blob/master/.cargo/config.toml"
    click RustfmtCfg "https://github.com/williamvenner/gmpublisher/blob/master/src-tauri/rustfmt.toml"
    click SteamSDK "https://github.com/williamvenner/gmpublisher/tree/master/src-tauri/lib/steam_api/"
    click MSI "https://github.com/williamvenner/gmpublisher/tree/master/src-tauri/msi/"
    click CIWF "https://github.com/williamvenner/gmpublisher/blob/master/.github/workflows/build.yml"
    click Docs "https://github.com/williamvenner/gmpublisher/blob/master/README.md"
    click EditorCfg "https://github.com/williamvenner/gmpublisher/blob/master/.editorconfig"

    %% Styles
    classDef frontend fill:#d0ebff,stroke:#1c7ed6,color:#1c7ed6;
    classDef backend fill:#d3f9d8,stroke:#37b24d,color:#37b24d;
    classDef config fill:#fff3bf,stroke:#f08c00,color:#f08c00;
    classDef util fill:#ffe3e3,stroke:#fa5252,color:#fa5252;
    classDef assets fill:#f8f0fc,stroke:#7950f2,color:#7950f2;
    classDef ci fill:#e7f5ff,stroke:#339af0,color:#339af0;
    classDef docs fill:#f1f3f5,stroke:#868e96,color:#495057;
```
