# snapei/clash-pro-rules architecture

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

- Interactive diagram: https://gitdiagram.com/snapei/clash-pro-rules
- Repository: https://github.com/snapei/clash-pro-rules

## Overview

1. This repository is not an application runtime; it is a curated data distribution repo for Clash / Mihomo rule-provider lists. Its “product” is a set of plain-text rule files that external Clash clients fetch over HTTP and convert into routing decisions.

2. The core assets are the `.txt` lists in the repo root. They fall into two broad data types:
- domain-based lists such as `apple.txt`, `google.txt`, `youtube.txt`, `telegram.txt`, `tiktok.txt`, `ai.txt`, `github.txt`, `workspace.txt`, `multimedia.txt`, `proxy.txt`
- IP-CIDR-based lists such as `cncidr.txt`, `netflixcidr.txt`, `telegramcidr.txt`, `metacidr.txt`, `applecidr.txt`, `youtubecidr.txt`, `lancidr.txt`, `microsoft.txt`’s domain counterpart only, etc.

3. Each list is a separately consumable boundary. In Clash terms, these map to `rule-providers` with different `behavior` settings:
- `behavior: domain` for hostname/domain matching
- `behavior: ipcidr` for IP range matching  
That separation is important because the client treats domain and IP rules differently in both matching and resolution behavior.

4. The repository’s routing model is policy-driven. The lists are not “actions” by themselves; they are inputs that select a policy name in the consumer’s Clash config, such as `DIRECT`, `PROXY`, or custom groups like `GOOGLE`, `YOUTUBE`, `NETFLIX`. The README explicitly shows service-specific policy wiring rather than hardcoded behavior in the repo.

5. Rule precedence is part of the architecture. The recommended consumer rule order is:
- process-name exclusions first
- local/LAN IP ranges next
- reject lists
- service-specific direct rules (`icloud`, `apple`)
- service-specific proxy groups (`google`, `youtube`, `netflix`, `telegram`, `tiktok`, `proxy`)
- generic direct lists
- final `GEOIP,CN,DIRECT`
- default catch-all `MATCH,PROXY`  
So the repo is designed to feed a layered routing pipeline, not a flat list.

6. There are three major rule families represented by the filenames:
- “major platforms” and vendors: Apple, Google, Microsoft, Amazon, GitHub, Meta, Android
- “traffic destinations” and apps: YouTube, Netflix, Telegram, TikTok, X, socials, workspace, multimedia
- “network policy” and catch-all control lists: `direct.txt`, `reject.txt`, `gfw.txt`, `greatfire.txt`, `proxy.txt`, `tld-not-cn.txt`  
These families imply different downstream routing intents: bypass, proxy, block, or classification.

7. The repo has a clear upstream-data boundary. The README names the sources used to assemble the lists, including:
- Loyalsoldier `v2ray-rules-dat` and `clash-rules`
- `v2fly/domain-list-community`
- `felixonmars/dnsmasq-china-list`
- `17mon/china_ip_list`  
This means the repo is a consolidation layer over multiple external datasets rather than a primary source of truth.

8. The delivery boundary is GitHub raw hosting and jsDelivr CDN. The README instructs consumers to fetch files from `raw.githubusercontent.com` or `cdn.jsdelivr.net`, so the repo acts as a static origin for rule-provider URLs, with CDN fallback for availability.

9. The consumer boundary is the Clash/Mihomo client configuration. Nothing in the repo runs server-side; all logic happens in the client after download. The repo’s role is to supply stable URLs and file contents that the client periodically refreshes, typically on a 24-hour interval.

10. The repo also encodes platform-specific constraints in the README:
- it is intended for Clash and Mihomo
- `PROCESS-NAME` rules are only supported in ClashX Pro
- `no-resolve` is used selectively on some CIDR rules to avoid DNS resolution  
These details matter for architecture because they affect which client capabilities the data set assumes.

11. The maintenance/tooling surface is minimal. `clash-format.yaml` suggests formatting or linting support for the rule files, and `config.yaml` likely holds generation or packaging configuration. But there is no evidence of a build service, API layer, database, or dynamic backend in the repository itself.

12. In diagram terms, the repository is best modeled as a static rule-data publisher:
upstream community lists and curated sources feed this repo’s text artifacts, which are hosted via GitHub/CDN, which are then consumed by Clash rule-providers to drive routing decisions across direct, proxy, and reject paths.

