# youzspace/3xui-hub architecture

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

- Interactive diagram: https://gitdiagram.com/youzspace/3xui-hub
- Repository: https://github.com/youzspace/3xui-hub

## Overview

ControlHub is a Laravel-based subscription-management hub for 3x-ui/Xray nodes, users, plans, and payments. Users authenticate, choose a plan, pay, and receive subscription access; administrators manage users, nodes, settings, and backups. Node agents register, fetch rendered Xray configuration, report status and traffic, and receive commands. Scheduled jobs synchronize usage and enforce limits. The graph combines documented capabilities with relationships visible in the supplied excerpts and SOURCE INDEX; unsampled feature implementations are represented by their exact enclosing directories.

Main entry points: [`backend/app/Http/Controllers/Admin`](https://github.com/youzspace/3xui-hub/tree/main/backend/app/Http/Controllers/Admin) (Admin features), [`backend/app/Http/Controllers/Api/NodeApiController.php`](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Http/Controllers/Api/NodeApiController.php) (Xray agent API), [`backend/app/Drivers/NodeDriverFactory.php`](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Drivers/NodeDriverFactory.php) (Node driver factory), [`backend/app/Services/TrafficSyncService.php`](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Services/TrafficSyncService.php) (Traffic synchronization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["API and Administration"]
  node_api_routes["User and node API<br/>[api.php]"]
  node_admin_routes["Admin API<br/>[web.php]"]
  node_auth["Authentication<br/>[AuthController.php]"]
  node_admin_features["Admin features"]
end

subgraph group_commerce["Accounts and Commerce"]
  node_user_features["User features"]
  node_subscriptions["Subscriptions"]
  node_payments["Payments and orders<br/>[PaymentService.php]"]
  node_user_admin["User provisioning"]
end

subgraph group_nodes["Node Management"]
  node_node_admin["Node administration<br/>[NodeController.php]"]
  node_driver_factory["Node driver factory"]
  node_panel_driver["3x-ui client<br/>[ThreeXUiClient.php]"]
  node_xray_api["Xray agent API"]
  node_xray_config["Xray configuration"]
end

subgraph group_automation["Automation and Messaging"]
  node_traffic["Traffic synchronization"]
  node_ban["Limit enforcement<br/>[BanService.php]"]
  node_jobs["Queue and scheduled jobs"]
  node_backup["Database backup"]
end

subgraph group_state["Persistent State"]
  node_users_db[("Users and plans<br/>[User.php]")]
  node_nodes_db[("Node configuration<br/>[Node.php]")]
  node_settings_db[("Site settings<br/>[SiteConfig.php]")]
  node_orders_db[("Orders<br/>[Order.php]")]
end

node_user(("User"))
node_admin(("Administrator"))
node_agent(("Node agent"))

node_user -->|"uses"| node_api_routes
node_admin -->|"manages"| node_admin_routes
node_api_routes -->|"routes to"| node_auth
node_api_routes -->|"routes to"| node_user_features
node_admin_routes -->|"routes to"| node_admin_features
node_auth -->|"authenticates"| node_users_db
node_user_features -.->|"serves subscriptions"| node_subscriptions
node_user_features -->|"creates orders"| node_payments
node_payments -.->|"records orders"| node_orders_db
node_payments -->|"integrates gateway"| node_user
node_admin_features -->|"manages nodes"| node_node_admin
node_node_admin -->|"selects driver"| node_driver_factory
node_driver_factory -->|"creates client"| node_panel_driver
node_driver_factory -->|"reads node type"| node_nodes_db
node_agent -->|"registers and reports"| node_xray_api
node_xray_api -->|"renders config"| node_xray_config
node_xray_api -->|"submits usage"| node_traffic
node_xray_api -->|"updates node"| node_nodes_db
node_traffic -->|"updates usage"| node_users_db
node_traffic -->|"reads node usage"| node_nodes_db
node_jobs -.->|"runs sync"| node_traffic
node_jobs -.->|"checks limits"| node_ban
node_ban -.->|"enforces limits"| node_users_db
node_user_admin -->|"provisions clients"| node_driver_factory
node_user_admin -->|"updates accounts"| node_users_db
node_admin_features -->|"offers backup"| node_backup
node_backup -.->|"backs up data"| node_settings_db
node_admin_features -.->|"configures site"| node_settings_db
node_admin_features -.->|"reviews orders"| node_orders_db

click node_api_routes "https://github.com/youzspace/3xui-hub/blob/main/backend/routes/api.php"
click node_admin_routes "https://github.com/youzspace/3xui-hub/blob/main/backend/routes/web.php"
click node_auth "https://github.com/youzspace/3xui-hub/blob/main/backend/app/Http/Controllers/Api/AuthController.php"
click node_admin_features "https://github.com/youzspace/3xui-hub/tree/main/backend/app/Http/Controllers/Admin"
click node_user_features "https://github.com/youzspace/3xui-hub/tree/main/backend/app/Http/Controllers/Api"
click node_subscriptions "https://github.com/youzspace/3xui-hub/blob/main/backend/app/Services/SubscriptionService.php"
click node_payments "https://github.com/youzspace/3xui-hub/blob/main/backend/app/Services/PaymentService.php"
click node_user_admin "https://github.com/youzspace/3xui-hub/blob/main/backend/app/Services/UserAdminService.php"
click node_node_admin "https://github.com/youzspace/3xui-hub/blob/main/backend/app/Http/Controllers/Admin/NodeController.php"
click node_driver_factory "https://github.com/youzspace/3xui-hub/blob/main/backend/app/Drivers/NodeDriverFactory.php"
click node_panel_driver "https://github.com/youzspace/3xui-hub/blob/main/backend/app/Services/ThreeXUi/ThreeXUiClient.php"
click node_xray_api "https://github.com/youzspace/3xui-hub/blob/main/backend/app/Http/Controllers/Api/NodeApiController.php"
click node_xray_config "https://github.com/youzspace/3xui-hub/blob/main/backend/app/Drivers/Xray/XrayConfigService.php"
click node_traffic "https://github.com/youzspace/3xui-hub/blob/main/backend/app/Services/TrafficSyncService.php"
click node_ban "https://github.com/youzspace/3xui-hub/blob/main/backend/app/Services/BanService.php"
click node_jobs "https://github.com/youzspace/3xui-hub/tree/main/backend/app/Jobs"
click node_backup "https://github.com/youzspace/3xui-hub/blob/main/backend/app/Http/Controllers/Admin/BackupController.php"
click node_users_db "https://github.com/youzspace/3xui-hub/blob/main/backend/app/Models/User.php"
click node_nodes_db "https://github.com/youzspace/3xui-hub/blob/main/backend/app/Models/Node.php"
click node_settings_db "https://github.com/youzspace/3xui-hub/blob/main/backend/app/Models/SiteConfig.php"
click node_orders_db "https://github.com/youzspace/3xui-hub/blob/main/backend/app/Models/Order.php"

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_api_routes,node_admin_routes,node_auth,node_admin_features,node_user toneBlue
class node_user_features,node_subscriptions,node_payments,node_user_admin toneAmber
class node_node_admin,node_driver_factory,node_panel_driver,node_xray_api,node_xray_config toneMint
class node_traffic,node_ban,node_jobs,node_backup toneRose
class node_users_db,node_nodes_db,node_settings_db,node_orders_db,node_admin,node_agent toneIndigo
```

## Components

### API and Administration

- [User and node API](https://github.com/youzspace/3xui-hub/blob/main/backend/routes/api.php): `backend/routes/api.php`
- [Admin API](https://github.com/youzspace/3xui-hub/blob/main/backend/routes/web.php): `backend/routes/web.php`
- [Authentication](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Http/Controllers/Api/AuthController.php): `backend/app/Http/Controllers/Api/AuthController.php`
- [Admin features](https://github.com/youzspace/3xui-hub/tree/main/backend/app/Http/Controllers/Admin): `backend/app/Http/Controllers/Admin`

### Accounts and Commerce

- [User features](https://github.com/youzspace/3xui-hub/tree/main/backend/app/Http/Controllers/Api): `backend/app/Http/Controllers/Api`
- [Subscriptions](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Services/SubscriptionService.php): `backend/app/Services/SubscriptionService.php`
- [Payments and orders](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Services/PaymentService.php): `backend/app/Services/PaymentService.php`
- [User provisioning](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Services/UserAdminService.php): `backend/app/Services/UserAdminService.php`

### Node Management

- [Node administration](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Http/Controllers/Admin/NodeController.php): `backend/app/Http/Controllers/Admin/NodeController.php`
- [Node driver factory](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Drivers/NodeDriverFactory.php): `backend/app/Drivers/NodeDriverFactory.php`
- [3x-ui client](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Services/ThreeXUi/ThreeXUiClient.php): `backend/app/Services/ThreeXUi/ThreeXUiClient.php`
- [Xray agent API](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Http/Controllers/Api/NodeApiController.php): `backend/app/Http/Controllers/Api/NodeApiController.php`
- [Xray configuration](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Drivers/Xray/XrayConfigService.php): `backend/app/Drivers/Xray/XrayConfigService.php`

### Automation and Messaging

- [Traffic synchronization](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Services/TrafficSyncService.php): `backend/app/Services/TrafficSyncService.php`
- [Limit enforcement](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Services/BanService.php): `backend/app/Services/BanService.php`
- [Queue and scheduled jobs](https://github.com/youzspace/3xui-hub/tree/main/backend/app/Jobs): `backend/app/Jobs`
- [Database backup](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Http/Controllers/Admin/BackupController.php): `backend/app/Http/Controllers/Admin/BackupController.php`

### Persistent State

- [Users and plans](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Models/User.php): `backend/app/Models/User.php`
- [Node configuration](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Models/Node.php): `backend/app/Models/Node.php`
- [Site settings](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Models/SiteConfig.php): `backend/app/Models/SiteConfig.php`
- [Orders](https://github.com/youzspace/3xui-hub/blob/main/backend/app/Models/Order.php): `backend/app/Models/Order.php`

### Other components

- **User**
- **Administrator**
- **Node agent**

## Connections

- User → User and node API: uses (evidence: `README.md`)
- Administrator → Admin API: manages (evidence: `README.md`)
- User and node API → Authentication: routes to (evidence: `backend/routes/api.php`)
- User and node API → User features: routes to (evidence: `backend/routes/api.php`)
- Admin API → Admin features: routes to (evidence: `backend/routes/web.php`)
- Authentication → Users and plans: authenticates (evidence: `backend/app/Http/Controllers/Api/AuthController.php`)
- User features → Subscriptions: serves subscriptions
- User features → Payments and orders: creates orders (evidence: `backend/app/Http/Controllers/Api/PaymentController.php`)
- Payments and orders → Orders: records orders (evidence: `backend/app/Services/PaymentService.php`)
- Payments and orders → User: integrates gateway (evidence: `README.md`)
- Admin features → Node administration: manages nodes (evidence: `backend/routes/web.php`)
- Node administration → Node driver factory: selects driver (evidence: `backend/app/Http/Controllers/Admin/NodeController.php`)
- Node driver factory → 3x-ui client: creates client (evidence: `backend/app/Drivers/NodeDriverFactory.php`)
- Node driver factory → Node configuration: reads node type (evidence: `backend/app/Drivers/NodeDriverFactory.php`)
- Node agent → Xray agent API: registers and reports (evidence: `README.md`)
- Xray agent API → Xray configuration: renders config (evidence: `backend/app/Http/Controllers/Api/NodeApiController.php`)
- Xray agent API → Traffic synchronization: submits usage (evidence: `backend/app/Http/Controllers/Api/NodeApiController.php`)
- Xray agent API → Node configuration: updates node (evidence: `backend/app/Http/Controllers/Api/NodeApiController.php`)
- Traffic synchronization → Users and plans: updates usage (evidence: `backend/app/Services/TrafficSyncService.php`)
- Traffic synchronization → Node configuration: reads node usage (evidence: `backend/app/Services/TrafficSyncService.php`)
- Queue and scheduled jobs → Traffic synchronization: runs sync
- Queue and scheduled jobs → Limit enforcement: checks limits
- Limit enforcement → Users and plans: enforces limits
- User provisioning → Node driver factory: provisions clients (evidence: `backend/app/Services/UserAdminService.php`)
- User provisioning → Users and plans: updates accounts (evidence: `backend/app/Services/UserAdminService.php`)
- Admin features → Database backup: offers backup (evidence: `README.md`)
- Database backup → Site settings: backs up data
- Admin features → Site settings: configures site (evidence: `backend/app/Http/Controllers/Admin/NodeController.php`)
- Admin features → Orders: reviews orders
