# legiz-ru/sb-rule-sets architecture

> Architecture diagram of the GitHub repository legiz-ru/sb-rule-sets, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/legiz-ru/sb-rule-sets
- Repository: https://github.com/legiz-ru/sb-rule-sets

## Overview

##### High-Level Architecture Components
a. Upstream Data Sources
- External GitHub repos or URLs providing raw lists (e.g., itdoginfo, no-russia-hosts, discord-voice-ips).
b. GitHub Repository (legiz-ru/sb-rule-sets)
- Stores raw JSON definitions, compiled .srs files, and metadata (lst).
- Contains folder `.github/workflows` with CI pipelines.
c. CI/CD Pipeline (GitHub Actions)
- Triggers on pushes to `main`.
- Steps: fetch upstream lists, generate JSON rule-sets, compile to .srs (binary), commit artifacts, tag releases.
- Deploys static files to GitHub Pages or makes them available via jsDelivr CDN.
d. Artifact Hosting
- GitHub raw URLs + jsDelivr CDN endpoints serve `.json`, `.srs`, and `.lst`.
e. Clients / Consumers

##### Relationships and Data Flows
- CI Pipeline → GitHub Repo (commit new JSON/.srs).
- GitHub Repo → jsDelivr (CDN cache).
- Clients ← Raw URLs (https://raw.githubusercontent.com/.../*.json) or CDN URLs.
- Clients download JSON or binary .srs at runtime to apply routing rules.

##### Architectural Patterns & Principles
- “Pipeline” pattern: raw data ingestion → transformation → publication.
- Separation of concerns: upstream list definitions vs. compiled binary rule-sets vs. distribution templates.
- Extensibility: adding a new rule-set involves dropping JSON and a build step.

##### Technologies & Frameworks
- GitHub Actions for CI/CD.
- JSON for source rule-sets; custom `.srs` binary format.
- GitHub Pages/jsDelivr for static hosting.

##### Essential Details to Capture
- Each rule-set’s dual format outputs (`source` vs. `binary`).
- The .lst index file for vpnbot.
- CI triggers and deployment paths.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Data Sources
    subgraph "External Data Sources"
        ext1["ItDogInfo Repo"]:::external
        ext2["No-Russia-Hosts Repo"]:::external
        ext3["Discord-Voice-IP List Repo"]:::external
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        srs["srs.yml"]:::process
        jsdeliv["jsDelivr.yml"]:::process
    end

    %% GitHub Repository
    subgraph "GitHub Repository (legiz-ru/sb-rule-sets)"
        repo["Repository"]:::storage

        subgraph "Rule-set Definitions (raw JSON)"
            json1["discord-voice-ip-list.json"]:::storage
            json2["itdoginfo-inside-russia.json"]:::storage
            json3["no-russia-hosts.json"]:::storage
            json4["ru-app-list.json"]:::storage
            json5["ru-bundle.json"]:::storage
            json6["torrent-clients.json"]:::storage
            json7["unbanru-app-list.json"]:::storage
        end

        subgraph "Compiled Rule-sets (binary .srs)"
            bin1["discord-voice-ip-list.srs"]:::storage
            bin2["itdoginfo-inside-russia.srs"]:::storage
            bin3["no-russia-hosts.srs"]:::storage
            bin4["ru-app-list.srs"]:::storage
            bin5["ru-bundle.srs"]:::storage
            bin6["torrent-clients.srs"]:::storage
            bin7["unbanru-app-list.srs"]:::storage
            bin8["viber_aws_ip.srs"]:::storage
        end

        lst["ru-bundle.lst"]:::storage

        subgraph "Template Bundles (.github/sub2sing-box)"
            tpl1["ru-bundle.json"]:::storage
            tpl2["ru-bundle-refilter.json"]:::storage
            tpl3["ru-bundle-oisd-big.json"]:::storage
            tpl4["re-filter.json"]:::storage
            tpl5["secret-sing-box.json"]:::storage
            tpl6["secret-sing-box_sb1-10.json"]:::storage
            tpl7["ru-bundle_sb1-10.json"]:::storage
            tpl8["README.md"]:::docs
        end

        README["README.md"]:::docs
    end

    %% Artifact Hosting
    subgraph "Artifact Hosting"
        raw["GitHub Raw URLs"]:::storage
        cdn["jsDelivr CDN"]:::storage
    end

    %% Clients / Consumers
    subgraph "Clients / Consumers"
        sb["Sing-Box"]:::client
        vpnbot["vpnbot"]:::client
        xray["Xray"]:::client
    end

    %% Connections
    ext1 -->|fetch| srs
    ext2 -->|fetch| srs
    ext3 -->|fetch| srs

    srs -->|build & commit| repo

    repo --> raw
    repo --> cdn

    raw -->|download .json/.srs| sb
    raw -->|download .json/.srs| vpnbot
    raw -->|download .json/.srs| xray

    cdn -->|download .json/.srs| sb
    cdn -->|download .json/.srs| vpnbot
    cdn -->|download .json/.srs| xray

    %% Click Events
    click json1 "https://github.com/legiz-ru/sb-rule-sets/blob/main/discord-voice-ip-list.json"
    click json2 "https://github.com/legiz-ru/sb-rule-sets/blob/main/itdoginfo-inside-russia.json"
    click json3 "https://github.com/legiz-ru/sb-rule-sets/blob/main/no-russia-hosts.json"
    click json4 "https://github.com/legiz-ru/sb-rule-sets/blob/main/ru-app-list.json"
    click json5 "https://github.com/legiz-ru/sb-rule-sets/blob/main/ru-bundle.json"
    click json6 "https://github.com/legiz-ru/sb-rule-sets/blob/main/torrent-clients.json"
    click json7 "https://github.com/legiz-ru/sb-rule-sets/blob/main/unbanru-app-list.json"

    click bin1 "https://github.com/legiz-ru/sb-rule-sets/blob/main/discord-voice-ip-list.srs"
    click bin2 "https://github.com/legiz-ru/sb-rule-sets/blob/main/itdoginfo-inside-russia.srs"
    click bin3 "https://github.com/legiz-ru/sb-rule-sets/blob/main/no-russia-hosts.srs"
    click bin4 "https://github.com/legiz-ru/sb-rule-sets/blob/main/ru-app-list.srs"
    click bin5 "https://github.com/legiz-ru/sb-rule-sets/blob/main/ru-bundle.srs"
    click bin6 "https://github.com/legiz-ru/sb-rule-sets/blob/main/torrent-clients.srs"
    click bin7 "https://github.com/legiz-ru/sb-rule-sets/blob/main/unbanru-app-list.srs"
    click bin8 "https://github.com/legiz-ru/sb-rule-sets/blob/main/viber_aws_ip.srs"

    click lst "https://github.com/legiz-ru/sb-rule-sets/blob/main/ru-bundle.lst"

    click srs "https://github.com/legiz-ru/sb-rule-sets/blob/main/.github/workflows/srs.yml"
    click jsdeliv "https://github.com/legiz-ru/sb-rule-sets/blob/main/.github/workflows/jsDelivr.yml"

    click tpl1 "https://github.com/legiz-ru/sb-rule-sets/blob/main/.github/sub2sing-box/ru-bundle.json"
    click tpl2 "https://github.com/legiz-ru/sb-rule-sets/blob/main/.github/sub2sing-box/ru-bundle-refilter.json"
    click tpl3 "https://github.com/legiz-ru/sb-rule-sets/blob/main/.github/sub2sing-box/ru-bundle-oisd-big.json"
    click tpl4 "https://github.com/legiz-ru/sb-rule-sets/blob/main/.github/sub2sing-box/re-filter.json"
    click tpl5 "https://github.com/legiz-ru/sb-rule-sets/blob/main/.github/sub2sing-box/secret-sing-box.json"
    click tpl6 "https://github.com/legiz-ru/sb-rule-sets/blob/main/.github/sub2sing-box/secret-sing-box_sb1-10.json"
    click tpl7 "https://github.com/legiz-ru/sb-rule-sets/blob/main/.github/sub2sing-box/ru-bundle_sb1-10.json"
    click tpl8 "https://github.com/legiz-ru/sb-rule-sets/blob/main/.github/sub2sing-box/README.md"

    click README "https://github.com/legiz-ru/sb-rule-sets/blob/main/README.md"

    %% Styles
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef process fill:#8BC34A,stroke:#333,stroke-width:1px
    classDef storage fill:#2196F3,stroke:#333,stroke-width:1px
    classDef client fill:#9C27B0,stroke:#333,stroke-width:1px
    classDef docs fill:#607D8B,stroke:#333,stroke-width:1px
```