Main entry points: [`README.md`](https://github.com/snapei/clash-pro-rules/blob/main/README.md) (README)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_upstream["Upstream sources"]
  node_upstream_sources[("Community sources<br/>dataset inputs")]
end

subgraph group_repo["Repository assets"]
  node_readme["README<br/>docs<br/>[README.md]"]
  node_tooling["Tooling<br/>format/config"]
  node_domain_lists["Domain lists<br/>rule files"]
  node_cidr_lists["CIDR lists<br/>rule files"]
  node_platform_lists["Platform lists<br/>service domains"]
  node_app_lists["App lists<br/>service domains"]
  node_control_lists["Control lists<br/>routing lists"]
end

subgraph group_consumer["Consumer side"]
  node_github_raw["GitHub raw<br/>origin hosting"]
  node_cdn_jsdelivr["jsDelivr CDN<br/>cdn mirror"]
  node_rule_providers["Rule providers<br/>clash config"]
  node_clash_client["Clash/Mihomo<br/>client runtime"]
  node_direct_policy(("DIRECT<br/>routing policy"))
  node_proxy_policy(("PROXY<br/>routing policy"))
  node_reject_policy(("REJECT<br/>routing policy"))
end

node_upstream_sources -->|"feed"| node_domain_lists
node_upstream_sources -->|"feed"| node_cidr_lists
node_upstream_sources -->|"feed"| node_control_lists
node_readme -->|"documents"| node_rule_providers
node_readme -->|"documents"| node_clash_client
node_tooling -->|"supports"| node_domain_lists
node_tooling -->|"supports"| node_cidr_lists
node_domain_lists -->|"contains"| node_platform_lists
node_domain_lists -->|"contains"| node_app_lists
node_cidr_lists -->|"pairs with"| node_platform_lists
node_control_lists -->|"routes to"| node_direct_policy
node_control_lists -->|"routes to"| node_proxy_policy
node_control_lists -->|"routes to"| node_reject_policy
node_domain_lists -->|"published as"| node_rule_providers
node_cidr_lists -->|"published as"| node_rule_providers
node_control_lists -->|"published as"| node_rule_providers
node_github_raw -->|"fetches from"| node_rule_providers
node_cdn_jsdelivr -->|"fetches from"| node_rule_providers
node_rule_providers -->|"refreshes"| node_clash_client
node_clash_client -->|"matches"| node_direct_policy
node_clash_client -->|"matches"| node_proxy_policy
node_clash_client -->|"matches"| node_reject_policy

click node_readme "https://github.com/snapei/clash-pro-rules/blob/main/README.md"

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_upstream_sources toneBlue
class node_readme,node_tooling,node_domain_lists,node_cidr_lists,node_platform_lists,node_app_lists,node_control_lists toneAmber
class node_github_raw,node_cdn_jsdelivr,node_rule_providers,node_clash_client,node_direct_policy,node_proxy_policy,node_reject_policy toneMint
```

## Components

### Upstream sources

External community datasets consolidated into the repo.

- **Community sources**: dataset inputs · External rule and IP datasets used to assemble the lists.

### Repository assets

Static rule files and lightweight packaging/formatting support.

- [README](https://github.com/snapei/clash-pro-rules/blob/main/README.md): docs · Documents rule-provider usage, precedence, delivery URLs, and client assumptions. · `README.md`
- **Tooling**: format/config · Minimal repo tooling for formatting and generation/packaging support.
- **Domain lists**: rule files · Hostname/domain-based rule-provider lists such as major platforms and services.
- **CIDR lists**: rule files · IP-CIDR rule-provider lists for network ranges and geo/IP matching.
- **Platform lists**: service domains · Vendor and platform coverage such as Apple, Google, Microsoft, Amazon, GitHub, Meta, Android.
- **App lists**: service domains · Traffic destinations and app-oriented lists such as YouTube, Netflix, Telegram, TikTok, X, socials, workspace, multimedia.
- **Control lists**: routing lists · Direct, proxy, reject, GFW, greatfire, and tld-not-cn control inputs for routing precedence.

### Consumer side

GitHub/CDN delivery and Clash/Mihomo rule-provider consumption.

- **GitHub raw**: origin hosting · Primary static origin used by consumers to fetch rule files.
- **jsDelivr CDN**: cdn mirror · Fallback delivery path for the same static rule files.
- **Rule providers**: clash config · Clash/Mihomo rule-provider entries that point at the hosted text files.
- **Clash/Mihomo**: client runtime · External client that refreshes rule-provider files and applies match behavior.
- **DIRECT**: routing policy · Bypass path selected by direct-oriented rule lists.
- **PROXY**: routing policy · Proxy path selected by proxy-oriented service lists.
- **REJECT**: routing policy · Block path selected by reject and block-oriented lists.

## Connections

- Community sources → Domain lists: feed · Community datasets are consolidated into domain-based rule files.
- Community sources → CIDR lists: feed · Community datasets are consolidated into IP-CIDR rule files.
- Community sources → Control lists: feed · Upstream lists inform direct, proxy, reject, and block controls.
- README → Rule providers: documents · README explains the provider URLs, behaviors, and usage patterns.
- README → Clash/Mihomo: documents · README describes client capabilities and rule precedence assumptions.
- Tooling → Domain lists: supports · Formatting/configuration helps keep the text artifacts consistent.
- Tooling → CIDR lists: supports · Formatting/configuration helps keep the CIDR artifacts consistent.
- Domain lists → Platform lists: contains · Domain-based lists include platform and vendor coverage.
- Domain lists → App lists: contains · Domain-based lists include app and destination coverage.
- CIDR lists → Platform lists: pairs with · Some services also have CIDR companions for IP-based matching.
- Control lists → DIRECT: routes to · Direct-oriented lists select bypass behavior in consumer configs.
- Control lists → PROXY: routes to · Proxy-oriented lists select upstream proxy groups in consumer configs.
- Control lists → REJECT: routes to · Reject and block-oriented lists select deny behavior.
- Domain lists → Rule providers: published as · Domain rule files are exposed as Clash/Mihomo rule providers.
- CIDR lists → Rule providers: published as · CIDR rule files are exposed as Clash/Mihomo rule providers.
- Control lists → Rule providers: published as · Control lists are also consumed through rule-provider entries.
- GitHub raw → Rule providers: fetches from · Primary consumer URL pattern is GitHub raw hosting.
- jsDelivr CDN → Rule providers: fetches from · jsDelivr mirrors the same static files as a CDN fallback.
- Rule providers → Clash/Mihomo: refreshes · The client periodically downloads and refreshes provider contents.
- Clash/Mihomo → DIRECT: matches · Rule evaluation can terminate on direct routing decisions.
- Clash/Mihomo → PROXY: matches · Rule evaluation can terminate on proxy routing decisions.
- Clash/Mihomo → REJECT: matches · Rule evaluation can terminate on reject routing decisions.
