# wyx2685/v2bx architecture

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

- Interactive diagram: https://gitdiagram.com/wyx2685/v2bx
- Repository: https://github.com/wyx2685/v2bx

## Overview

V2bX is a V2Board node server that runs multiple proxy cores and serves several protocol types from one instance. Its principal workflow loads server and node configuration, retrieves node and user data from V2Board, applies limits and certificate handling, then configures a selected core to serve traffic. Periodic node tasks report usage and refresh state. The README also documents automatic TLS renewal, DNS and audit rules, online-IP and connection limits, and dynamic/user speed limits. Wiring beyond the sampled controller and selector is represented only where supported by the tree or README.

Main entry points: [`node/controller.go`](https://github.com/wyx2685/v2bx/blob/dev_new/node/controller.go) (Node controller), [`cmd/server.go`](https://github.com/wyx2685/v2bx/blob/dev_new/cmd/server.go) (Server command), [`core/selector.go`](https://github.com/wyx2685/v2bx/blob/dev_new/core/selector.go) (Core selector), [`node/task.go`](https://github.com/wyx2685/v2bx/blob/dev_new/node/task.go) (Node tasks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime lifecycle"]
  node_server["Server command<br/>[server.go]"]
  node_config["Configuration<br/>[conf.go]"]
  node_watch["Config watching<br/>[watch.go]"]
  node_node_manager["Node manager<br/>[node.go]"]
  node_controller["Node controller<br/>[controller.go]"]
  node_tasks["Node tasks<br/>[task.go]"]
end

subgraph group_panel["Panel integration"]
  node_panel_client["Panel API client<br/>[panel.go]"]
  node_node_data["Node and user data<br/>[node.go]"]
  node_protocol_data["Protocol configuration<br/>[node.go]"]
end

subgraph group_cores["Proxy cores"]
  node_selector["Core selector<br/>[selector.go]"]
  node_xray["Xray core"]
  node_sing["sing-box core"]
  node_hysteria["Hysteria 2 core"]
end

subgraph group_policy["Limits and certificates"]
  node_traffic["Traffic counters"]
  node_limiter["Limit enforcement<br/>[limiter.go]"]
  node_certificates["TLS certificates<br/>[cert.go]"]
end

node_operator(("Operator"))
node_panel_service(("V2Board"))

node_operator -->|"starts"| node_server
node_server -->|"loads"| node_config
node_server -->|"creates and starts"| node_selector
node_server -->|"starts nodes"| node_node_manager
node_config -->|"watches changes"| node_watch
node_watch -->|"triggers restart"| node_server
node_node_manager -->|"starts controllers"| node_controller
node_controller -->|"requests data"| node_panel_client
node_panel_client -->|"fetches node and users"| node_panel_service
node_panel_service -->|"returns configuration"| node_node_data
node_controller -->|"sets limits"| node_limiter
node_controller -.->|"requests certificates"| node_certificates
node_controller -->|"adds node and users"| node_selector
node_selector -->|"dispatches node"| node_xray
node_selector -->|"dispatches node"| node_sing
node_selector -->|"dispatches node"| node_hysteria
node_controller -->|"starts periodic tasks"| node_tasks
node_tasks -->|"reports and refreshes"| node_panel_client
node_tasks -->|"collects usage"| node_traffic
node_tasks -->|"updates limits"| node_limiter
node_node_data -->|"parses protocol settings"| node_protocol_data

click node_server "https://github.com/wyx2685/v2bx/blob/dev_new/cmd/server.go"
click node_config "https://github.com/wyx2685/v2bx/blob/dev_new/conf/conf.go"
click node_watch "https://github.com/wyx2685/v2bx/blob/dev_new/conf/watch.go"
click node_node_manager "https://github.com/wyx2685/v2bx/blob/dev_new/node/node.go"
click node_controller "https://github.com/wyx2685/v2bx/blob/dev_new/node/controller.go"
click node_panel_client "https://github.com/wyx2685/v2bx/blob/dev_new/api/panel/panel.go"
click node_node_data "https://github.com/wyx2685/v2bx/blob/dev_new/api/panel/node.go"
click node_selector "https://github.com/wyx2685/v2bx/blob/dev_new/core/selector.go"
click node_xray "https://github.com/wyx2685/v2bx/tree/dev_new/core/xray"
click node_sing "https://github.com/wyx2685/v2bx/tree/dev_new/core/sing"
click node_hysteria "https://github.com/wyx2685/v2bx/tree/dev_new/core/hy2"
click node_traffic "https://github.com/wyx2685/v2bx/tree/dev_new/common/counter"
click node_limiter "https://github.com/wyx2685/v2bx/blob/dev_new/limiter/limiter.go"
click node_certificates "https://github.com/wyx2685/v2bx/blob/dev_new/node/cert.go"
click node_tasks "https://github.com/wyx2685/v2bx/blob/dev_new/node/task.go"
click node_protocol_data "https://github.com/wyx2685/v2bx/blob/dev_new/api/panel/node.go"

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_server,node_config,node_watch,node_node_manager,node_controller,node_tasks toneBlue
class node_panel_client,node_node_data,node_protocol_data toneAmber
class node_selector,node_xray,node_sing,node_hysteria toneMint
class node_traffic,node_limiter,node_certificates toneRose
class node_operator,node_panel_service toneIndigo
```

## Components

### Runtime lifecycle

- [Server command](https://github.com/wyx2685/v2bx/blob/dev_new/cmd/server.go): `cmd/server.go`
- [Configuration](https://github.com/wyx2685/v2bx/blob/dev_new/conf/conf.go): `conf/conf.go`
- [Config watching](https://github.com/wyx2685/v2bx/blob/dev_new/conf/watch.go): `conf/watch.go`
- [Node manager](https://github.com/wyx2685/v2bx/blob/dev_new/node/node.go): `node/node.go`
- [Node controller](https://github.com/wyx2685/v2bx/blob/dev_new/node/controller.go): `node/controller.go`
- [Node tasks](https://github.com/wyx2685/v2bx/blob/dev_new/node/task.go): `node/task.go`

### Panel integration

- [Panel API client](https://github.com/wyx2685/v2bx/blob/dev_new/api/panel/panel.go): `api/panel/panel.go`
- [Node and user data](https://github.com/wyx2685/v2bx/blob/dev_new/api/panel/node.go): `api/panel/node.go`
- [Protocol configuration](https://github.com/wyx2685/v2bx/blob/dev_new/api/panel/node.go): `api/panel/node.go`

### Proxy cores

- [Core selector](https://github.com/wyx2685/v2bx/blob/dev_new/core/selector.go): `core/selector.go`
- [Xray core](https://github.com/wyx2685/v2bx/tree/dev_new/core/xray): `core/xray`
- [sing-box core](https://github.com/wyx2685/v2bx/tree/dev_new/core/sing): `core/sing`
- [Hysteria 2 core](https://github.com/wyx2685/v2bx/tree/dev_new/core/hy2): `core/hy2`

### Limits and certificates

- [Traffic counters](https://github.com/wyx2685/v2bx/tree/dev_new/common/counter): `common/counter`
- [Limit enforcement](https://github.com/wyx2685/v2bx/blob/dev_new/limiter/limiter.go): `limiter/limiter.go`
- [TLS certificates](https://github.com/wyx2685/v2bx/blob/dev_new/node/cert.go): `node/cert.go`

### Other components

- **Operator**
- **V2Board**

## Connections

- Operator → Server command: starts
- Server command → Configuration: loads
- Server command → Core selector: creates and starts
- Server command → Node manager: starts nodes
- Configuration → Config watching: watches changes
- Config watching → Server command: triggers restart
- Node manager → Node controller: starts controllers
- Node controller → Panel API client: requests data
- Panel API client → V2Board: fetches node and users
- V2Board → Node and user data: returns configuration
- Node controller → Limit enforcement: sets limits
- Node controller → TLS certificates: requests certificates
- Node controller → Core selector: adds node and users
- Core selector → Xray core: dispatches node
- Core selector → sing-box core: dispatches node
- Core selector → Hysteria 2 core: dispatches node
- Node controller → Node tasks: starts periodic tasks
- Node tasks → Panel API client: reports and refreshes
- Node tasks → Traffic counters: collects usage
- Node tasks → Limit enforcement: updates limits
- Node and user data → Protocol configuration: parses protocol settings
