# System map — 2dust/v2rayN

> Canonical page: https://codevetter.com/unpack/v2rayn/system-map

# System map — 2dust/v2rayN

Scanned commit 28139853a8087d81e1ac7ffaf7013b937958f5d2 (2026-09-20). Generated by codevetter codevetter 1.12.0 on 2026-09-22.

The solution (v2rayN.sln) has five projects: ServiceLib (all shared logic, ViewModels, managers, config generation), v2rayN (WPF Windows shell), v2rayN.Desktop (Avalonia cross-platform shell), AmazTool (a tiny console updater/relocator invoked after self-upgrade downloads), and ServiceLib.UdpTest (UDP-over-SOCKS5 tester library referenced by ServiceLib). Persistence is a JSON file guiNConfig.json plus a SQLite database guiNDB.db accessed via the SQLiteHelper singleton. External runtime boundaries are the spawned core processes (xray, sing-box, mihomo, etc. under bin/<coreType>/), OS facilities (WinInet/registry, launchctl, .desktop autostart, sudo bash scripts), a loopback Clash API, and GitHub release endpoints for updates. Build/test is .NET 10 with GitHub Actions workflows; GlobalHotKeys is a git submodule used only by the Desktop project.
- The WPF Windows shell entrypoint is App.OnStartup in v2rayN/v2rayN/App.xaml.cs: it enforces a single instance via an EventWaitHandle keyed on the MD5 of the exe path, honors a 'rebootas' arg, calls AppManager.Instance.InitApp()/InitComponents(), builds the ReactiveUI builder, and shows MainWindow resolved through SimpleViewLocator. — [v2rayN/v2rayN/App.xaml.cs#L24-61](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/v2rayN/App.xaml.cs#L24-L61) [v2rayN/v2rayN/Common/SimpleViewLocator.cs](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/v2rayN/Common/SimpleViewLocator.cs)
- The Avalonia shell entrypoint is Program.Main in v2rayN.Desktop which does single-instance locking (EventWaitHandle on Windows, a named Mutex 'v2rayN' on Linux/macOS), calls AppManager.Instance.InitApp(), then builds AppBuilder with UsePlatformDetect/UseReactiveUI and macOS dock options. — [v2rayN/v2rayN.Desktop/Program.cs#L14-77](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/v2rayN.Desktop/Program.cs#L14-L77) [v2rayN/v2rayN.Desktop/App.axaml.cs#L16-41](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/v2rayN.Desktop/App.axaml.cs#L16-L41)
- ServiceLib is the shared library referenced by both shells (ProjectReference in each csproj); it contains ViewModels, Manager singletons, Handler statics, Services, Fmt parsers, Models, ResUI localization resx files and embedded Sample templates. — [v2rayN/ServiceLib/ServiceLib.csproj](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/ServiceLib.csproj) [v2rayN/v2rayN/v2rayN.csproj#L39](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/v2rayN/v2rayN.csproj#L39) [v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj#L40-42](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj#L40-L42)
- AmazTool is a standalone console exe whose Main dispatches on args[0]: 'rebootas' restarts v2rayN via Utils.StartV2RayN, 'help' prints usage, and anything else is treated as a URL-escaped zip path passed to UpgradeApp.Upgrade for self-update extraction. — [v2rayN/AmazTool/Program.cs#L24-45](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/AmazTool/Program.cs#L24-L45) [v2rayN/AmazTool/UpgradeApp.cs#L9-19](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/AmazTool/UpgradeApp.cs#L9-L19)
- App state lives in two stores under StartupPath()/guiConfigs: the JSON file guiNConfig.json deserialized by ConfigHandler.LoadConfig into the Config model, and the SQLite db guiNDB.db opened once by the SQLiteHelper singleton (sqlite-net-e / Repobot.SQLite.Unofficial packages). — [v2rayN/ServiceLib/Handler/ConfigHandler.cs#L19-36](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/Handler/ConfigHandler.cs#L19-L36) [v2rayN/ServiceLib/Helper/SqliteHelper.cs#L9-19](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/Helper/SqliteHelper.cs#L9-L19) [v2rayN/ServiceLib/Global.cs#L12](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/Global.cs#L12) [v2rayN/ServiceLib/Models/Configs/Config.cs](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/Models/Configs/Config.cs)
- AppManager.InitApp creates eight SQLite tables at startup (SubItem, ProfileItem, ServerStatItem, RoutingItem, ProfileExItem, DNSItem, FullConfigTemplateItem, plus the obsolete ProfileGroupItem) and sets the process UI culture from config.UiItem.CurrentLanguage. — [v2rayN/ServiceLib/Manager/AppManager.cs#L63-96](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/Manager/AppManager.cs#L63-L96)
- If the app directory is not writable (HasWritePermission fails, e.g. WinGet installs or a NotStoreConfigHere.txt marker), InitApp sets env var V2RAYN_LOCAL_APPLICATION_DATA_V2=1 which makes StartupPath() resolve to %LocalApplicationData%/v2rayN instead of the exe directory — i.e. portable-by-default storage with a per-user fallback. — [v2rayN/ServiceLib/Manager/AppManager.cs#L65-68](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/Manager/AppManager.cs#L65-L68) [v2rayN/ServiceLib/Common/Utils.cs#L1097-1160](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/Common/Utils.cs#L1097-L1160) [v2rayN/ServiceLib/Global.cs#L90](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/Global.cs#L90)
- External proxy cores are enumerated in CoreInfoManager.InitCoreInfo — a hard-coded registry of 14 ECoreType entries (v2rayN self, v2fly, Xray, mihomo, hysteria, naiveproxy, tuic, sing_box, juicity, hysteria2, brook, overtls, shadowquic, mieru) each declaring exe names, argument template, GitHub release/download URLs and optional environment variables. — [v2rayN/ServiceLib/Manager/CoreInfoManager.cs#L97-293](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/Manager/CoreInfoManager.cs#L97-L293)
- Core processes are spawned by ProcessService (System.Diagnostics.Process, no shell, UTF8-redirected stdout/stderr piped to an updateFunc callback) and on Windows are attached to a Job Object via WindowsJobService so children die with the parent. — [v2rayN/ServiceLib/Services/ProcessService.cs#L24-71](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/Services/ProcessService.cs#L24-L71) [v2rayN/ServiceLib/Manager/CoreManager.cs#L334-376](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/Manager/CoreManager.cs#L334-L376) [v2rayN/ServiceLib/Services/WindowsJobService.cs](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/Services/WindowsJobService.cs)
- Cross-component messaging uses the static AppEvents/EventChannel bus (SendMsgViewRequested, SendSnackMsgRequested, AppExitRequested, SysProxyChangeRequested, etc.) rather than direct references; NoticeManager publishes snack/log messages onto it. — [v2rayN/ServiceLib/Events/AppEvents.cs](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/Events/AppEvents.cs) [v2rayN/ServiceLib/Manager/NoticeManager.cs#L8-34](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/Manager/NoticeManager.cs#L8-L34)
- Directory.Build.props pins net10.0, version 7.25.2, GPL-3.0, Nullable annotations + ImplicitUsings, and Release builds force PublishSingleFile with DebugType embedded; package versions are centrally managed in Directory.Packages.props and global.json pins the SDK. — [v2rayN/Directory.Build.props](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/Directory.Build.props) [v2rayN/Directory.Packages.props](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/Directory.Packages.props) [global.json](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/global.json)
- CI/CD is GitHub Actions only: test.yml runs 'dotnet test' on ServiceLib.Tests (ubuntu-latest, .NET 10.x) on pushes/PRs touching ServiceLib paths, while build.yml is a reusable workflow building x64+arm64 for windows/linux/macos and build-*.yml/package-*.yml wrappers package and publish releases (winget, zip, GPG keys). — [.github/workflows/test.yml#L31-52](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/.github/workflows/test.yml#L31-L52) [.github/workflows/build.yml](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/.github/workflows/build.yml) [.github/workflows/build-windows.yml](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/.github/workflows/build-windows.yml) [.github/workflows/package-zip.yml](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/.github/workflows/package-zip.yml)
- v2rayN/GlobalHotKeys is a git submodule (github.com/2dust/GlobalHotKeys) referenced by v2rayN.Desktop.csproj for global hotkeys; workflows checkout with submodules: 'recursive'. — [.gitmodules](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/.gitmodules) [v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj#L40](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj#L40) [.github/workflows/build.yml](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/.github/workflows/build.yml)
- Localization is centralized in ServiceLib/Resx/ResUI*.resx (en plus zh-Hans, zh-Hant, ru, fa, fr, hu, id, az satellite assemblies), consumed as the generated ResUI.Designer.cs class across ViewModels, handlers and services. — [v2rayN/ServiceLib/ServiceLib.csproj#L59-98](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/ServiceLib.csproj#L59-L98) [v2rayN/ServiceLib/Resx/ResUI.resx](https://github.com/2dust/v2rayN/blob/28139853a8087d81e1ac7ffaf7013b937958f5d2/v2rayN/ServiceLib/Resx/ResUI.resx)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
