# klierbyck/clash-verge-rev-rules architecture

> Architecture diagram of the GitHub repository klierbyck/clash-verge-rev-rules, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/klierbyck/clash-verge-rev-rules
- Repository: https://github.com/klierbyck/clash-verge-rev-rules

## Overview

This repository provides Clash Verge Rev/Mihomo global-extension scripts for traffic routing. The user installs either the HTTP-rule or local-rule variant, after which `main` validates a subscribed proxy config and adds rule providers, ordered routing rules, and proxy groups. Traffic matches AI, GitHub, Telegram, media, or global rule sets, falls back to the domestic group, and can use regional auto-selection or an optional chained residential proxy. The scripts were sampled; the rule-set YAML contents were not, so their internal matching details are omitted.

Main entry points: [`script_http.js`](https://github.com/klierbyck/clash-verge-rev-rules/blob/master/script_http.js) (Service groups), [`script_local.js`](https://github.com/klierbyck/clash-verge-rev-rules/blob/master/script_local.js) (Local script), [`ruleset/ai.yaml`](https://github.com/klierbyck/clash-verge-rev-rules/blob/master/ruleset/ai.yaml) (AI rules), [`ruleset/github.yaml`](https://github.com/klierbyck/clash-verge-rev-rules/blob/master/ruleset/github.yaml) (GitHub rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Client Setup"]
  node_client["Clash Verge Rev"]
  node_http_script["HTTP script<br/>[script_http.js]"]
  node_local_script["Local script<br/>[script_local.js]"]
end

subgraph group_routing["Rule Routing"]
  node_main["Config transform<br/>[script_http.js]"]
  node_rule_config["Routing rules<br/>[script_http.js]"]
  node_rule_groups["Service groups<br/>[script_http.js]"]
end

subgraph group_proxies["Proxy Selection"]
  node_regional["Regional auto groups<br/>[script_http.js]"]
  node_residential["Residential chain<br/>[script_http.js]"]
  node_proxy_nodes["Subscribed proxies"]
end

subgraph group_sources["Rule Sources"]
  node_ai["AI rules<br/>[ai.yaml]"]
  node_github["GitHub rules<br/>[github.yaml]"]
  node_telegram["Telegram rules<br/>[telegram.yaml]"]
  node_media["Media rules<br/>[media.yaml]"]
  node_global["Global rules<br/>[global.yaml]"]
  node_remote_rules["Remote rule files"]
end

node_user(("Clash user"))
node_destination(("Target traffic"))

node_user -->|"configures"| node_client
node_user -->|"installs"| node_http_script
node_user -->|"installs"| node_local_script
node_client -->|"runs script"| node_main
node_http_script -->|"defines entry"| node_main
node_local_script -->|"defines variant"| node_main
node_main -->|"sets rules"| node_rule_config
node_main -->|"sets groups"| node_rule_groups
node_main -->|"adds residential node"| node_proxy_nodes
node_rule_config -->|"matches set"| node_ai
node_rule_config -->|"matches set"| node_github
node_rule_config -->|"matches set"| node_telegram
node_rule_config -->|"matches set"| node_media
node_rule_config -->|"matches set"| node_global
node_rule_config -.->|"fetches sets"| node_remote_rules
node_ai -->|"routes to AI"| node_rule_groups
node_github -->|"routes to GitHub"| node_rule_groups
node_telegram -->|"routes to Telegram"| node_rule_groups
node_media -->|"routes to media"| node_rule_groups
node_global -->|"routes abroad"| node_rule_groups
node_rule_groups -->|"offers exits"| node_regional
node_rule_groups -->|"offers chain"| node_residential
node_regional -->|"selects by region"| node_proxy_nodes
node_residential -->|"dials through"| node_regional
node_rule_groups -->|"routes traffic"| node_destination
node_residential -->|"forwards traffic"| node_destination

click node_http_script "https://github.com/klierbyck/clash-verge-rev-rules/blob/master/script_http.js"
click node_local_script "https://github.com/klierbyck/clash-verge-rev-rules/blob/master/script_local.js"
click node_main "https://github.com/klierbyck/clash-verge-rev-rules/blob/master/script_http.js"
click node_rule_config "https://github.com/klierbyck/clash-verge-rev-rules/blob/master/script_http.js"
click node_rule_groups "https://github.com/klierbyck/clash-verge-rev-rules/blob/master/script_http.js"
click node_regional "https://github.com/klierbyck/clash-verge-rev-rules/blob/master/script_http.js"
click node_residential "https://github.com/klierbyck/clash-verge-rev-rules/blob/master/script_http.js"
click node_ai "https://github.com/klierbyck/clash-verge-rev-rules/blob/master/ruleset/ai.yaml"
click node_github "https://github.com/klierbyck/clash-verge-rev-rules/blob/master/ruleset/github.yaml"
click node_telegram "https://github.com/klierbyck/clash-verge-rev-rules/blob/master/ruleset/telegram.yaml"
click node_media "https://github.com/klierbyck/clash-verge-rev-rules/blob/master/ruleset/media.yaml"
click node_global "https://github.com/klierbyck/clash-verge-rev-rules/blob/master/ruleset/global.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client,node_http_script,node_local_script,node_user toneBlue
class node_main,node_rule_config,node_rule_groups toneAmber
class node_regional,node_residential,node_proxy_nodes toneMint
class node_ai,node_github,node_telegram,node_media,node_global,node_remote_rules toneRose
class node_destination toneIndigo
```

## Components

### Client Setup

- **Clash Verge Rev**
- [HTTP script](https://github.com/klierbyck/clash-verge-rev-rules/blob/master/script_http.js): `script_http.js`
- [Local script](https://github.com/klierbyck/clash-verge-rev-rules/blob/master/script_local.js): `script_local.js`

### Rule Routing

- [Config transform](https://github.com/klierbyck/clash-verge-rev-rules/blob/master/script_http.js): `script_http.js`
- [Routing rules](https://github.com/klierbyck/clash-verge-rev-rules/blob/master/script_http.js): `script_http.js`
- [Service groups](https://github.com/klierbyck/clash-verge-rev-rules/blob/master/script_http.js): `script_http.js`

### Proxy Selection

- [Regional auto groups](https://github.com/klierbyck/clash-verge-rev-rules/blob/master/script_http.js): `script_http.js`
- [Residential chain](https://github.com/klierbyck/clash-verge-rev-rules/blob/master/script_http.js): `script_http.js`
- **Subscribed proxies**

### Rule Sources

- [AI rules](https://github.com/klierbyck/clash-verge-rev-rules/blob/master/ruleset/ai.yaml): `ruleset/ai.yaml`
- [GitHub rules](https://github.com/klierbyck/clash-verge-rev-rules/blob/master/ruleset/github.yaml): `ruleset/github.yaml`
- [Telegram rules](https://github.com/klierbyck/clash-verge-rev-rules/blob/master/ruleset/telegram.yaml): `ruleset/telegram.yaml`
- [Media rules](https://github.com/klierbyck/clash-verge-rev-rules/blob/master/ruleset/media.yaml): `ruleset/media.yaml`
- [Global rules](https://github.com/klierbyck/clash-verge-rev-rules/blob/master/ruleset/global.yaml): `ruleset/global.yaml`
- **Remote rule files**

### Other components

- **Clash user**
- **Target traffic**

## Connections

- Clash user → Clash Verge Rev: configures
- Clash user → HTTP script: installs
- Clash user → Local script: installs
- Clash Verge Rev → Config transform: runs script
- HTTP script → Config transform: defines entry
- Local script → Config transform: defines variant
- Config transform → Routing rules: sets rules
- Config transform → Service groups: sets groups
- Config transform → Subscribed proxies: adds residential node
- Routing rules → AI rules: matches set
- Routing rules → GitHub rules: matches set
- Routing rules → Telegram rules: matches set
- Routing rules → Media rules: matches set
- Routing rules → Global rules: matches set
- Routing rules → Remote rule files: fetches sets
- AI rules → Service groups: routes to AI
- GitHub rules → Service groups: routes to GitHub
- Telegram rules → Service groups: routes to Telegram
- Media rules → Service groups: routes to media
- Global rules → Service groups: routes abroad
- Service groups → Regional auto groups: offers exits
- Service groups → Residential chain: offers chain
- Regional auto groups → Subscribed proxies: selects by region
- Residential chain → Regional auto groups: dials through
- Service groups → Target traffic: routes traffic
- Residential chain → Target traffic: forwards traffic
