# appshubcc/bettbox architecture

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

- Interactive diagram: https://gitdiagram.com/appshubcc/bettbox
- Repository: https://github.com/appshubcc/bettbox

## Overview

Bettbox is a cross-platform Mihomo client for proxy routing and DNS troubleshooting. Its intended user workflow is to configure or import a profile, start the core through the client, route traffic through a VPN/TUN or proxy, and inspect operational state. The supplied tree and excerpts show Android service integration, the Go core, and selected native plugins; the Flutter UI and profile-import implementation are not represented in the supplied source excerpts, so those links are limited to documented behavior or marked unverified.

Main entry points: [`core/Clash.Meta/main.go`](https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/main.go) (Core entry), [`android/app/src/main/kotlin/com/appshub/bettbox/plugins/VpnPlugin.kt`](https://github.com/appshubcc/bettbox/blob/main/android/app/src/main/kotlin/com/appshub/bettbox/plugins/VpnPlugin.kt) (Android VPN bridge), [`android/app/src/main/kotlin/com/appshub/bettbox/services/BettboxVpnService.kt`](https://github.com/appshubcc/bettbox/blob/main/android/app/src/main/kotlin/com/appshub/bettbox/services/BettboxVpnService.kt) (Android VPN service), [`android/app/src/main/kotlin/com/appshub/bettbox/GlobalState.kt`](https://github.com/appshubcc/bettbox/blob/main/android/app/src/main/kotlin/com/appshub/bettbox/GlobalState.kt) (Android run state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client runtime"]
  node_clientui["Client UI"]
  node_profiles["Profiles and settings<br/>[profile.go]"]
end

subgraph group_engine["Mihomo engine"]
  node_coreentry["Core entry<br/>[main.go]"]
  node_config["Configuration loading<br/>[config.go]"]
  node_inbound["Inbound listeners<br/>[listen.go]"]
  node_routing["Proxy routing<br/>[manager.go]"]
  node_outbound["Outbound adapters<br/>[base.go]"]
  node_dns["DNS services<br/>[server.go]"]
  node_api["Control API<br/>[server.go]"]
  node_tun["TUN integration<br/>[tun.go]"]
end

subgraph group_platform["Platform services"]
  node_androidvpn["Android VPN bridge<br/>[VpnPlugin.kt]"]
  node_androidservice["Android VPN service"]
  node_appstate["Android run state<br/>[GlobalState.kt]"]
  node_androidnotify["Foreground service<br/>[BettboxService.kt]"]
  node_tile["Quick settings tile"]
end

subgraph group_extensions["Client extensions"]
  node_editor["Code editor<br/>[editor.rs]"]
  node_scripts["JS customization<br/>[ffi.cpp]"]
  node_tray["Desktop tray"]
end

node_user(("User"))

node_user -.->|"configures"| node_clientui
node_clientui -.->|"selects profile"| node_profiles
node_profiles -.->|"configures"| node_coreentry
node_clientui -.->|"starts VPN"| node_androidvpn
node_androidvpn -->|"starts service"| node_androidservice
node_androidvpn -->|"updates state"| node_appstate
node_androidservice -->|"reads state"| node_appstate
node_tile -->|"toggles run state"| node_appstate
node_androidservice -.->|"uses service interface"| node_androidnotify
node_coreentry -.->|"loads config"| node_config
node_coreentry -.->|"starts listeners"| node_inbound
node_inbound -.->|"dispatches traffic"| node_routing
node_routing -.->|"selects proxy"| node_outbound
node_coreentry -.->|"starts DNS"| node_dns
node_coreentry -.->|"starts control API"| node_api
node_androidvpn -.->|"provides VPN interface"| node_tun
node_user -.->|"edits configuration"| node_editor
node_user -.->|"customizes UI"| node_scripts
node_clientui -.->|"controls tray"| node_tray

click node_profiles "https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/component/profile/profile.go"
click node_androidvpn "https://github.com/appshubcc/bettbox/blob/main/android/app/src/main/kotlin/com/appshub/bettbox/plugins/VpnPlugin.kt"
click node_androidservice "https://github.com/appshubcc/bettbox/blob/main/android/app/src/main/kotlin/com/appshub/bettbox/services/BettboxVpnService.kt"
click node_appstate "https://github.com/appshubcc/bettbox/blob/main/android/app/src/main/kotlin/com/appshub/bettbox/GlobalState.kt"
click node_androidnotify "https://github.com/appshubcc/bettbox/blob/main/android/app/src/main/kotlin/com/appshub/bettbox/services/BettboxService.kt"
click node_tile "https://github.com/appshubcc/bettbox/blob/main/android/app/src/main/kotlin/com/appshub/bettbox/services/BettboxTileService.kt"
click node_coreentry "https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/main.go"
click node_config "https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/config/config.go"
click node_inbound "https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/adapter/inbound/listen.go"
click node_routing "https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/tunnel/statistic/manager.go"
click node_outbound "https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/adapter/outbound/base.go"
click node_dns "https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/dns/server.go"
click node_api "https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/hub/route/server.go"
click node_tun "https://github.com/appshubcc/bettbox/blob/main/core/tun/tun.go"
click node_editor "https://github.com/appshubcc/bettbox/blob/main/plugins/code_forge/rust/src/api/editor.rs"
click node_scripts "https://github.com/appshubcc/bettbox/blob/main/plugins/flutter_qjs/cxx/ffi.cpp"
click node_tray "https://github.com/appshubcc/bettbox/blob/main/plugins/tray_manager/macos/Classes/TrayManagerPlugin.swift"

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_clientui,node_profiles,node_user toneBlue
class node_coreentry,node_config,node_inbound,node_routing,node_outbound,node_dns,node_api,node_tun toneAmber
class node_androidvpn,node_androidservice,node_appstate,node_androidnotify,node_tile toneMint
class node_editor,node_scripts,node_tray toneRose
```

## Components

### Client runtime

- **Client UI**
- [Profiles and settings](https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/component/profile/profile.go): `core/Clash.Meta/component/profile/profile.go`

### Mihomo engine

- [Core entry](https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/main.go): `core/Clash.Meta/main.go`
- [Configuration loading](https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/config/config.go): `core/Clash.Meta/config/config.go`
- [Inbound listeners](https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/adapter/inbound/listen.go): `core/Clash.Meta/adapter/inbound/listen.go`
- [Proxy routing](https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/tunnel/statistic/manager.go): `core/Clash.Meta/tunnel/statistic/manager.go`
- [Outbound adapters](https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/adapter/outbound/base.go): `core/Clash.Meta/adapter/outbound/base.go`
- [DNS services](https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/dns/server.go): `core/Clash.Meta/dns/server.go`
- [Control API](https://github.com/appshubcc/bettbox/blob/main/core/Clash.Meta/hub/route/server.go): `core/Clash.Meta/hub/route/server.go`
- [TUN integration](https://github.com/appshubcc/bettbox/blob/main/core/tun/tun.go): `core/tun/tun.go`

### Platform services

- [Android VPN bridge](https://github.com/appshubcc/bettbox/blob/main/android/app/src/main/kotlin/com/appshub/bettbox/plugins/VpnPlugin.kt): `android/app/src/main/kotlin/com/appshub/bettbox/plugins/VpnPlugin.kt`
- [Android VPN service](https://github.com/appshubcc/bettbox/blob/main/android/app/src/main/kotlin/com/appshub/bettbox/services/BettboxVpnService.kt): `android/app/src/main/kotlin/com/appshub/bettbox/services/BettboxVpnService.kt`
- [Android run state](https://github.com/appshubcc/bettbox/blob/main/android/app/src/main/kotlin/com/appshub/bettbox/GlobalState.kt): `android/app/src/main/kotlin/com/appshub/bettbox/GlobalState.kt`
- [Foreground service](https://github.com/appshubcc/bettbox/blob/main/android/app/src/main/kotlin/com/appshub/bettbox/services/BettboxService.kt): `android/app/src/main/kotlin/com/appshub/bettbox/services/BettboxService.kt`
- [Quick settings tile](https://github.com/appshubcc/bettbox/blob/main/android/app/src/main/kotlin/com/appshub/bettbox/services/BettboxTileService.kt): `android/app/src/main/kotlin/com/appshub/bettbox/services/BettboxTileService.kt`

### Client extensions

- [Code editor](https://github.com/appshubcc/bettbox/blob/main/plugins/code_forge/rust/src/api/editor.rs): `plugins/code_forge/rust/src/api/editor.rs`
- [JS customization](https://github.com/appshubcc/bettbox/blob/main/plugins/flutter_qjs/cxx/ffi.cpp): `plugins/flutter_qjs/cxx/ffi.cpp`
- [Desktop tray](https://github.com/appshubcc/bettbox/blob/main/plugins/tray_manager/macos/Classes/TrayManagerPlugin.swift): `plugins/tray_manager/macos/Classes/TrayManagerPlugin.swift`

### Other components

- **User**

## Connections

- User → Client UI: configures (evidence: `README.md`)
- Client UI → Profiles and settings: selects profile (evidence: `README.md`)
- Profiles and settings → Core entry: configures (evidence: `README.md`)
- Client UI → Android VPN bridge: starts VPN (evidence: `README.md`)
- Android VPN bridge → Android VPN service: starts service (evidence: `android/app/src/main/kotlin/com/appshub/bettbox/plugins/VpnPlugin.kt`)
- Android VPN bridge → Android run state: updates state (evidence: `android/app/src/main/kotlin/com/appshub/bettbox/plugins/VpnPlugin.kt`)
- Android VPN service → Android run state: reads state (evidence: `android/app/src/main/kotlin/com/appshub/bettbox/services/BettboxVpnService.kt`)
- Quick settings tile → Android run state: toggles run state (evidence: `android/app/src/main/kotlin/com/appshub/bettbox/services/BettboxTileService.kt`)
- Android VPN service → Foreground service: uses service interface
- Core entry → Configuration loading: loads config
- Core entry → Inbound listeners: starts listeners
- Inbound listeners → Proxy routing: dispatches traffic
- Proxy routing → Outbound adapters: selects proxy
- Core entry → DNS services: starts DNS
- Core entry → Control API: starts control API
- Android VPN bridge → TUN integration: provides VPN interface
- User → Code editor: edits configuration (evidence: `README.md`)
- User → JS customization: customizes UI (evidence: `README.md`)
- Client UI → Desktop tray: controls tray
