# luckjiawei/frpc-desktop architecture

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

- Interactive diagram: https://gitdiagram.com/luckjiawei/frpc-desktop
- Repository: https://github.com/luckjiawei/frpc-desktop

## Overview

##### Project type and purpose
- This is a cross-platform desktop application built with Electron.
- The renderer (frontend) is a Vue/Vite single‐page app providing a GUI for configuring and controlling FRP (Fast Reverse Proxy) clients.
- The main (backend) is an Electron Node process organizing controllers, services, repositories, and spawning FRP processes.

##### High-level architecture components
a. Renderer Process (UI Layer)
- Folder: /src – Vue components, views, router, store (Vuex), assets, styles
- Responsibilities: display pages (launch, proxy list, download, config, logger, about), send user commands via IPC
b. Preload Script (IPC Bridge)
- File: electron/preload/index.ts
- Exposes a safe API (ipcRenderer) to the renderer for requests like “start proxy,” “fetch config,” “download FRP.”
c. Main Process (Application Layer)
- Entry: electron/main/index.ts
- Controllers (electron/controller/*.ts): handle IPC events, route them to services
- IpcRouter (electron/core/IpcRouter.ts): central router for mapping IPC channels to controller methods
- Services (electron/service/*.ts): core business logic – FRPC process management, GitHub downloads, logging, system info
- Repositories (electron/repository/*.ts): file-based persistence of configs, versions, proxies
- Core & DI (electron/core/BeanFactory.ts + annotations): component management, dependency injection, global constants, error types
- Utils (electron/utils): file, path, security, response formatting, ID generation
d. External Processes & Services
- FRP client process (spawned by FrpcProcessService)
- GitHub API & mirror sites for downloading FRP releases
- Local file system for storing JSON configs & logs
- Python script (electron/json/extract.py) for preprocessing JSON data
e. Public Static & Configuration
- electron-builder.json5 – packaging config
- Vite, Tailwind, TypeScript configs

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer" 
        direction TB
        VueRenderer["Vue Renderer"]:::frontend
        Components["Components"]:::frontend
        Layout["Layout"]:::frontend
        Views["Views (Pages)"]:::frontend
        Router["Router"]:::frontend
        Store["Store (Vuex)"]:::frontend
        IPCUtils["IPC Utils (ipcUtils.ts)"]:::frontend
    end

    %% IPC Layer
    subgraph "IPC Layer" 
        direction TB
        Preload["Preload Script"]:::ipc
        IpcChannels["IPC Channels"]:::ipc
    end

    %% App Logic Layer
    subgraph "App Logic Layer" 
        direction TB
        IpcRouter["IpcRouter"]:::logic
        subgraph "Controllers" 
            direction TB
            BaseController["BaseController"]:::logic
            ConfigController["ConfigController"]:::logic
            LaunchController["LaunchController"]:::logic
            LogController["LogController"]:::logic
            ProxyController["ProxyController"]:::logic
            SystemController["SystemController"]:::logic
            VersionController["VersionController"]:::logic
        end
        subgraph "Services" 
            direction TB
            BaseService["BaseService"]:::logic
            FrpcProcessService["FrpcProcessService"]:::logic
            GitHubService["GitHubService"]:::logic
            LogService["LogService"]:::logic
            ProxyService["ProxyService"]:::logic
            ServerService["ServerService"]:::logic
            SystemService["SystemService"]:::logic
            VersionService["VersionService"]:::logic
        end
        subgraph "Repositories" 
            direction TB
            BaseRepository["BaseRepository"]:::logic
            ProxyRepository["ProxyRepository"]:::logic
            ServerRepository["ServerRepository"]:::logic
            VersionRepository["VersionRepository"]:::logic
        end
        subgraph "Core & DI" 
            direction TB
            BeanFactory["BeanFactory"]:::core
            GlobalConstant["GlobalConstant"]:::core
            BusinessError["BusinessError"]:::core
            Annotations["Annotations"]:::core
            Logger["Logger"]:::core
        end
        subgraph "Utils" 
            direction TB
            FileUtils["File Utils"]:::core
            PathUtils["Path Utils"]:::core
            SecurityUtils["Security Utils"]:::core
            ResponseUtils["Response Utils"]:::core
            IDUtils["ID Utils"]:::core
        end
    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        FRPProcess["FRP Client Process"]:::external
        GitHubAPI["GitHub API"]:::external
        FileSystem["Local File System"]:::external
        PythonScript["Python Extraction Script"]:::external
        JSONData["JSON Data Files"]:::external
    end

    %% Connections
    VueRenderer -->|click| Components
    VueRenderer -->|click| Layout
    VueRenderer -->|uses| Views
    VueRenderer -->|uses| Router
    VueRenderer -->|uses| Store
    Views -->|calls| IPCUtils
    IPCUtils -->|invokes| Preload
    Preload -->|sends| IpcChannels
    IpcChannels -->|mapped by| IpcRouter
    IpcRouter -->|routes to| ConfigController
    IpcRouter -->|routes to| LaunchController
    IpcRouter -->|routes to| LogController
    IpcRouter -->|routes to| ProxyController
    IpcRouter -->|routes to| SystemController
    IpcRouter -->|routes to| VersionController

    ConfigController -->|calls| ConfigController
    LaunchController -->|calls| FrpcProcessService
    LogController -->|calls| LogService
    ProxyController -->|calls| ProxyService
    SystemController -->|calls| SystemService
    VersionController -->|calls| VersionService

    FrpcProcessService -->|spawns| FRPProcess
    GitHubService -->|requests| GitHubAPI
    ProxyService -->|uses| ProxyRepository
    VersionService -->|uses| VersionRepository
    ServerService -->|uses| ServerRepository

    ConfigController -->|persists| BaseRepository
    FrpcProcessService -->|logs to| Logger
    LogService -->|writes to| FileSystem
    PythonScript -->|preprocesses| JSONData
    GitHubService -->|downloads to| FileSystem

    BeanFactory -->|injects into| Controllers
    BeanFactory -->|injects into| Services
    BeanFactory -->|injects into| Repositories

    %% Click Events
    click VueRenderer "https://github.com/luckjiawei/frpc-desktop/tree/main/src/"
    click Components "https://github.com/luckjiawei/frpc-desktop/tree/main/src/components/"
    click Layout "https://github.com/luckjiawei/frpc-desktop/tree/main/src/layout/"
    click Views "https://github.com/luckjiawei/frpc-desktop/tree/main/src/views/"
    click Router "https://github.com/luckjiawei/frpc-desktop/blob/main/src/router/index.ts"
    click Store "https://github.com/luckjiawei/frpc-desktop/blob/main/src/store/frpcDesktop.ts"
    click IPCUtils "https://github.com/luckjiawei/frpc-desktop/blob/main/src/utils/ipcUtils.ts"
    click Preload "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/preload/index.ts"
    click IpcRouter "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/core/IpcRouter.ts"
    click BaseController "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/controller/BaseController.ts"
    click ConfigController "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/controller/ConfigController.ts"
    click LaunchController "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/controller/LaunchController.ts"
    click LogController "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/controller/LogController.ts"
    click ProxyController "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/controller/ProxyController.ts"
    click SystemController "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/controller/SystemController.ts"
    click VersionController "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/controller/VersionController.ts"
    click BaseService "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/service/BaseService.ts"
    click FrpcProcessService "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/service/FrpcProcessService.ts"
    click GitHubService "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/service/GitHubService.ts"
    click LogService "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/service/LogService.ts"
    click ProxyService "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/service/ProxyService.ts"
    click ServerService "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/service/ServerService.ts"
    click SystemService "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/service/SystemService.ts"
    click VersionService "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/service/VersionService.ts"
    click BaseRepository "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/repository/BaseRepository.ts"
    click ProxyRepository "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/repository/ProxyRepository.ts"
    click ServerRepository "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/repository/ServerRepository.ts"
    click VersionRepository "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/repository/VersionRepository.ts"
    click BeanFactory "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/core/BeanFactory.ts"
    click GlobalConstant "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/core/GlobalConstant.ts"
    click BusinessError "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/core/BusinessError.ts"
    click Annotations "https://github.com/luckjiawei/frpc-desktop/tree/main/electron/core/annotation/"
    click Logger "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/core/Logger.ts"
    click FileUtils "https://github.com/luckjiawei/frpc-desktop/tree/main/electron/utils/"
    click PathUtils "https://github.com/luckjiawei/frpc-desktop/tree/main/electron/utils/"
    click SecurityUtils "https://github.com/luckjiawei/frpc-desktop/tree/main/electron/utils/"
    click ResponseUtils "https://github.com/luckjiawei/frpc-desktop/tree/main/electron/utils/"
    click IDUtils "https://github.com/luckjiawei/frpc-desktop/tree/main/electron/utils/"
    click PythonScript "https://github.com/luckjiawei/frpc-desktop/blob/main/electron/json/extract.py"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#004D40
    classDef ipc fill:#FFF9C4,stroke:#F57F17,color:#E65100
    classDef logic fill:#E8F5E9,stroke:#2E7D32,color:#1B5E20
    classDef core fill:#ECEFF1,stroke:#607D8B,color:#37474F
    classDef external fill:#FFE0B2,stroke:#E65100,color:#BF360C
```
