# gizmo-ds/vcc-auto-translate architecture

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

- Interactive diagram: https://gitdiagram.com/gizmo-ds/vcc-auto-translate
- Repository: https://github.com/gizmo-ds/vcc-auto-translate

## Overview

##### Project type and purpose
- This is a “patcher”/translation tool for a desktop application (VRChat Creator Companion, or VCC).
- It consists of two main codebases:
- A TypeScript “patch-loader” that uses AST techniques to inject translations into VCC’s React code.
- A Rust-based CLI installer that bundles the patch-loader and applies it to the user’s VCC installation.

##### File structure
- Top level:
- package.json, pnpm-lock.yaml, tsconfig.json – define the Node/TS build environment.
- scripts/ – TS build scripts (build-patch-loader.ts, version.ts, localization_hashs.ts).
- src/ – source of the patch-loader and injector logic.
- crates/installer/ – Rust project that compiles to an executable installer.
- localization/ – JSON files with translation mappings.
- images/, docs/ – assets for README and documentation.
- Makefile – orchestrates the build of both TS and Rust parts.
- Patterns:
- A build pipeline: TS sources + localization data → bundled patch-loader.js → embedded into Rust installer assets.
- Runtime: Rust installer invokes patch-loader.js to modify VCC files on disk.

##### README for additional insights
- Purpose: automatically translate VCC interface by patching its WebApp/Dist/index.html using AST.
- Build steps: pnpm run build:patch-loader → copy built JS into crates/installer/assets → cargo build --release.
- Usage: user downloads the installer binary and runs it in the VCC installation directory.

##### Elements
- Blue for build-time artifacts/processes.
- Green for runtime installer activities.
- Gray for the target application.
- Rectangles for code modules.

##### Summary
- Both build and runtime workflows.
- Separate concerns visually: TS vs. Rust vs. VCC target.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Developer Workstation
    subgraph "Developer Workstation"
        direction TB
        pkg["package.json"]:::build
        tsconfig["tsconfig.json"]:::build
        lock["pnpm-lock.yaml"]:::build
        MakefileNode["Makefile"]:::build
        subgraph "Scripts"
            direction TB
            buildScript["build-patch-loader.ts"]:::build
            hashScript["localization_hashs.ts"]:::build
            versionScript["version.ts"]:::build
        end
        subgraph "TypeScript Source"
            direction TB
            patchLoaderTS["patch-loader.ts"]:::build
            injectorTS["injector.ts"]:::build
            helpersTS["helpers.ts"]:::build
            typesDir["types/"]:::build
            subgraph "patch/"
                direction TB
                patchDir["src/patch/"]:::build
            end
            subgraph "components/"
                direction TB
                compDir["src/components/"]:::build
            end
        end
        locData["localization/"]:::build
    end

    %% Build Pipeline
    subgraph "Build Pipeline"
        direction TB
        TSCompile["TS Compiler"]:::build
        BundleJS["patch-loader.js"]:::build
        CopyAsset["Asset Copier"]:::build
        CargoBuild["Cargo Build"]:::build
    end

    %% Runtime Installer
    subgraph "Runtime Installer"
        direction TB
        mainRS["main.rs"]:::runtime
        utilsRS["utils.rs"]:::runtime
        vccRS["vcc.rs"]:::runtime
        assetDir["assets/"]:::runtime
        rustToml["Cargo.toml"]:::runtime
    end

    %% Target Application
    subgraph "Target Application (VCC)"
        direction TB
        origHTML["index.html (original)"]:::target
        backupHTML["index.html (backup)"]:::target
    end

    %% Data Store
    locData -->|provides translations| TSCompile
    TSCompile -->|compiles| BundleJS
    BundleJS -->|embedded via| CopyAsset
    CopyAsset -->|copies to| assetDir
    assetDir -->|bundled in| CargoBuild
    MakefileNode -->|orchestrates| TSCompile
    MakefileNode -->|orchestrates| CargoBuild
    pkg & tsconfig & lock -->|config for| TSCompile

    CargoBuild -->|produces installer.exe| mainRS
    mainRS -->|uses| utilsRS
    mainRS -->|uses| vccRS
    mainRS -->|loads| BundleJS
    mainRS -->|executes on| origHTML
    mainRS -->|backs up| backupHTML
    mainRS -->|patches via| BundleJS
    backupHTML -->|restored if needed| mainRS

    classDef build fill:#cce5ff,stroke:#3399ff;
    classDef runtime fill:#d4edda,stroke:#28a745;
    classDef target fill:#f0f0f0,stroke:#6c757d;

    %% Click Events
    click patchLoaderTS "https://github.com/gizmo-ds/vcc-auto-translate/blob/main/src/patch-loader.ts"
    click injectorTS "https://github.com/gizmo-ds/vcc-auto-translate/blob/main/src/injector.ts"
    click patchDir "https://github.com/gizmo-ds/vcc-auto-translate/tree/main/src/patch/"
    click compDir "https://github.com/gizmo-ds/vcc-auto-translate/tree/main/src/components/"
    click helpersTS "https://github.com/gizmo-ds/vcc-auto-translate/blob/main/src/helpers.ts"
    click typesDir "https://github.com/gizmo-ds/vcc-auto-translate/tree/main/types/"
    click locData "https://github.com/gizmo-ds/vcc-auto-translate/tree/main/localization/"
    click buildScript "https://github.com/gizmo-ds/vcc-auto-translate/blob/main/scripts/build-patch-loader.ts"
    click hashScript "https://github.com/gizmo-ds/vcc-auto-translate/blob/main/scripts/localization_hashs.ts"
    click versionScript "https://github.com/gizmo-ds/vcc-auto-translate/blob/main/scripts/version.ts"
    click mainRS "https://github.com/gizmo-ds/vcc-auto-translate/blob/main/crates/installer/src/main.rs"
    click utilsRS "https://github.com/gizmo-ds/vcc-auto-translate/blob/main/crates/installer/src/utils.rs"
    click vccRS "https://github.com/gizmo-ds/vcc-auto-translate/blob/main/crates/installer/src/vcc.rs"
    click assetDir "https://github.com/gizmo-ds/vcc-auto-translate/tree/main/crates/installer/assets/"
    click rustToml "https://github.com/gizmo-ds/vcc-auto-translate/blob/main/crates/installer/Cargo.toml"
    click MakefileNode "https://github.com/gizmo-ds/vcc-auto-translate/tree/main/Makefile"
    click pkg "https://github.com/gizmo-ds/vcc-auto-translate/blob/main/package.json"
    click tsconfig "https://github.com/gizmo-ds/vcc-auto-translate/blob/main/tsconfig.json"
    click lock "https://github.com/gizmo-ds/vcc-auto-translate/blob/main/pnpm-lock.yaml"
```
