# thebertdark/gcsim-to-multiopt architecture

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

- Interactive diagram: https://gitdiagram.com/thebertdark/gcsim-to-multiopt
- Repository: https://github.com/thebertdark/gcsim-to-multiopt

## Overview

##### Project Type and Purpose
- This is a client-side, single-page web application (SPA) built with Svelte/SvelteKit and Vite.
- Purpose: In-browser conversion of `gcsim` JSON/GZ sample files into configuration JSON for Genshin Optimizer’s Multi-Opt tool.

##### File Structure Analysis
- Top-level:
- `.github/` – CI workflow (deploy) and issue templates
- `package.json` + lock – NPM dependencies and scripts
- `svelte.config.js`, `vite.config.ts`, `tsconfig.json` – build and TS configuration
- `src/`:
- `app.html` – base HTML shell
- `routes/+page.svelte` – main page component (entry point)
- `lib/components/` – UI building blocks (PlayIcon, PauseIcon, WelcomeOverlay, etc.)
- `lib/gcsim-to-multiopt/` – core conversion logic (config mappings, type definitions, convert.ts)
- `lib/utils/` – ancillary functions (themeManager, konamiCode, holiday testers)
- `static/`:
- CSS for seasonal themes, audio assets
- No server or database directories – purely static front end

##### Key Insights from README
- Workflow: upload sample → parse JSON/GZ → select character → toggle mods → generate output → copy to clipboard → import into Genshin Optimizer
- Conversion engine lives entirely on the client
- The app is hosted as static files (via GitHub Pages or similar)

##### Main Components
a. Browser (Client)
- Svelte Frontend (UI Components)
- File Processor (Conversion Engine in TS)
- Theme/UX Utilities
b. Static Hosting
- CDN or GitHub Pages serves HTML, JS, CSS, assets
c. External Service
- Genshin Optimizer site (consumer of generated JSON)

##### Relationships and Data Flows
- User → Browser UI: drag & drop or click to upload file
- Browser UI → File Processor: invoke `convert()` with parsed data
- File Processor → UI: return processed config and error list
- UI → Clipboard API: copy JSON output
- User → Genshin Optimizer: paste JSON into Multi-Opt tool
- Hosting Provider → Browser: serves static assets over HTTP(S)

##### Architectural Patterns and Design Principles
- SPA architecture: view and logic co-located in client
- Component-based UI (Svelte components)
- Modular conversion engine: separate TS modules for mapping/config and processing
- No server-side state; all state lives in the browser

##### Technologies and Frameworks
- Svelte / SvelteKit for component-driven UI
- Vite for dev server and build
- TypeScript for type safety
- GitHub Actions for automated deploy

##### Elements
- Hosting/CDN
- External Genshin Optimizer
- From Browser to Hosting (asset fetch)
- From User to Browser (upload)
- Within Browser (UI → Conversion Engine → UI → Clipboard API)
- From User to Genshin Optimizer
- Green for hosting/infrastructure
- Orange for external integration

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Actors and External
    User["User"]:::external
    External["Genshin Optimizer"]:::external

    %% Hosting Layer
    Hosting["CDN / GitHub Pages"]:::infra

    %% Browser Client Group
    subgraph "Browser (Client)" 
        direction TB
        subgraph "UI Layer"
            direction TB
            HTML["HTML Shell"]:::client
            Page["+page.svelte"]:::client
            subgraph "UI Components"
                direction TB
                CoreUI["Core UI Components"]:::client
                ElemIcons["Element Icons"]:::client
            end
        end

        subgraph "Business Logic Layer"
            direction TB
            Convert["convert.ts"]:::client
            Index["index.ts & Types"]:::client
            subgraph "Config Mappings"
                direction TB
                Configs["Mapping Files"]:::client
            end
        end

        Utils["Utilities"]:::client
        Clipboard["Clipboard API"]:::client
    end

    %% Data Flows
    User -->|"upload file"| Page
    Hosting -->|"serve assets over HTTPS"| HTML
    Page -->|"renders UI Components"| CoreUI
    Page -->|"renders UI Components"| ElemIcons
    CoreUI -->|"invokes convert() with data"| Convert
    Convert -->|"returns JSON config or errors"| Page
    Page -->|"copy output"| Clipboard
    User -->|"paste JSON"| External

    %% Click events
    click Page "https://github.com/thebertdark/gcsim-to-multiopt/blob/main/src/routes/+page.svelte"
    click HTML "https://github.com/thebertdark/gcsim-to-multiopt/blob/main/src/app.html"
    click CoreUI "https://github.com/thebertdark/gcsim-to-multiopt/tree/main/src/lib/components/"
    click ElemIcons "https://github.com/thebertdark/gcsim-to-multiopt/tree/main/src/lib/icons/"
    click Convert "https://github.com/thebertdark/gcsim-to-multiopt/blob/main/src/lib/gcsim-to-multiopt/convert.ts"
    click Index "https://github.com/thebertdark/gcsim-to-multiopt/blob/main/src/lib/gcsim-to-multiopt/index.ts"
    click Configs "https://github.com/thebertdark/gcsim-to-multiopt/tree/main/src/lib/gcsim-to-multiopt/config/"
    click Utils "https://github.com/thebertdark/gcsim-to-multiopt/tree/main/src/lib/utils/"

    %% Styling
    classDef client fill:#D0E8FF,stroke:#0366d6,stroke-width:1px;
    classDef infra fill:#DFFFE0,stroke:#2c662d,stroke-width:1px;
    classDef external fill:#FFE8D0,stroke:#d66306,stroke-width:1px;
```
