# goresense/gorebox architecture

> Architecture diagram of the GitHub repository goresense/gorebox, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/goresense/gorebox
- Repository: https://github.com/goresense/gorebox

## Overview

GoreBox is a Windows WPF proxy/VPN client that manages connection profiles and routing, builds sing-box configuration, then starts the vendored nekobox_core over authenticated local gRPC or falls back to `run -c`. Its runtime supports proxy/TUN operation, traffic statistics and latency via Clash API, plus profile/rule storage, updates, and DPI-bypass tooling. The README documents the main launch contract and protocol capabilities; source excerpts show selected storage, startup, routing, and DPI behavior, not the full application wiring.

Main entry points: [`src/GoreBox/ViewModels/MainViewModel.cs`](https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/ViewModels/MainViewModel.cs) (Main UI), [`src/GoreBox/Services/CoreService.cs`](https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/CoreService.cs) (Core lifecycle), [`core/sing-box/box.go`](https://github.com/goresense/gorebox/blob/Windows/core/sing-box/box.go) (sing-box engine), [`src/GoreBox/App.xaml.cs`](https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/App.xaml.cs) (App startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client workflow"]
  node_app["App startup<br/>[App.xaml.cs]"]
  node_mainui["Main UI<br/>[MainViewModel.cs]"]
  node_import["Profile import<br/>[LinkParser.cs]"]
  node_config["Config builder"]
end

subgraph group_data["Profiles and settings"]
  node_profile["Profile model<br/>[ProxyProfile.cs]"]
  node_rules["Routing editor"]
  node_routestore[("Route storage<br/>[RouteStore.cs]")]
  node_storage["Data location<br/>[StorageLocation.cs]"]
end

subgraph group_runtime["Proxy runtime"]
  node_corectl["Core lifecycle<br/>[CoreService.cs]"]
  node_rpc["Core RPC client"]
  node_coreentry["nekobox entry<br/>[main.go]"]
  node_grpcbox["gRPC service mode<br/>[grpc_box.go]"]
  node_singbox["sing-box engine<br/>[box.go]"]
  node_inbounds["Proxy inbounds<br/>[builder.go]"]
  node_routing["Traffic routing<br/>[router.go]"]
  node_outbounds["Proxy outbounds<br/>[builder.go]"]
  node_tun["TUN service<br/>[tun.go]"]
end

subgraph group_diagnostics["Diagnostics and operations"]
  node_latency["Latency tests<br/>[LatencyService.cs]"]
  node_clash["Clash API<br/>[server.go]"]
  node_dpi["DPI bypass<br/>[DpiBypassEngine.cs]"]
  node_updates["App updates"]
end

node_user(("User"))
node_corebinary["Core binary"]

node_user -->|"manages connections"| node_mainui
node_app -->|"initializes data"| node_storage
node_app -->|"opens window"| node_mainui
node_mainui -->|"imports profiles"| node_import
node_import -->|"creates profiles"| node_profile
node_mainui -->|"builds configuration"| node_config
node_profile -->|"converts profile"| node_config
node_mainui -->|"starts core"| node_corectl
node_config -->|"supplies JSON"| node_corectl
node_corectl -->|"uses gRPC client"| node_rpc
node_rpc -->|"sends commands"| node_grpcbox
node_corectl -.->|"launches fallback"| node_corebinary
node_corebinary -->|"runs nekobox mode"| node_coreentry
node_coreentry -.->|"dispatches mode"| node_grpcbox
node_grpcbox -.->|"controls engine"| node_singbox
node_singbox -.->|"starts listeners"| node_inbounds
node_singbox -.->|"routes traffic"| node_routing
node_routing -.->|"selects egress"| node_outbounds
node_singbox -.->|"supports TUN"| node_tun
node_mainui -.->|"edits routing"| node_rules
node_rules -->|"loads and saves"| node_routestore
node_mainui -->|"tests profiles"| node_latency
node_latency -->|"tests core proxy"| node_corectl
node_mainui -.->|"reads statistics"| node_clash
node_mainui -.->|"configures bypass"| node_dpi
node_app -->|"cleans old executable"| node_updates

click node_app "https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/App.xaml.cs"
click node_mainui "https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/ViewModels/MainViewModel.cs"
click node_profile "https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Models/ProxyProfile.cs"
click node_import "https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Utils/LinkParser.cs"
click node_config "https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/SingBoxConfigBuilder.cs"
click node_corectl "https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/CoreService.cs"
click node_rpc "https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/NekoCoreRpcClient.cs"
click node_coreentry "https://github.com/goresense/gorebox/blob/Windows/core/nekoray/go/cmd/nekobox_core/main.go"
click node_grpcbox "https://github.com/goresense/gorebox/blob/Windows/core/nekoray/go/cmd/nekobox_core/grpc_box.go"
click node_singbox "https://github.com/goresense/gorebox/blob/Windows/core/sing-box/box.go"
click node_inbounds "https://github.com/goresense/gorebox/blob/Windows/core/sing-box/inbound/builder.go"
click node_routing "https://github.com/goresense/gorebox/blob/Windows/core/sing-box/route/router.go"
click node_outbounds "https://github.com/goresense/gorebox/blob/Windows/core/sing-box/outbound/builder.go"
click node_tun "https://github.com/goresense/gorebox/blob/Windows/core/sing-box/experimental/libbox/tun.go"
click node_rules "https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/ViewModels/RoutingViewModel.cs"
click node_routestore "https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/RouteStore.cs"
click node_storage "https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/StorageLocation.cs"
click node_latency "https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/LatencyService.cs"
click node_clash "https://github.com/goresense/gorebox/blob/Windows/core/sing-box/experimental/clashapi/server.go"
click node_dpi "https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/DpiBypassEngine.cs"
click node_updates "https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/AppUpdateService.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_mainui,node_import,node_config,node_user toneBlue
class node_profile,node_rules,node_routestore,node_storage toneAmber
class node_corectl,node_rpc,node_coreentry,node_grpcbox,node_singbox,node_inbounds,node_routing,node_outbounds,node_tun toneMint
class node_latency,node_clash,node_dpi,node_updates toneRose
class node_corebinary toneIndigo
```

## Components

### Client workflow

- [App startup](https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/App.xaml.cs): `src/GoreBox/App.xaml.cs`
- [Main UI](https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/ViewModels/MainViewModel.cs): `src/GoreBox/ViewModels/MainViewModel.cs`
- [Profile import](https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Utils/LinkParser.cs): `src/GoreBox/Utils/LinkParser.cs`
- [Config builder](https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/SingBoxConfigBuilder.cs): `src/GoreBox/Services/SingBoxConfigBuilder.cs`

### Profiles and settings

- [Profile model](https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Models/ProxyProfile.cs): `src/GoreBox/Models/ProxyProfile.cs`
- [Routing editor](https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/ViewModels/RoutingViewModel.cs): `src/GoreBox/ViewModels/RoutingViewModel.cs`
- [Route storage](https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/RouteStore.cs): `src/GoreBox/Services/RouteStore.cs`
- [Data location](https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/StorageLocation.cs): `src/GoreBox/Services/StorageLocation.cs`

### Proxy runtime

- [Core lifecycle](https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/CoreService.cs): `src/GoreBox/Services/CoreService.cs`
- [Core RPC client](https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/NekoCoreRpcClient.cs): `src/GoreBox/Services/NekoCoreRpcClient.cs`
- [nekobox entry](https://github.com/goresense/gorebox/blob/Windows/core/nekoray/go/cmd/nekobox_core/main.go): `core/nekoray/go/cmd/nekobox_core/main.go`
- [gRPC service mode](https://github.com/goresense/gorebox/blob/Windows/core/nekoray/go/cmd/nekobox_core/grpc_box.go): `core/nekoray/go/cmd/nekobox_core/grpc_box.go`
- [sing-box engine](https://github.com/goresense/gorebox/blob/Windows/core/sing-box/box.go): `core/sing-box/box.go`
- [Proxy inbounds](https://github.com/goresense/gorebox/blob/Windows/core/sing-box/inbound/builder.go): `core/sing-box/inbound/builder.go`
- [Traffic routing](https://github.com/goresense/gorebox/blob/Windows/core/sing-box/route/router.go): `core/sing-box/route/router.go`
- [Proxy outbounds](https://github.com/goresense/gorebox/blob/Windows/core/sing-box/outbound/builder.go): `core/sing-box/outbound/builder.go`
- [TUN service](https://github.com/goresense/gorebox/blob/Windows/core/sing-box/experimental/libbox/tun.go): `core/sing-box/experimental/libbox/tun.go`

### Diagnostics and operations

- [Latency tests](https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/LatencyService.cs): `src/GoreBox/Services/LatencyService.cs`
- [Clash API](https://github.com/goresense/gorebox/blob/Windows/core/sing-box/experimental/clashapi/server.go): `core/sing-box/experimental/clashapi/server.go`
- [DPI bypass](https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/DpiBypassEngine.cs): `src/GoreBox/Services/DpiBypassEngine.cs`
- [App updates](https://github.com/goresense/gorebox/blob/Windows/src/GoreBox/Services/AppUpdateService.cs): `src/GoreBox/Services/AppUpdateService.cs`

### Other components

- **User**
- **Core binary**

## Connections

- User → Main UI: manages connections (evidence: `README.md`)
- App startup → Data location: initializes data (evidence: `src/GoreBox/App.xaml.cs`)
- App startup → Main UI: opens window (evidence: `src/GoreBox/App.xaml.cs`)
- Main UI → Profile import: imports profiles (evidence: `README.md`)
- Profile import → Profile model: creates profiles (evidence: `README.md`)
- Main UI → Config builder: builds configuration (evidence: `README.md`)
- Profile model → Config builder: converts profile (evidence: `README.md`)
- Main UI → Core lifecycle: starts core (evidence: `README.md`)
- Config builder → Core lifecycle: supplies JSON (evidence: `README.md`)
- Core lifecycle → Core RPC client: uses gRPC client (evidence: `README.md`)
- Core RPC client → gRPC service mode: sends commands (evidence: `README.md`)
- Core lifecycle → Core binary: launches fallback (evidence: `README.md`)
- Core binary → nekobox entry: runs nekobox mode (evidence: `README.md`)
- nekobox entry → gRPC service mode: dispatches mode
- gRPC service mode → sing-box engine: controls engine
- sing-box engine → Proxy inbounds: starts listeners
- sing-box engine → Traffic routing: routes traffic
- Traffic routing → Proxy outbounds: selects egress
- sing-box engine → TUN service: supports TUN (evidence: `README.md`)
- Main UI → Routing editor: edits routing
- Routing editor → Route storage: loads and saves (evidence: `src/GoreBox/ViewModels/RoutingViewModel.cs`)
- Main UI → Latency tests: tests profiles
- Latency tests → Core lifecycle: tests core proxy (evidence: `src/GoreBox/Services/LatencyService.cs`)
- Main UI → Clash API: reads statistics (evidence: `README.md`)
- Main UI → DPI bypass: configures bypass
- App startup → App updates: cleans old executable (evidence: `src/GoreBox/App.xaml.cs`)
