# juewuy/shellcrash architecture

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

- Interactive diagram: https://gitdiagram.com/juewuy/shellcrash
- Repository: https://github.com/juewuy/shellcrash

## Overview

##### Main Components
- User Interaction Layer: Represent the shell/CLI interface through which a user interacts with ShellCrash. Indicate the installation scripts (install.sh) and startup scripts (e.g., scripts/start.sh, scripts/menu.sh).
- Script Orchestration Module: Group all the management scripts (under scripts/) that control tasks like initialization, periodic updates, and service management (e.g., scripts/task.sh, scripts/webget.sh).
- Clash & Clashpre binaries
- Singbox and Singboxp binaries
- Dashboard binaries (for the local web panel management)
- Meta and Fix binaries
- Configuration and Rules Engine: Include the “rules” directory that stores configuration files, rule sets for different modes (routing, native, etc.), and providers (both for Clash and Singbox). This component is key for dynamic configuration management.
- Geodata Component: Represent the “bin/geodata” folder which holds IP, DNS, and geo-location data files, critical for rule application in proxy management.
- Public Assets: The “public” directory providing additional resources, like lists (fake_ip_filter.list, servers.list, etc.) which might be used for real-time configuration update or fallback strategies.
- Automated CI/CD & Maintenance: Illustrate that GitHub workflows (in the .github/workflows/ folder) drive auto-updates, releases, and dependency maintenance. This shows how changes propagate from repository updates to deployment packages.

##### Relationships and Interactions
- That the User Interaction Layer triggers execution of the management scripts.
- The Script Orchestration Module calls the appropriate binaries from the Binary Repository and also applies configuration files from the Rules and Geodata components.
- The configuration files (including online provider configurations) affect the behavior of the binaries (Crash, Clash, Singbox).
- The Web Panel (dashboard) interacts with the binary dashboard and reflects operational status.
- CI/CD workflows (GitHub Actions) automatically update binaries and metadata, which in turn update the public binaries and configuration files.

##### Architectural Patterns
- Modular Design: Components are clearly separated – for instance, binaries are distinct from configuration files and from orchestration scripts.
- Dynamic Updates & Extensibility: The system supports online updates and configurations, so highlight pipelines from remote repositories (triggered by GitHub workflows) feeding into the binaries and rule provider modules.
- Multi-Platform Support: Emphasize that binaries are packaged for various architectures (amd64, arm, mips, etc.) which are organized under separate subdirectories within the “bin.”

