Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Architecture

This section describes xrat’s internal architecture, data flow, and module structure for developers and contributors.

Context Diagram

graph TB
    classDef user   fill:#3a2c1a,stroke:#dfa85b,color:#e6edf3
    classDef iface  fill:#1a2e1a,stroke:#5bdf8a,color:#e6edf3
    classDef core   fill:#1a2c3a,stroke:#5b8def,color:#e6edf3
    classDef engine fill:#1a3a1a,stroke:#5bdf5b,color:#e6edf3
    classDef store  fill:#1a3a3a,stroke:#5bdfd3,color:#e6edf3
    User(("User")):::user

    subgraph interfaces[" "]
        TUI["TUI"]:::iface
        CLI["CLI"]:::iface
        API["HTTP API"]:::iface
    end

    Daemon["xrat Core<br/>Daemon Supervisor"]:::core

    subgraph engines["Proxy Engines"]
        Xray["Xray-core"]:::engine
        SingBox["sing-box"]:::engine
    end

    DB[("SQLite / Postgres")]:::store

    User -- "HTTP" --> API
    User --> TUI
    User --> CLI

    TUI -- "IPC" --> Daemon
    CLI -- "IPC" --> Daemon

    Daemon -- "spawns" --> Xray
    Daemon -- "spawns" --> SingBox

    CLI --> DB
    Daemon --> DB
    API --> DB

Pages

PageDescription
Module StructureSource tree, module responsibilities, dependency graph
Config GenerationHow engine JSON configs are generated from nodes
Import PipelineEnd-to-end subscription import flow
Daemon ArchitectureDaemon process, IPC protocol, supervisor event loop
Runtime LifecycleSession state machine, connect/replace/disconnect flows
Test PipelineProbe execution, test stages, output formatting
Database SchemaFull SQL DDL and per-table column reference