# givpn/autoscriptxray architecture

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

- Interactive diagram: https://gitdiagram.com/givpn/autoscriptxray
- Repository: https://github.com/givpn/autoscriptxray

## Overview

##### Project Type and Purpose
- This is an infrastructure automation project—a Bash-based installer & manager for VPN/SSH services on Debian/Ubuntu.
- The README and file tree show a “one-click” setup script (`setup.sh`) that installs and configures: OpenSSH, Dropbear, Stunnel4, various SSH-over-WebSocket/UDP services, Xray (VLESS/VMESS/Trojan/gRPC), Shadowsocks, Webmin (Helium), Bot Telegram panel, optional OpenVPN/SlowDNS (udp-custom), plus utilities (Fail2Ban, BBRPLUS, speedtest, auto-reboot).

##### File Structure Analysis
- Root
- `setup.sh` (orchestrator)
- `menu/` (interactive menu scripts)
- `rootvps.sh` (helper)
- service folders (`ssh/`, `sshws/`, `xray/`, `grpc/`, `openvpn/`, `slowdns/`, `udp-custom/`, `websocket/`, `helium/`, `bot telegram panel/`, `fix/`, etc.)
- config templates (`ssh/nginx.conf`, `udp-custom/config.json`, `banner/`, `privacy/`, `sshd_config`)
- Each service folder contains scripts to install, add users, renew, delete, and check status.
- Cron jobs, systemd service units (`.service` under `sshws/`, `websocket/ws-dropbear.service`, etc.), and helper scripts in `menu/` indicate a modular, script-per-component pattern.

##### README Insights
- Describes supported OS, domain & Cloudflare DNS settings, service & port mapping.
- Lists features (auto-reboot, user expiration cleanup, speedtest, BBR, DNS changer).
- Shows optional installs: Panel Webmin (Helium) and Telegram Bot.

a. Main Components
- User (sysadmin) invoking `setup.sh` (CLI orchestrator).
- Core OS Platform: Debian/Ubuntu host with systemd and networking stack.
- Service modules:
- SSH Stack: OpenSSH, Dropbear, SSH-over-WebSocket (sshws), SSH UDP Custom (slowdns + udp-custom).
- TLS Proxy: Stunnel4.
- WebSocket & gRPC Gateways: Nginx (for WS/TLS), Xray core (VMESS/VLESS/Trojan/gRPC), websocket scripts.
- VPN: OpenVPN (udp-custom/openvpn).
- Management: Webmin panel (Helium), Telegram Bot panel.
- Utilities: Fail2Ban, BBRPLUS, speedtest, auto-reboot & cron jobs.
- External: Domain Name & DNS (Cloudflare), Telegram API.

b. Relationships & Interactions
- `setup.sh` → executes `menu/menu.sh` → calls individual service installers.
- Each installer script ↔ OS package manager (`apt`), systemd unit files, config directories (e.g., `/etc/ssh/`, `/etc/xray/`).
- Nginx routes HTTP/WS traffic to Xray or SSH WS endpoints.
- Stunnel terminates TLS on configured ports and proxies to internal services.
- Cron jobs (via `cron.d`) manage auto-reboots, user expiry cleanup, speedtest.
- Telegram Bot connects to local script hooks (via polling or webhook) to administer users.
- Webmin (Helium) exposes a web UI on port 10000 for system management.

c. Architectural Patterns & Principles
- Modular script-per-service pattern for isolation and easier updates.
- Layered proxy approach: Nginx → Xray/gRPC and Stunnel → underlying daemons.
- Configuration-as-code: template + scripted deployment.
- CLI‐driven orchestration with interactive menus.

