# shadowsocksr-live/overtls architecture

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

- Interactive diagram: https://gitdiagram.com/shadowsocksr-live/overtls
- Repository: https://github.com/shadowsocksr-live/overtls

## Overview

##### Main Components Identification

The system should be represented with these key components:
- Client-side proxy service
- Server-side proxy service
- TLS layer
- SOCKS5 interface
- TCP/UDP relay handlers
- Web API/Status monitoring
- Configuration management

- SOCKS5 Interface (Entry point)
- Configuration Manager
- TCP/UDP Handlers
- TLS Client
- Traffic Audit/Status

- TLS Server
- Request Router
- TCP/UDP Forwarders
- Web API
- Certificate Manager

- Target Servers
- HTTP/HTTPS Services (nginx/caddy)
- DNS Services

##### Connection Flow Representation

- Initial SOCKS5 client connection
- TLS tunnel establishment
- Data flow through encrypted channel
- Forward connections to target servers

##### Implementation Details

- Traffic audit system (traffic_audit.rs)
- DNS handling (dns.rs)
- Web API interface (webapi.rs)
- Configuration management (config.rs)

##### Deployment Context

Deployment-related elements:
- Docker container boundaries
- System service integration
- Certificate management flow
- Health check mechanisms

- Clear separation between client and server components
- Explicit representation of the TLS tunnel
- Detailed flow of both TCP and UDP traffic
- Integration points with external services

Use standardized symbols:
- Rectangles for services/components
- Diamonds for decision points

- All symbols used
- Component groupings

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        SOCKS5[SOCKS5 Interface]
        ClientConfig[Configuration Manager]:::config
        ClientTCP[TCP Handler]:::handler
        ClientUDP[UDP Handler]:::handler
        ClientTLS[TLS Client]:::security
        TrafficAudit[Traffic Audit]:::monitoring
    end

    subgraph Server
        TLSServer[TLS Server]:::security
        Router[Request Router]:::core
        ServerTCP[TCP Forwarder]:::handler
        ServerUDP[UDP Forwarder]:::handler
        WebAPI[Web API]:::api
        CertManager[Certificate Manager]:::security
    end

    subgraph External
        TargetServers[Target Servers]:::external
        HTTPProxy[HTTP/HTTPS Services]:::external
        DNSService[DNS Services]:::external
    end

    %% Client-side connections
    SOCKS5 --> ClientConfig
    SOCKS5 --> ClientTCP
    SOCKS5 --> ClientUDP
    ClientTCP --> ClientTLS
    ClientUDP --> ClientTLS
    ClientConfig --> TrafficAudit
    
    %% Server-side connections
    ClientTLS <--> TLSServer
    TLSServer --> Router
    Router --> ServerTCP
    Router --> ServerUDP
    Router --> WebAPI
    TLSServer --> CertManager
    
    %% External connections
    ServerTCP --> TargetServers
    ServerUDP --> TargetServers
    ServerTCP --> HTTPProxy
    ServerUDP --> DNSService

    %% Click events
    click ClientConfig "https://github.com/shadowsocksr-live/overtls/blob/master/src/config.rs"
    click ClientTCP "https://github.com/shadowsocksr-live/overtls/blob/master/src/tcp_stream.rs"
    click ClientUDP "https://github.com/shadowsocksr-live/overtls/blob/master/src/udprelay.rs"
    click TrafficAudit "https://github.com/shadowsocksr-live/overtls/blob/master/src/traffic_audit.rs"
    click WebAPI "https://github.com/shadowsocksr-live/overtls/blob/master/src/webapi.rs"
    click Router "https://github.com/shadowsocksr-live/overtls/blob/master/src/api.rs"
    click DNSService "https://github.com/shadowsocksr-live/overtls/blob/master/src/dns.rs"
    click HTTPProxy "https://github.com/shadowsocksr-live/overtls/tree/master/docker_overtls_caddy/rootfs/etc/caddy/Caddyfile"
    click TLSServer "https://github.com/shadowsocksr-live/overtls/blob/master/src/tls.rs"
    click ClientTLS "https://github.com/shadowsocksr-live/overtls/blob/master/src/tls.rs"

    %% Styles
    classDef core fill:#2374ab
    classDef security fill:#57cc99
    classDef handler fill:#80ed99
    classDef api fill:#f48c06
    classDef monitoring fill:#9b5de5
    classDef config fill:#00b4d8
    classDef external fill:#grey

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Security Layer]:::security
        L3[Handlers]:::handler
        L4[API Services]:::api
        L5[Monitoring]:::monitoring
        L6[Configuration]:::config
        L7[External Services]:::external
    end
```