##### Incorporate Relevant Technologies and Frameworks
- Use of shell scripting as the core technology.
- GitHub Actions for CI/CD.
- The built-in web panel (dashboard) for online configuration management.
- Use of compressed archives (tar.gz files) for distributing binaries.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction Layer
    subgraph "User Interaction Layer"
        UI1("Install Script"):::frontend
        UI2("Start Script"):::frontend
        UI3("Menu Script"):::frontend
        UI4("Dashboard UI"):::frontend
    end

    %% Script Orchestration Module
    subgraph "Script Orchestration Module"
        SO1("Init Script"):::orchestration
        SO2("Task Script"):::orchestration
        SO3("Webget Script"):::orchestration
        SO4("Misnap Init"):::orchestration
        SO5("Process Daemon"):::orchestration
        SO6("Service Manager"):::orchestration
    end

    %% Binary Repository & Distribution
    subgraph "Binary Repository & Distribution"
        BR1("Clash Binaries"):::binary
        BR2("Clashpre Binaries"):::binary
        BR3("Singbox Binaries"):::binary
        BR4("Singboxp Binaries"):::binary
        BR5("Dashboard Binaries"):::binary
        BR6("Fix Binaries"):::binary
        BR7("Meta Binaries"):::binary
        BR8("HFS Binaries"):::binary
    end

    %% Configuration and Rules Engine
    subgraph "Configuration and Rules Engine"
        CR1("Rules"):::config
        CR2("Clash Providers"):::config
        CR3("Singbox Providers"):::config
    end

    %% Geodata Component
    subgraph "Geodata Component"
        GD1("Geodata Files"):::geodata
    end

    %% Public Assets
    subgraph "Public Assets"
        PA1("Public Assets"):::public
    end

    %% Automated CI/CD & Maintenance
    subgraph "Automated CI/CD & Maintenance"
        CI1("CI/CD Workflows"):::cicd
    end

    %% Connections between components
    UI3 -->|"triggers"| SO1
    UI4 -->|"accesses"| BR5
    UI1 -->|"initiates"| SO6
    UI2 -->|"starts"| SO5

    SO2 -->|"calls"| BR1
    SO2 -->|"loads"| CR1
    SO2 -->|"fetches"| GD1

    CR1 -->|"configures"| BR1

    CI1 -->|"updates"| BR1
    CI1 -->|"updates"| BR7
    CI1 -->|"updates"| CR1

    %% Styling for vertical layout
    class UI1,UI2,UI3,UI4 frontend
    class SO1,SO2,SO3,SO4,SO5,SO6 orchestration
    class BR1,BR2,BR3,BR4,BR5,BR6,BR7,BR8 binary
    class CR1,CR2,CR3 config
    class GD1 geodata
    class PA1 public
    class CI1 cicd

    %% Click Events for User Interaction Layer
    click UI1 "https://github.com/juewuy/shellcrash/blob/dev/install.sh"
    click UI2 "https://github.com/juewuy/shellcrash/blob/dev/scripts/start.sh"
    click UI3 "https://github.com/juewuy/shellcrash/blob/dev/scripts/menu.sh"

    %% Click Events for Script Orchestration Module
    click SO1 "https://github.com/juewuy/shellcrash/blob/dev/scripts/init.sh"
    click SO2 "https://github.com/juewuy/shellcrash/blob/dev/scripts/task.sh"
    click SO3 "https://github.com/juewuy/shellcrash/blob/dev/scripts/webget.sh"
    click SO4 "https://github.com/juewuy/shellcrash/blob/dev/scripts/misnap_init.sh"
    click SO5 "https://github.com/juewuy/shellcrash/blob/dev/scripts/shellcrash.procd"
    click SO6 "https://github.com/juewuy/shellcrash/blob/dev/scripts/shellcrash.service"

    %% Click Events for Binary Repository & Distribution
    click BR1 "https://github.com/juewuy/shellcrash/tree/dev/bin/clash"
    click BR2 "https://github.com/juewuy/shellcrash/tree/dev/bin/clashpre"
    click BR3 "https://github.com/juewuy/shellcrash/tree/dev/bin/singbox"
    click BR4 "https://github.com/juewuy/shellcrash/tree/dev/bin/singboxp"
    click BR5 "https://github.com/juewuy/shellcrash/tree/dev/bin/dashboard"
    click BR6 "https://github.com/juewuy/shellcrash/tree/dev/bin/fix"
    click BR7 "https://github.com/juewuy/shellcrash/tree/dev/bin/meta"
    click BR8 "https://github.com/juewuy/shellcrash/tree/dev/bin/hfs"

    %% Click Events for Configuration and Rules Engine
    click CR1 "https://github.com/juewuy/shellcrash/tree/dev/rules"
    click CR2 "https://github.com/juewuy/shellcrash/tree/dev/rules/clash_providers"
    click CR3 "https://github.com/juewuy/shellcrash/tree/dev/rules/singbox_providers"

    %% Click Event for Geodata Component
    click GD1 "https://github.com/juewuy/shellcrash/tree/dev/bin/geodata"

    %% Click Event for Public Assets
    click PA1 "https://github.com/juewuy/shellcrash/tree/dev/public"

    %% Click Event for Automated CI/CD & Maintenance
    click CI1 "https://github.com/juewuy/shellcrash/tree/dev/.github/workflows"

classDef frontend fill:#ffd700,stroke:#333,stroke-width:2px;
classDef orchestration fill:#add8e6,stroke:#333,stroke-width:2px;
classDef binary fill:#90ee90,stroke:#333,stroke-width:2px;
classDef config fill:#ffb6c1,stroke:#333,stroke-width:2px;
classDef geodata fill:#d3d3d3,stroke:#333,stroke-width:2px;
classDef public fill:#ffa07a,stroke:#333,stroke-width:2px;
classDef cicd fill:#dda0dd,stroke:#333,stroke-width:2px;
```
