# legiz-ru/mihomo-rule-sets architecture

> Architecture diagram of the GitHub repository legiz-ru/mihomo-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/mihomo-rule-sets
- Repository: https://github.com/legiz-ru/mihomo-rule-sets

## Overview

##### Project Type and Purpose
- This is an open-source “rule-sets” repository for Mihomo (clash-meta) and related proxy/VPN tools.
- It doesn’t implement a running service or UI—it hosts static rule files (.mrs binary sets and .yaml definitions) organized by category (ru-bundle, oisd, re-filter, other).

##### File-Structure Analysis
- Top-level directories:
- .github/workflows: CI definitions (jsDelivr.yml, main.yml)
- ru-bundle, oisd, re-filter, other: Each contains rule-set sources (.yaml) and prebuilt binaries (.mrs)
- examples: sample YAML usages
- README.md: usage instructions and metadata
- No “src” or server code—content-only repository.
- Workflows indicate an automated build/publish pipeline, pushing to GitHub raw URLs and external CDN.

##### Main Components
a. Source Code & Rule Definitions
- GitHub Repo
- Directories: ru-bundle, oisd, re-filter, other (source YAML + checked-in .mrs)
b. CI/CD Pipeline
- GitHub Actions (main.yml builds .mrs, jsDelivr.yml publishes to CDN)
c. Artifact Storage & Distribution
- GitHub raw URLs (raw.githubusercontent.com)
- jsDelivr CDN endpoints
d. Consumers

##### Component Interactions and Data Flow
- Developer Commit → triggers GitHub Actions
- Actions → compile or validate rule files → output .mrs binaries
- Actions → push artifacts to GitHub (committed .mrs or GitHub Releases)
- jsDelivr Workflow → mirrors files to CDN
- End-User Clients → fetch rule-sets from raw GitHub URLs or jsDelivr
- Clients apply rules in their proxy/VPN pipelines

##### Architectural Patterns and Principles
- “Content Pipeline” pattern: source → build → publish → consume
- Infrastructure-as-Code: workflows themselves are code in the repo
- CDN distribution for global performance and availability
- Immutable artifacts (.mrs binaries) to ensure consistency

##### Relevant Technologies
- GitHub (version control + raw file hosting)
- GitHub Actions (CI/CD)
- jsDelivr (public CDN)
- YAML (rule definitions) + custom binary format (.mrs)
- Mihomo/Clash/Vpnbot clients consuming HTTP rule-providers

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% GitHub Repo Layer
    subgraph "GitHub Repository"
        direction TB
        RU["ru-bundle\n(YAML + MRS)"]:::storage
        OISD["oisd\n(MRS)"]:::storage
        REF["re-filter\n(YAML + MRS)"]:::storage
        OTHER["other\n(YAML + MRS/JSON)"]:::storage
        EXAMPLES["examples"]:::storage
        README["README.md"]:::storage
    end

    %% CI/CD Layer
    subgraph "CI/CD Pipeline"
        direction TB
        BUILD["Build Workflow\n(.github/workflows/main.yml)"]:::cicd
        AUX["Aux Config\n(.github/workflows/v2ray-marzban-base.json)"]:::cicd
        PUBLISH["Publish Workflow\n(.github/workflows/jsDelivr.yml)"]:::cicd
    end

    %% Distribution Layer
    subgraph "Distribution"
        direction TB
        RAW["GitHub Raw URLs"]:::dist
        CDN["jsDelivr CDN"]:::dist
    end

    %% Consumers Layer
    subgraph "Consumers"
        direction TB
        MIHOMO["Mihomo Client"]:::client
        CLASH["Clash"]:::client
        VPNBOT["vpnbot / Sing-box"]:::client
    end

    %% Connections
    RU -->|"trigger build"| BUILD
    OISD -->|"trigger build"| BUILD
    REF -->|"trigger build"| BUILD
    OTHER -->|"trigger build"| BUILD
    EXAMPLES -->|"trigger build"| BUILD
    README -->|"trigger build"| BUILD

    BUILD -->|"upload .mrs"| RAW
    BUILD -->|"prepare publish"| PUBLISH
    AUX -->|"support workflows"| BUILD

    PUBLISH -->|"mirror artifacts"| CDN

    RAW -->|"fetch rules"| MIHOMO
    RAW -->|"fetch rules"| CLASH
    RAW -->|"fetch rules"| VPNBOT

    CDN -->|"fetch rules"| MIHOMO
    CDN -->|"fetch rules"| CLASH
    CDN -->|"fetch rules"| VPNBOT

    %% Click Events
    click RU "https://github.com/legiz-ru/mihomo-rule-sets/tree/main/ru-bundle"
    click OISD "https://github.com/legiz-ru/mihomo-rule-sets/tree/main/oisd"
    click REF "https://github.com/legiz-ru/mihomo-rule-sets/tree/main/re-filter"
    click OTHER "https://github.com/legiz-ru/mihomo-rule-sets/tree/main/other"
    click EXAMPLES "https://github.com/legiz-ru/mihomo-rule-sets/tree/main/examples"
    click README "https://github.com/legiz-ru/mihomo-rule-sets/blob/main/README.md"
    click BUILD "https://github.com/legiz-ru/mihomo-rule-sets/blob/main/.github/workflows/main.yml"
    click PUBLISH "https://github.com/legiz-ru/mihomo-rule-sets/blob/main/.github/workflows/jsDelivr.yml"
    click AUX "https://github.com/legiz-ru/mihomo-rule-sets/blob/main/.github/workflows/v2ray-marzban-base.json"

    %% Styles
    classDef storage fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef cicd fill:#90EE90,stroke:#333,stroke-width:1px
    classDef dist fill:#FFA500,stroke:#333,stroke-width:1px
    classDef client fill:#D3D3D3,stroke:#333,stroke-width:1px
```
