# sinalphabeta/flux-v2app architecture

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

- Interactive diagram: https://gitdiagram.com/sinalphabeta/flux-v2app
- Repository: https://github.com/sinalphabeta/flux-v2app

## Overview

Flux is a cross-platform Flutter V2Board client: users authenticate against a panel, inspect subscription plans and nodes, manage orders/account details, then connect through a unified VPN service. The connection layer selects platform-specific traffic handling and runs V2Ray/Xray. The README documents the iOS and desktop approaches; platform source excerpts are partial, so uncertain internal wiring is omitted.

Main entry points: [`lib/services/v2board_api.dart`](https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/v2board_api.dart) (V2Board API), [`lib/screens`](https://github.com/sinalphabeta/flux-v2app/tree/main/lib/screens) (Client screens), [`lib/services/platform_service.dart`](https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/platform_service.dart) (Platform selector), [`android/app/src/main/kotlin/com/flux/app/flux/MainActivity.kt`](https://github.com/sinalphabeta/flux-v2app/blob/main/android/app/src/main/kotlin/com/flux/app/flux/MainActivity.kt) (Android bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["Flutter app<br/>[main.dart]"]
  node_screens["Client screens"]
  node_account["User and plan models"]
end

subgraph group_panel["V2Board services"]
  node_api_config["API endpoint config<br/>[api_config.dart]"]
  node_api["V2Board API<br/>[v2board_api.dart]"]
  node_subscription["Subscription service"]
end

subgraph group_connect["Connection orchestration"]
  node_unified["Unified VPN service"]
  node_platform_service["Platform selector"]
  node_latency["Latency testing"]
end

subgraph group_platform["Platform traffic"]
  node_desktop["Desktop proxy"]
  node_v2ray["V2Ray service<br/>[v2ray_service.dart]"]
  node_win_v2ray["Windows V2Ray"]
  node_android_activity["Android bridge<br/>[MainActivity.kt]"]
  node_android_core["Android Xray core<br/>[libv2ray.aar]"]
  node_android_vpn["Android VPN service<br/>[FluxVpnService.kt]"]
  node_tproxy["TUN-to-SOCKS<br/>[FluxVpnService.kt]"]
  node_hev["HEV native bridge<br/>[TProxyService.kt]"]
  node_ios_manager["iOS VPN manager<br/>[VPNManager.swift]"]
  node_ios_tunnel["iOS packet tunnel"]
end

node_user(("User"))
node_panel_server(("V2Board panel"))
node_xray["Xray core"]
node_os_proxy["System proxy settings"]

node_user -->|"uses"| node_app
node_app -->|"presents"| node_screens
node_screens -->|"panel requests"| node_api
node_api -->|"gets endpoint"| node_api_config
node_api -->|"calls"| node_panel_server
node_api -->|"maps responses"| node_account
node_subscription -->|"fetches subscription"| node_api
node_screens -->|"loads subscription"| node_subscription
node_screens -->|"requests connection"| node_unified
node_unified -->|"selects platform"| node_platform_service
node_unified -->|"tests node latency"| node_latency
node_platform_service -->|"selects desktop proxy"| node_desktop
node_platform_service -->|"selects iOS VPN"| node_ios_manager
node_platform_service -->|"selects Android VPN"| node_android_activity
node_desktop -->|"starts core"| node_v2ray
node_desktop -->|"sets system proxy"| node_os_proxy
node_v2ray -->|"launches core"| node_xray
node_win_v2ray -->|"launches core"| node_xray
node_android_activity -->|"starts core"| node_android_core
node_android_activity -->|"starts VPN"| node_android_vpn
node_android_vpn -->|"starts forwarding"| node_tproxy
node_tproxy -->|"calls native methods"| node_hev
node_android_vpn -->|"emits status"| node_android_activity
node_ios_manager -->|"starts tunnel"| node_ios_tunnel

click node_app "https://github.com/sinalphabeta/flux-v2app/blob/main/lib/main.dart"
click node_screens "https://github.com/sinalphabeta/flux-v2app/tree/main/lib/screens"
click node_account "https://github.com/sinalphabeta/flux-v2app/tree/main/lib/models"
click node_api_config "https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/api_config.dart"
click node_api "https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/v2board_api.dart"
click node_subscription "https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/subscription_service.dart"
click node_unified "https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/unified_vpn_service.dart"
click node_platform_service "https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/platform_service.dart"
click node_latency "https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/latency_test_service.dart"
click node_desktop "https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/desktop_proxy_service.dart"
click node_v2ray "https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/v2ray_service.dart"
click node_win_v2ray "https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/v2ray_service_windows.dart"
click node_xray "https://github.com/sinalphabeta/flux-v2app/tree/main/assets/bin"
click node_android_activity "https://github.com/sinalphabeta/flux-v2app/blob/main/android/app/src/main/kotlin/com/flux/app/flux/MainActivity.kt"
click node_android_core "https://github.com/sinalphabeta/flux-v2app/blob/main/android/app/src/main/libs/libv2ray.aar"
click node_android_vpn "https://github.com/sinalphabeta/flux-v2app/blob/main/android/app/src/main/kotlin/com/flux/app/flux/FluxVpnService.kt"
click node_tproxy "https://github.com/sinalphabeta/flux-v2app/blob/main/android/app/src/main/kotlin/com/flux/app/flux/FluxVpnService.kt"
click node_hev "https://github.com/sinalphabeta/flux-v2app/blob/main/android/app/src/main/kotlin/hev/htproxy/TProxyService.kt"
click node_ios_manager "https://github.com/sinalphabeta/flux-v2app/blob/main/ios/Runner/VPNManager.swift"
click node_ios_tunnel "https://github.com/sinalphabeta/flux-v2app/blob/main/ios/Runner/PacketTunnelProvider.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_app,node_screens,node_account,node_user toneBlue
class node_api_config,node_api,node_subscription toneAmber
class node_unified,node_platform_service,node_latency toneMint
class node_desktop,node_v2ray,node_win_v2ray,node_android_activity,node_android_core,node_android_vpn,node_tproxy,node_hev,node_ios_manager,node_ios_tunnel toneRose
class node_panel_server,node_os_proxy toneIndigo
class node_xray toneTeal
```

## Components

### Client experience

- [Flutter app](https://github.com/sinalphabeta/flux-v2app/blob/main/lib/main.dart): `lib/main.dart`
- [Client screens](https://github.com/sinalphabeta/flux-v2app/tree/main/lib/screens): `lib/screens`
- [User and plan models](https://github.com/sinalphabeta/flux-v2app/tree/main/lib/models): `lib/models`

### V2Board services

- [API endpoint config](https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/api_config.dart): `lib/services/api_config.dart`
- [V2Board API](https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/v2board_api.dart): `lib/services/v2board_api.dart`
- [Subscription service](https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/subscription_service.dart): `lib/services/subscription_service.dart`

### Connection orchestration

- [Unified VPN service](https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/unified_vpn_service.dart): `lib/services/unified_vpn_service.dart`
- [Platform selector](https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/platform_service.dart): `lib/services/platform_service.dart`
- [Latency testing](https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/latency_test_service.dart): `lib/services/latency_test_service.dart`

### Platform traffic

- [Desktop proxy](https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/desktop_proxy_service.dart): `lib/services/desktop_proxy_service.dart`
- [V2Ray service](https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/v2ray_service.dart): `lib/services/v2ray_service.dart`
- [Windows V2Ray](https://github.com/sinalphabeta/flux-v2app/blob/main/lib/services/v2ray_service_windows.dart): `lib/services/v2ray_service_windows.dart`
- [Android bridge](https://github.com/sinalphabeta/flux-v2app/blob/main/android/app/src/main/kotlin/com/flux/app/flux/MainActivity.kt): `android/app/src/main/kotlin/com/flux/app/flux/MainActivity.kt`
- [Android Xray core](https://github.com/sinalphabeta/flux-v2app/blob/main/android/app/src/main/libs/libv2ray.aar): `android/app/src/main/libs/libv2ray.aar`
- [Android VPN service](https://github.com/sinalphabeta/flux-v2app/blob/main/android/app/src/main/kotlin/com/flux/app/flux/FluxVpnService.kt): `android/app/src/main/kotlin/com/flux/app/flux/FluxVpnService.kt`
- [TUN-to-SOCKS](https://github.com/sinalphabeta/flux-v2app/blob/main/android/app/src/main/kotlin/com/flux/app/flux/FluxVpnService.kt): `android/app/src/main/kotlin/com/flux/app/flux/FluxVpnService.kt`
- [HEV native bridge](https://github.com/sinalphabeta/flux-v2app/blob/main/android/app/src/main/kotlin/hev/htproxy/TProxyService.kt): `android/app/src/main/kotlin/hev/htproxy/TProxyService.kt`
- [iOS VPN manager](https://github.com/sinalphabeta/flux-v2app/blob/main/ios/Runner/VPNManager.swift): `ios/Runner/VPNManager.swift`
- [iOS packet tunnel](https://github.com/sinalphabeta/flux-v2app/blob/main/ios/Runner/PacketTunnelProvider.swift): `ios/Runner/PacketTunnelProvider.swift`

### Other components

- **User**
- **V2Board panel**
- [Xray core](https://github.com/sinalphabeta/flux-v2app/tree/main/assets/bin): `assets/bin`
- **System proxy settings**

## Connections

- User → Flutter app: uses
- Flutter app → Client screens: presents
- Client screens → V2Board API: panel requests
- V2Board API → API endpoint config: gets endpoint
- V2Board API → V2Board panel: calls
- V2Board API → User and plan models: maps responses
- Subscription service → V2Board API: fetches subscription
- Client screens → Subscription service: loads subscription
- Client screens → Unified VPN service: requests connection
- Unified VPN service → Platform selector: selects platform
- Unified VPN service → Latency testing: tests node latency
- Platform selector → Desktop proxy: selects desktop proxy
- Platform selector → iOS VPN manager: selects iOS VPN
- Platform selector → Android bridge: selects Android VPN
- Desktop proxy → V2Ray service: starts core
- Desktop proxy → System proxy settings: sets system proxy
- V2Ray service → Xray core: launches core
- Windows V2Ray → Xray core: launches core
- Android bridge → Android Xray core: starts core
- Android bridge → Android VPN service: starts VPN
- Android VPN service → TUN-to-SOCKS: starts forwarding
- TUN-to-SOCKS → HEV native bridge: calls native methods
- Android VPN service → Android bridge: emits status
- iOS VPN manager → iOS packet tunnel: starts tunnel
