# amiercassanova-21/apk-cassanova-tunnel architecture

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

- Interactive diagram: https://gitdiagram.com/amiercassanova-21/apk-cassanova-tunnel
- Repository: https://github.com/amiercassanova-21/apk-cassanova-tunnel

## Overview

Amier VPN is an Android tunneling client built around Xray-based proxy profiles, with added SSH/SlowDNS tunnels and a separate Wi-Fi tethering feature. The main user journey is to import or configure a profile, select it, start a connection, and route traffic through the Android VPN or proxy service. The graph preserves subscription, routing, diagnostics, and tethering branches. Some links are dashed where the supplied excerpts and README do not establish the runtime caller; unsampled implementations are not treated as inspected.

Main entry points: [`V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreServiceManager.kt`](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreServiceManager.kt) (Core service manager), [`V2rayNG/app/src/main/java/com/v2ray/ang/ui/main/MainActivity.kt`](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/ui/main/MainActivity.kt) (Main screen), [`V2rayNG/tether/src/main/java/com/amier/tether/TetherVpnService.kt`](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/tether/src/main/java/com/amier/tether/TetherVpnService.kt) (Tether VPN), [`V2rayNG/app/src/main/java/com/v2ray/ang/handler/MmkvManager.kt`](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/handler/MmkvManager.kt) (Profile settings store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_profiles["Profiles and setup"]
  node_profileedit["Profile editors"]
  node_formats["Profile formats"]
  node_profile["Profile model<br/>[ProfileItem.kt]"]
  node_subscriptions["Subscriptions"]
  node_store[("Profile settings store<br/>[MmkvManager.kt]")]
  node_routingui["Routing editor"]
  node_routing["Routing settings<br/>[SettingsManager.kt]"]
end

subgraph group_connection["Connection runtime"]
  node_config["Core config builder"]
  node_coremanager["Core service manager"]
  node_vpnservice["VPN service<br/>[CoreVpnService.kt]"]
  node_rootproxy["Root proxy mode"]
  node_sshmanager["SSH tunnel manager"]
  node_sshengine["SSH tunnel engines<br/>[SshTunnel.kt]"]
  node_dialer["Browser dialer"]
end

subgraph group_features["Network features"]
  node_tetherui["Tether controls<br/>[MainActivity.kt]"]
  node_tetherservice["Tether VPN"]
  node_proxyfinder["Proxy discovery<br/>[ProxyFinder.kt]"]
  node_tproxy["Transparent proxy<br/>[TProxyService.kt]"]
  node_diagnostics["Connection diagnostics"]
end

subgraph group_appui["App experience"]
  node_mainui["Main screen<br/>[MainActivity.kt]"]
  node_traffic["Traffic and status<br/>[TrafficTracker.kt]"]
  node_notifications["Notifications"]
end

node_user(("User"))
node_xray["Xray core"]
node_androidvpn["Android VPN"]
node_network(("Wi-Fi network"))

node_user -->|"opens"| node_mainui
node_mainui -.->|"configures"| node_profileedit
node_profileedit -.->|"encodes profiles"| node_formats
node_formats -.->|"produces"| node_profile
node_subscriptions -.->|"updates profiles"| node_store
node_profile -->|"persists as"| node_store
node_routingui -->|"edits rules"| node_routing
node_mainui -.->|"starts connection"| node_coremanager
node_coremanager -.->|"builds config"| node_config
node_coremanager -->|"starts tunnel"| node_sshmanager
node_coremanager -->|"reads settings"| node_store
node_sshmanager -->|"reads profile"| node_profile
node_sshmanager -->|"starts engine"| node_sshengine
node_vpnservice -->|"delegates lifecycle"| node_coremanager
node_vpnservice -.->|"establishes tunnel"| node_androidvpn
node_coremanager -.->|"controls core"| node_xray
node_rootproxy -->|"reads settings"| node_store
node_mainui -.->|"manages subscriptions"| node_subscriptions
node_mainui -.->|"opens routing"| node_routingui
node_coremanager -.->|"updates status"| node_notifications
node_notifications -->|"reads traffic"| node_traffic
node_mainui -.->|"runs tests"| node_diagnostics
node_user -.->|"starts tethering"| node_tetherui
node_tetherui -->|"controls service"| node_tetherservice
node_tetherservice -->|"finds proxy"| node_proxyfinder
node_tetherservice -->|"reads proxy stats"| node_tproxy
node_tetherservice -->|"monitors Wi-Fi"| node_network
node_dialer -.->|"uses WebSockets"| node_network

click node_mainui "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/ui/main/MainActivity.kt"
click node_profileedit "https://github.com/amiercassanova-21/apk-cassanova-tunnel/tree/main/V2rayNG/app/src/main/java/com/v2ray/ang/ui/server"
click node_formats "https://github.com/amiercassanova-21/apk-cassanova-tunnel/tree/main/V2rayNG/app/src/main/java/com/v2ray/ang/fmt"
click node_profile "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/dto/entities/ProfileItem.kt"
click node_subscriptions "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SubscriptionUpdater.kt"
click node_store "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/handler/MmkvManager.kt"
click node_routingui "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/ui/routing/RoutingSettingActivity.kt"
click node_routing "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SettingsManager.kt"
click node_config "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreConfigManager.kt"
click node_coremanager "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreServiceManager.kt"
click node_vpnservice "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreVpnService.kt"
click node_rootproxy "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/root/RootProxyManager.kt"
click node_sshmanager "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/core/ssh/SshTunnelManager.kt"
click node_sshengine "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/core/ssh/SshTunnel.kt"
click node_dialer "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/service/DialerNativeService.kt"
click node_tetherui "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/tether/src/main/java/com/amier/tether/MainActivity.kt"
click node_tetherservice "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/tether/src/main/java/com/amier/tether/TetherVpnService.kt"
click node_proxyfinder "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/tether/src/main/java/com/amier/tether/ProxyFinder.kt"
click node_tproxy "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/tether/src/main/java/com/v2ray/ang/service/TProxyService.kt"
click node_diagnostics "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SpeedtestManager.kt"
click node_traffic "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/handler/TrafficTracker.kt"
click node_notifications "https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/handler/NotificationManager.kt"

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_profileedit,node_formats,node_profile,node_subscriptions,node_store,node_routingui,node_routing,node_user toneBlue
class node_config,node_coremanager,node_vpnservice,node_rootproxy,node_sshmanager,node_sshengine,node_dialer toneAmber
class node_tetherui,node_tetherservice,node_proxyfinder,node_tproxy,node_diagnostics toneMint
class node_mainui,node_traffic,node_notifications toneRose
class node_xray,node_androidvpn,node_network toneIndigo
```

## Components

### Profiles and setup

- [Profile editors](https://github.com/amiercassanova-21/apk-cassanova-tunnel/tree/main/V2rayNG/app/src/main/java/com/v2ray/ang/ui/server): `V2rayNG/app/src/main/java/com/v2ray/ang/ui/server`
- [Profile formats](https://github.com/amiercassanova-21/apk-cassanova-tunnel/tree/main/V2rayNG/app/src/main/java/com/v2ray/ang/fmt): `V2rayNG/app/src/main/java/com/v2ray/ang/fmt`
- [Profile model](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/dto/entities/ProfileItem.kt): `V2rayNG/app/src/main/java/com/v2ray/ang/dto/entities/ProfileItem.kt`
- [Subscriptions](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SubscriptionUpdater.kt): `V2rayNG/app/src/main/java/com/v2ray/ang/handler/SubscriptionUpdater.kt`
- [Profile settings store](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/handler/MmkvManager.kt): `V2rayNG/app/src/main/java/com/v2ray/ang/handler/MmkvManager.kt`
- [Routing editor](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/ui/routing/RoutingSettingActivity.kt): `V2rayNG/app/src/main/java/com/v2ray/ang/ui/routing/RoutingSettingActivity.kt`
- [Routing settings](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SettingsManager.kt): `V2rayNG/app/src/main/java/com/v2ray/ang/handler/SettingsManager.kt`

### Connection runtime

- [Core config builder](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreConfigManager.kt): `V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreConfigManager.kt`
- [Core service manager](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreServiceManager.kt): `V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreServiceManager.kt`
- [VPN service](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreVpnService.kt): `V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreVpnService.kt`
- [Root proxy mode](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/root/RootProxyManager.kt): `V2rayNG/app/src/main/java/com/v2ray/ang/root/RootProxyManager.kt`
- [SSH tunnel manager](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/core/ssh/SshTunnelManager.kt): `V2rayNG/app/src/main/java/com/v2ray/ang/core/ssh/SshTunnelManager.kt`
- [SSH tunnel engines](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/core/ssh/SshTunnel.kt): `V2rayNG/app/src/main/java/com/v2ray/ang/core/ssh/SshTunnel.kt`
- [Browser dialer](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/service/DialerNativeService.kt): `V2rayNG/app/src/main/java/com/v2ray/ang/service/DialerNativeService.kt`

### Network features

- [Tether controls](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/tether/src/main/java/com/amier/tether/MainActivity.kt): `V2rayNG/tether/src/main/java/com/amier/tether/MainActivity.kt`
- [Tether VPN](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/tether/src/main/java/com/amier/tether/TetherVpnService.kt): `V2rayNG/tether/src/main/java/com/amier/tether/TetherVpnService.kt`
- [Proxy discovery](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/tether/src/main/java/com/amier/tether/ProxyFinder.kt): `V2rayNG/tether/src/main/java/com/amier/tether/ProxyFinder.kt`
- [Transparent proxy](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/tether/src/main/java/com/v2ray/ang/service/TProxyService.kt): `V2rayNG/tether/src/main/java/com/v2ray/ang/service/TProxyService.kt`
- [Connection diagnostics](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SpeedtestManager.kt): `V2rayNG/app/src/main/java/com/v2ray/ang/handler/SpeedtestManager.kt`

### App experience

- [Main screen](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/ui/main/MainActivity.kt): `V2rayNG/app/src/main/java/com/v2ray/ang/ui/main/MainActivity.kt`
- [Traffic and status](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/handler/TrafficTracker.kt): `V2rayNG/app/src/main/java/com/v2ray/ang/handler/TrafficTracker.kt`
- [Notifications](https://github.com/amiercassanova-21/apk-cassanova-tunnel/blob/main/V2rayNG/app/src/main/java/com/v2ray/ang/handler/NotificationManager.kt): `V2rayNG/app/src/main/java/com/v2ray/ang/handler/NotificationManager.kt`

### Other components

- **User**
- **Xray core**
- **Android VPN**
- **Wi-Fi network**

## Connections

- User → Main screen: opens
- Main screen → Profile editors: configures
- Profile editors → Profile formats: encodes profiles
- Profile formats → Profile model: produces
- Subscriptions → Profile settings store: updates profiles
- Profile model → Profile settings store: persists as (evidence: `V2rayNG/app/src/main/java/com/v2ray/ang/handler/MmkvManager.kt`)
- Routing editor → Routing settings: edits rules (evidence: `V2rayNG/app/src/main/java/com/v2ray/ang/ui/routing/RoutingSettingActivity.kt`)
- Main screen → Core service manager: starts connection
- Core service manager → Core config builder: builds config (evidence: `V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreServiceManager.kt`)
- Core service manager → SSH tunnel manager: starts tunnel (evidence: `V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreServiceManager.kt`)
- Core service manager → Profile settings store: reads settings (evidence: `V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreServiceManager.kt`)
- SSH tunnel manager → Profile model: reads profile (evidence: `V2rayNG/app/src/main/java/com/v2ray/ang/core/ssh/SshTunnelManager.kt`)
- SSH tunnel manager → SSH tunnel engines: starts engine (evidence: `V2rayNG/app/src/main/java/com/v2ray/ang/core/ssh/SshTunnelManager.kt`)
- VPN service → Core service manager: delegates lifecycle (evidence: `V2rayNG/app/src/main/java/com/v2ray/ang/service/CoreVpnService.kt`)
- VPN service → Android VPN: establishes tunnel
- Core service manager → Xray core: controls core
- Root proxy mode → Profile settings store: reads settings (evidence: `V2rayNG/app/src/main/java/com/v2ray/ang/root/RootProxyManager.kt`)
- Main screen → Subscriptions: manages subscriptions
- Main screen → Routing editor: opens routing
- Core service manager → Notifications: updates status (evidence: `V2rayNG/app/src/main/java/com/v2ray/ang/core/CoreServiceManager.kt`)
- Notifications → Traffic and status: reads traffic (evidence: `V2rayNG/app/src/main/java/com/v2ray/ang/handler/NotificationManager.kt`)
- Main screen → Connection diagnostics: runs tests
- User → Tether controls: starts tethering
- Tether controls → Tether VPN: controls service (evidence: `V2rayNG/tether/src/main/java/com/amier/tether/MainActivity.kt`)
- Tether VPN → Proxy discovery: finds proxy (evidence: `V2rayNG/tether/src/main/java/com/amier/tether/MainActivity.kt`)
- Tether VPN → Transparent proxy: reads proxy stats (evidence: `V2rayNG/tether/src/main/java/com/amier/tether/TetherVpnService.kt`)
- Tether VPN → Wi-Fi network: monitors Wi-Fi (evidence: `V2rayNG/tether/src/main/java/com/amier/tether/TetherVpnService.kt`)
- Browser dialer → Wi-Fi network: uses WebSockets