d. Key Technologies & Frameworks
- Bash & shell scripts (orchestration).
- APT (package management), systemd (service management), cron (job scheduling).
- OpenSSH, Dropbear, Stunnel4.
- Xray core (Go-based proxy), Webmin (Perl/PHP panel), Telegram Bot (shell + `xolpanel.sh`).
- Nginx (HTTP & WebSocket proxy), SlowDNS (Go).
- Speedtest CLI (Python), BBRPLUS kernel module.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Orchestrator Layer"
        O1["setup.sh"]:::orchestrator
        O2["rootvps.sh"]:::orchestrator
        subgraph "Secondary Setup Scripts"
            O3["ubuntu/setup.sh"]:::orchestrator
            O4["stempel/setup.sh"]:::orchestrator
        end
        O1 --> O2
        O1 --> O3
        O1 --> O4
        O1 --> M1["menu/menu.sh"]:::orchestrator
    end

    subgraph "Host OS (Debian/Ubuntu)"
        direction TB
        M1 -->|"calls installers"| SSH1
        M1 --> SSH1
        M1 --> WS1
        M1 --> ST
        M1 --> SD
        M1 --> UC
        M1 --> OV
        M1 --> WG
        M1 --> XR
        M1 --> GR
        M1 --> HM
        M1 --> TB
        subgraph "Service Modules"
            direction TB
            subgraph "SSH Stack" 
                SSH1["ssh/"]:::coreServices
            end
            subgraph "SSH-over-WebSocket"
                WS1["sshws/"]:::proxies
            end
            subgraph "TLS Proxy (Stunnel4)"
                ST["sshws/ws-stunnel"]:::proxies
            end
            subgraph "SlowDNS Service"
                SD["slowdns/"]:::coreServices
            end
            subgraph "UDP-Custom VPN"
                UC["udp-custom/"]:::coreServices
            end
            subgraph "OpenVPN Service"
                OV["openvpn/"]:::coreServices
            end
            subgraph "WebSocket Gateways"
                WG["websocket/"]:::proxies
            end
            subgraph "Xray Proxy Core"
                XR["xray/"]:::proxies
            end
            subgraph "gRPC Gateway"
                GR["grpc/"]:::proxies
            end
            subgraph "Webmin Panel (Helium)"
                HM["helium/"]:::coreServices
            end
            subgraph "Telegram Bot Panel"
                TB["bot telegram panel/"]:::coreServices
            end
            subgraph "Utilities & Maintenance"
                direction TB
                UT1["fix/"]:::utilities
                UT2["banner/"]:::utilities
                UT3["privacy/"]:::utilities
                UT4["addip/"]:::utilities
                UT5["update/"]:::utilities
            end
        end
        cron["Cron Scheduler"]:::utilities
        cron --> UT1
        cron --> UT2
        cron --> UT3
        cron --> UT4
    end

    subgraph "External Systems"
        CF["Cloudflare DNS"]:::external
        DM["Domain Name"]:::external
        TA["Telegram API"]:::external
    end
    CF --> DM
    DM --> M1
    TA -->|"API calls"| TB

    click O1 "https://github.com/givpn/autoscriptxray/blob/master/setup.sh"
    click O2 "https://github.com/givpn/autoscriptxray/blob/master/rootvps.sh"
    click O3 "https://github.com/givpn/autoscriptxray/blob/master/ubuntu/setup.sh"
    click O4 "https://github.com/givpn/autoscriptxray/blob/master/stempel/setup.sh"
    click M1 "https://github.com/givpn/autoscriptxray/blob/master/menu/menu.sh"
    click SSH1 "https://github.com/givpn/autoscriptxray/tree/master/ssh/"
    click WS1 "https://github.com/givpn/autoscriptxray/tree/master/sshws/"
    click ST "https://github.com/givpn/autoscriptxray/tree/master/sshws/ws-stunnel"
    click SD "https://github.com/givpn/autoscriptxray/tree/master/slowdns/"
    click UC "https://github.com/givpn/autoscriptxray/tree/master/udp-custom/"
    click OV "https://github.com/givpn/autoscriptxray/tree/master/openvpn/"
    click WG "https://github.com/givpn/autoscriptxray/tree/master/websocket/"
    click XR "https://github.com/givpn/autoscriptxray/tree/master/xray/"
    click GR "https://github.com/givpn/autoscriptxray/tree/master/grpc/"
    click HM "https://github.com/givpn/autoscriptxray/tree/master/helium/"
    click TB "https://github.com/givpn/autoscriptxray/tree/master/bot telegram panel/"
    click UT1 "https://github.com/givpn/autoscriptxray/blob/master/fix/speedtestfix.sh"
    click UT2 "https://github.com/givpn/autoscriptxray/blob/master/banner/banner.conf"
    click UT3 "https://github.com/givpn/autoscriptxray/blob/master/privacy/user.toml"
    click UT4 "https://github.com/givpn/autoscriptxray/tree/master/addip/"
    click UT5 "https://github.com/givpn/autoscriptxray/blob/master/update/yes.py"

    classDef orchestrator fill:#D0E8FF,stroke:#333,stroke-width:1px;
    classDef coreServices fill:#D5F5E3,stroke:#333,stroke-width:1px;
    classDef proxies fill:#FDEBD0,stroke:#333,stroke-width:1px;
    classDef utilities fill:#E5E8E8,stroke:#333,stroke-width:1px;
    classDef external fill:#F4ECF7,stroke:#333,stroke-dasharray:5 5;
```
