# bepass-org/warp-plus architecture

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

- Interactive diagram: https://gitdiagram.com/bepass-org/warp-plus
- Repository: https://github.com/bepass-org/warp-plus

## Overview

##### Main Components

a) Core Components:
- Warp Client Implementation
- Psiphon Integration Layer
- SOCKS5 Proxy Server
- WireGuard Protocol Handler
- IP Scanner System
- Configuration Management

b) External Services:
- Cloudflare Warp Servers
- Psiphon Network
- DNS Services (e.g., 1.1.1.1)

**┌─ User Layer ─────────────────────────┐**
- SOCKS5 Client / TUN Interface        │
- ┬─────────────────────┘
- ↓
**┌─ Proxy Layer ─────────────────────────┐**
- SOCKS5 Proxy Server                   │
- Custom Protocol Handlers              │
- ┬─────────────────────┘
- ↓
**┌─ Core Service Layer ──────────────────┐**
- ┌─────────────┐  ┌─────────────┐     │
- Warp      │  │  Psiphon    │     │
- Client    │←→│  Integration│     │
- ┘  └─────────────┘     │
- ┌─────────────┐  ┌─────────────┐     │
- WireGuard  │  │ IP Scanner  │     │
- Protocol   │  │   System    │     │
- ┘  └─────────────┘     │
- ┬─────────────────────┘
- ↓
**┌─ Network Layer ────────────────────────┐**
- Cloudflare Warp │ Psiphon Network      │
- DNS Services    │ Internet Connection  │
- ┘

##### Key Interactions to Highlight

a) Primary Data Flow:
- Client → SOCKS5 Proxy → Warp Client → Cloudflare Network
- Alternative flow with Psiphon: Client → SOCKS5 → Psiphon → Warp → Cloudflare

b) Control Flow:
- Configuration Management → All Components
- IP Scanner → Warp Client (for endpoint selection)
- WireGuard Protocol → Network Interface

##### Special Features to Emphasize

- Warp-in-Warp chaining capability (show as nested Warp clients)
- Country-based routing through Psiphon
- IP scanning and optimization system
- TUN interface support (experimental)

##### Technical Details

- Default ports (e.g., 8086 for SOCKS5)
- Supported protocols (WireGuard, SOCKS5)
- Configuration options (IPv4/IPv6 support)
- Security features (encryption, key management)

##### Implementation Notes

- Use standardized UML or C4 model notation
- Notes for experimental features
- Configuration file relationships
- Platform-specific components (Windows/Linux/Darwin)

This system design should help developers understand both the high-level architecture and the detailed interactions between components, facilitating further development and maintenance of the project.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph User["User Layer"]
        Client["SOCKS5 Client"]
        TUN["TUN Interface"]
    end

    subgraph Proxy["Proxy Layer"]
        SOCKS["SOCKS5 Proxy Server"]:::proxy
        ProtoHandlers["Protocol Handlers"]
    end

    subgraph Core["Core Service Layer"]
        WarpClient["Warp Client"]:::warp
        PsiphonInt["Psiphon Integration"]:::psiphon
        WireGuard["WireGuard Protocol"]:::wireguard
        IPScanner["IP Scanner System"]:::scanner
        Config["Configuration Management"]:::config
        App["Core Application"]:::app
    end

    subgraph Network["Network Layer"]
        CloudflareWarp["Cloudflare Warp Servers"]:::external
        PsiphonNet["Psiphon Network"]:::external
        DNS["DNS Services (1.1.1.1)"]:::external
    end

    %% Connections
    Client --> SOCKS
    TUN --> WireGuard
    SOCKS --> WarpClient
    SOCKS --> PsiphonInt
    ProtoHandlers --> SOCKS
    
    WarpClient <--> WireGuard
    WarpClient <--> PsiphonInt
    IPScanner --> WarpClient
    Config --> WarpClient
    Config --> SOCKS
    Config --> WireGuard
    App --> WarpClient
    App --> SOCKS
    
    WireGuard --> CloudflareWarp
    PsiphonInt --> PsiphonNet
    CloudflareWarp --> DNS
    PsiphonNet --> CloudflareWarp

    %% Click Events
    click SOCKS "https://github.com/bepass-org/warp-plus/tree/master//proxy/pkg/socks5"
    click WarpClient "https://github.com/bepass-org/warp-plus/tree/master//warp"
    click PsiphonInt "https://github.com/bepass-org/warp-plus/blob/master//psiphon/p.go"
    click WireGuard "https://github.com/bepass-org/warp-plus/tree/master//wireguard"
    click IPScanner "https://github.com/bepass-org/warp-plus/tree/master//ipscanner"
    click Config "https://github.com/bepass-org/warp-plus/blob/master//wiresocks/config.go"
    click TUN "https://github.com/bepass-org/warp-plus/blob/master//app/tun_windows.go"
    click App "https://github.com/bepass-org/warp-plus/blob/master//app/app.go"

    %% Styling
    classDef warp fill:#3498db
    classDef proxy fill:#2ecc71
    classDef psiphon fill:#e74c3c
    classDef wireguard fill:#9b59b6
    classDef scanner fill:#f1c40f
    classDef config fill:#1abc9c
    classDef external fill:#95a5a6
    classDef app fill:#34495e

    %% Legend
    subgraph Legend
        L1["Core Components"]:::warp
        L2["Proxy Components"]:::proxy
        L3["Psiphon Integration"]:::psiphon
        L4["WireGuard Protocol"]:::wireguard
        L5["Scanner System"]:::scanner
        L6["Configuration"]:::config
        L7["External Services"]:::external
        L8["Application Core"]:::app
    end
```
