# geph-official/gephgui-wry architecture

> Architecture diagram of the GitHub repository geph-official/gephgui-wry, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/geph-official/gephgui-wry
- Repository: https://github.com/geph-official/gephgui-wry

## Overview

##### Project type and purpose
- gephgui-wry is a cross-platform desktop GUI application built in Rust, hosting a local HTML/JS frontend (the gephgui submodule) inside a Wry (WebView) window. Its job is to provide a user interface for controlling the Geph VPN daemon, handling updates, configuration (PAC files), and IPC between the UI and system services.

##### File structure
- Top level:
- Cargo.toml, Cargo.lock, build.rs → Rust project configuration and build script.
- .cargo/config → Cargo build configuration.
- gephgui/ → git submodule containing the HTML/JavaScript frontend.
- src/:
- main.rs → sets up the Wry window, loads the static assets, registers RPC handlers.
- rpc.rs → defines the Rust side of the RPC/API exposed to JS.
- daemon.rs → logic for launching, monitoring, and communicating with the Geph VPN daemon process.
- autoupdate.rs → self-update logic (checking for new versions, downloading, restarting).
- pac.rs → generates or serves the PAC (Proxy Auto-Configuration) file.
- mtbus.rs → message bus abstraction within Rust for internal event distribution.
- fakefs.rs → virtual filesystem layer to map/serve static assets to the WebView.
- init.js → injected script to bootstrap the JS side of the RPC API.
- linux-start-vpn.sh → Linux-specific VPN startup helper.

##### README for additional insights
- Confirms the dual nature: Rust “host” application + HTML/JS “gephgui” frontend.
- Dependency on Wry for the WebView (cross-platform).
- Build steps: compile frontend, then `cargo install` the Rust wrapper.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Frontend Tier"
        direction TB
        UI["gephgui HTML/JS"]:::ui
        InitJS["init.js (JS bootstrap)"]:::ui
        UI -->|"bootstrap via init.js"| InitJS
    end

    subgraph "Backend Tier"
        direction TB
        Build["build.rs"]:::rust
        Config["Cargo.toml<br/>.cargo/config<br/>Cargo.lock"]:::rust
        Main["src/main.rs<br/>(Wry setup)"]:::rust
        FakeFS["src/fakefs.rs<br/>(virtual FS)"]:::rust
        RPC["src/rpc.rs"]:::rust
        MTBus["src/mtbus.rs"]:::rust
        DaemonCtrl["src/daemon.rs"]:::rust
        PAC["src/pac.rs"]:::rust
        AutoUpd["src/autoupdate.rs"]:::rust

        Build -->|"embed assets"| FakeFS
        Config --> Main
        Main --> FakeFS
        Main --> RPC
        FakeFS --> UI
        UI -->|"RPC calls"| RPC
        RPC --> MTBus
        MTBus --> DaemonCtrl
        MTBus --> PAC
        MTBus --> AutoUpd
    end

    subgraph "External Services"
        direction TB
        GephDaemon["Geph VPN daemon"]:::ext
        LinuxScript["src/linux-start-vpn.sh"]:::ext
        OS["OS filesystem/network stack"]:::ext
        DaemonCtrl -->|"spawn/monitor"| GephDaemon
        GephDaemon -->|"status events"| DaemonCtrl
        DaemonCtrl --> LinuxScript
        PAC -->|"serve PAC file"| OS
        AutoUpd -->|"network requests / restart"| OS
    end

    classDef ui fill:#cce5ff,stroke:#004085;
    classDef rust fill:#d4edda,stroke:#155724;
    classDef ext fill:#e2e3e5,stroke:#3a3b3c;

    click UI "https://github.com/geph-official/gephgui-wry/tree/master/gephgui/"
    click Build "https://github.com/geph-official/gephgui-wry/blob/master/build.rs"
    click Config "https://github.com/geph-official/gephgui-wry/blob/master/Cargo.toml"
    click Main "https://github.com/geph-official/gephgui-wry/blob/master/src/main.rs"
    click RPC "https://github.com/geph-official/gephgui-wry/blob/master/src/rpc.rs"
    click DaemonCtrl "https://github.com/geph-official/gephgui-wry/blob/master/src/daemon.rs"
    click AutoUpd "https://github.com/geph-official/gephgui-wry/blob/master/src/autoupdate.rs"
    click PAC "https://github.com/geph-official/gephgui-wry/blob/master/src/pac.rs"
    click MTBus "https://github.com/geph-official/gephgui-wry/blob/master/src/mtbus.rs"
    click FakeFS "https://github.com/geph-official/gephgui-wry/blob/master/src/fakefs.rs"
    click InitJS "https://github.com/geph-official/gephgui-wry/blob/master/src/init.js"
    click LinuxScript "https://github.com/geph-official/gephgui-wry/blob/master/src/linux-start-vpn.sh"
    click Config "https://github.com/geph-official/gephgui-wry/blob/master/Cargo.lock"
    click Config "https://github.com/geph-official/gephgui-wry/tree/master/.cargo/config"
```
