# v2board/v2board architecture

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

- Interactive diagram: https://gitdiagram.com/v2board/v2board
- Repository: https://github.com/v2board/v2board

## Overview

##### Project type and purpose
- V2Board is a monolithic full-stack web application built on Laravel (PHP), serving as a subscription/proxy-management and billing platform. It provides user registration/login, plan management, server provisioning, traffic/statistics, ticketing, payments (Stripe, Alipay, Coinbase, etc.), email/Telegram notifications, and an admin panel.

##### File structure
- Top-level directories:
- app/              → core Laravel code (Console commands, HTTP controllers by role, Middleware, Jobs, Models, Services, Providers, Plugins, Utilities)
- config/           → environment/configuration
- database/         → migrations, seeds, SQL scripts
- public/           → entry point (index.php), static assets (admin SPA built with Umi/React, theme assets)
- resources/        → Blade views, front-end assets (JS, Sass), i18n, rule templates
- routes/           → route definitions by area (AdminRoute, UserRoute, etc.)
- tests/            → PHPUnit tests
- artisan, bootstrap, storage, composer.json, pm2.yaml, init/update scripts

- Architectural indicators:
- MVC pattern (Controllers, Models, Views)
- Domain services layer (app/Services) and Plugins (Telegram)
- Asynchronous processing (Jobs, Queues, Laravel Horizon)
- Scheduled tasks (Console/Kernel.php)
- Multi-role HTTP entrypoints (Admin, Client, Guest, Staff, Server, Passport, User)

##### README for additional insights
- Confirms tech stack: PHP7.3+, Laravel, MySQL, Redis

##### Elements
– Blue for user-facing (frontend)
– Green for application logic (Laravel)
– Yellow for data stores
– Orange for external services

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        Browser["Web Browser"]:::frontend
        Browser -->|loads SPA| AdminSPA["Admin SPA (Umi/React)"]:::frontend
        Browser -->|loads UI| PublicUI["Public UI (Blade + JS)"]:::frontend
        click AdminSPA "https://github.com/v2board/v2board/tree/master/public/assets/admin/"
        click PublicUI "https://github.com/v2board/v2board/tree/master/public/theme/v2board/"
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        HTTPServer["HTTP Server\n(Nginx/Apache)"]:::app
        HTTPServer -->|passes request| PHPFPM["PHP-FPM"]:::app
        PHPFPM -->|bootstraps| Bootstrap["Application Bootstrap"]:::app
        click HTTPServer "https://github.com/v2board/v2board/blob/master/public/index.php"
        click Bootstrap "https://github.com/v2board/v2board/blob/master/bootstrap/app.php"
    end

    %% Routing & Middleware
    subgraph "Routing & Middleware"
        direction TB
        Kernel["HTTP Kernel"]:::app
        Kernel --> Routes["Route Definitions"]:::app
        click Kernel "https://github.com/v2board/v2board/blob/master/app/Http/Kernel.php"
        click Routes "https://github.com/v2board/v2board/blob/master/routes/web.php"
        subgraph "Routes"
            direction TB
            AR["AdminRoute"] 
            CR["ClientRoute"] 
            GR["GuestRoute"] 
            PR["PassportRoute"] 
            SR["ServerRoute"] 
            STR["StaffRoute"] 
            UR["UserRoute"]
            click AR "https://github.com/v2board/v2board/blob/master/app/Http/Routes/AdminRoute.php"
            click CR "https://github.com/v2board/v2board/blob/master/app/Http/Routes/ClientRoute.php"
            click GR "https://github.com/v2board/v2board/blob/master/app/Http/Routes/GuestRoute.php"
            click PR "https://github.com/v2board/v2board/blob/master/app/Http/Routes/PassportRoute.php"
            click SR "https://github.com/v2board/v2board/blob/master/app/Http/Routes/ServerRoute.php"
            click STR "https://github.com/v2board/v2board/blob/master/app/Http/Routes/StaffRoute.php"
            click UR "https://github.com/v2board/v2board/blob/master/app/Http/Routes/UserRoute.php"
        end
        Kernel -->|applies| Middleware["Middleware"]:::app
        click Middleware "https://github.com/v2board/v2board/tree/master/app/Http/Middleware/"
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Controllers["Controllers"]:::app
        Controllers --> Services["Services"]:::app
        Controllers --> JobsDispatcher["Dispatch Jobs"]:::app
        Services --> Models["Models (Eloquent)"]:::app
        click Controllers "https://github.com/v2board/v2board/tree/master/app/Http/Controllers/"
        click Services "https://github.com/v2board/v2board/tree/master/app/Services/"
        click Models "https://github.com/v2board/v2board/tree/master/app/Models/"
        subgraph "Jobs & Workers"
            direction TB
            Jobs["Jobs/Queue Workers"]:::app
            click Jobs "https://github.com/v2board/v2board/tree/master/app/Jobs/"
        end
        Controllers -->|dispatch| Jobs
    end

    %% Console & Scheduler
    subgraph "Scheduler & Console"
        direction TB
        Cron["Cron/CLI"]:::app
        Cron -->|triggers| ConsoleKernel["Console Kernel"]:::app
        click ConsoleKernel "https://github.com/v2board/v2board/blob/master/app/Console/Kernel.php"
        ConsoleKernel --> Commands["Console Commands"]:::app
        click Commands "https://github.com/v2board/v2board/tree/master/app/Console/Commands/"
    end

    %% Plugins & Payments
    subgraph "Integrations"
        direction TB
        Plugins["Plugins (Telegram)"]:::app
        Payments["Payment Gateways"]:::app
        click Plugins "https://github.com/v2board/v2board/tree/master/app/Plugins/Telegram/"
        click Payments "https://github.com/v2board/v2board/tree/master/app/Payments/"
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        DB["MySQL Database"]:::data
        Cache["Redis Cache & Session"]:::data
        QueueStore["Redis Queue (Horizon)"]:::data
        Storage["File Storage"]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        ExtPay["External Payment APIs"]:::external
        ExtTele["Telegram API"]:::external
        ExtMail["Email SMTP/Mailgun/SES"]:::external
    end

    %% Config & Assets
    Config["Configuration"]:::config
    click Config "https://github.com/v2board/v2board/tree/master/config/"

    Resources["Views & Assets"]:::config
    click Resources "https://github.com/v2board/v2board/tree/master/resources/views/"
    click Resources "https://github.com/v2board/v2board/blob/master/resources/js/app.js"
    click Resources "https://github.com/v2board/v2board/blob/master/resources/sass/app.scss"

    %% Connections
    PublicUI --> HTTPServer
    AdminSPA --> HTTPServer
    Bootstrap --> Kernel
    Routes --> Controllers
    Middleware --> Controllers
    Services --> Plugins
    Services --> Payments
    Services --> ExtTele
    Services --> ExtMail
    Controllers --> DB
    Services --> Cache
    Jobs --> DB
    Jobs --> ExtMail
    Jobs --> ExtTele
    Cron --> Commands
    Commands --> Services

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#3399FF,color:#000;
    classDef app fill:#E6FFE6,stroke:#33CC33,color:#000;
    classDef data fill:#FFF5CC,stroke:#E6B800,color:#000;
    classDef external fill:#FFE6CC,stroke:#FF9933,color:#000;
    classDef config fill:#F2F2F2,stroke:#CCCCCC,color:#000;
```
