# backslashxx/bindhosts architecture

> Architecture diagram of the GitHub repository backslashxx/bindhosts, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/backslashxx/bindhosts
- Repository: https://github.com/backslashxx/bindhosts

## Overview

Key Components to Include:

##### Root Manager Layer
- APatch
- KernelSU
- Magisk

##### Core Module Components (Main Layer)
- Three sub-components for the main operational methods:
- Manager Mount
- Bind Mount
- OverlayFS
- Redirect methods as separate components:
- ZN-hostsredirect
- hosts_file_redirect
- open_redirect

##### Configuration and Control Layer
- WebUI component (webroot folder)
- Index.html, index.js, and styles.css
- Action Button Control
- Configuration Files:
- blacklist.txt
- whitelist.txt
- custom.txt
- sources.txt

##### Execution Scripts Layer
- action.sh
- bindhosts.sh
- customize.sh
- service.sh
- post-fs-data.sh
- utils.sh

##### Component Grouping
- Related components using containers or boundaries
- Use clear separation between different layers

**[Root Managers Layer]**
- ↓
**[WebUI & Control Layer] ←→ [Configuration Layer]**
- ↓
**[Core Module Layer]**
- ↓
**[Execution Scripts Layer]**

##### Supported operating modes

Level of Detail:

- Keep high-level architecture visible at first glance
- Use expandable/collapsible sections for detailed components
- Maintain clear boundaries between system layers
- Integration points with host system

Remember to:
- File paths for critical components
- Data flow between components
- Permission requirements
- Security-sensitive areas

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef rootManager fill:#b3d9ff,stroke:#333,stroke-width:2px
    classDef core fill:#90EE90,stroke:#333,stroke-width:2px
    classDef config fill:#FFE5CC,stroke:#333,stroke-width:2px
    classDef execution fill:#FFB366,stroke:#333,stroke-width:2px
    classDef webui fill:#E6E6FA,stroke:#333,stroke-width:2px
    classDef optional fill:#DCDCDC,stroke:#333,stroke-width:2px

    %% Root Manager Layer
    subgraph RootLayer["Root Management Layer"]
        APatch["APatch"]:::rootManager
        KernelSU["KernelSU"]:::rootManager
        Magisk["Magisk"]:::rootManager
        
        KsuWebUI["KsuWebUI"]:::optional
        MMRL["MMRL"]:::optional
        
        KernelSU -.-> KsuWebUI
        Magisk -.-> MMRL
    end

    %% WebUI & Configuration Layer
    subgraph ConfigLayer["Configuration & Control Layer"]
        WebUI["WebUI"]:::webui
        IndexHTML["index.html"]:::webui
        IndexJS["index.js"]:::webui
        StylesCSS["styles.css"]:::webui
        
        ConfigFiles["Configuration Files"]:::config
        Blacklist["blacklist.txt"]:::config
        Whitelist["whitelist.txt"]:::config
        Custom["custom.txt"]:::config
        Sources["sources.txt"]:::config
        
        WebUI --> IndexHTML
        WebUI --> IndexJS
        WebUI --> StylesCSS
        
        ConfigFiles --> Blacklist
        ConfigFiles --> Whitelist
        ConfigFiles --> Custom
        ConfigFiles --> Sources
    end

    %% Core Module Layer
    subgraph CoreLayer["Core Module Layer"]
        BindHosts["bindhosts Module"]:::core
        
        MountMethods["Mount Methods"]:::core
        ManagerMount["Manager Mount"]:::core
        BindMount["Bind Mount"]:::core
        OverlayFS["OverlayFS"]:::core
        
        RedirectMethods["Redirect Methods"]:::core
        ZNHosts["ZN-hostsredirect"]:::core
        HostsFile["hosts_file_redirect"]:::core
        OpenRedirect["open_redirect"]:::core
        
        MountMethods --> ManagerMount
        MountMethods --> BindMount
        MountMethods --> OverlayFS
        
        RedirectMethods --> ZNHosts
        RedirectMethods --> HostsFile
        RedirectMethods --> OpenRedirect
        
        BindHosts --> MountMethods
        BindHosts --> RedirectMethods
    end

    %% Execution Scripts Layer
    subgraph ScriptsLayer["Execution Scripts Layer"]
        ActionSH["action.sh"]:::execution
        BindHostsSH["bindhosts.sh"]:::execution
        CustomizeSH["customize.sh"]:::execution
        ServiceSH["service.sh"]:::execution
        PostFSDataSH["post-fs-data.sh"]:::execution
        UtilsSH["utils.sh"]:::execution
    end

    %% Connections between layers
    RootLayer --> ConfigLayer
    ConfigLayer --> CoreLayer
    CoreLayer --> ScriptsLayer

    %% Click Events
    click BindHostsSH "https://github.com/backslashxx/bindhosts/blob/master/module/bindhosts.sh"
    click WebUI "https://github.com/backslashxx/bindhosts/tree/master/module/webroot/"
    click IndexHTML "https://github.com/backslashxx/bindhosts/blob/master/module/webroot/index.html"
    click StylesCSS "https://github.com/backslashxx/bindhosts/blob/master/module/webroot/styles.css"
    click IndexJS "https://github.com/backslashxx/bindhosts/blob/master/module/webroot/index.js"
    click Blacklist "https://github.com/backslashxx/bindhosts/blob/master/module/blacklist.txt"
    click Whitelist "https://github.com/backslashxx/bindhosts/blob/master/module/whitelist.txt"
    click Custom "https://github.com/backslashxx/bindhosts/blob/master/module/custom.txt"
    click Sources "https://github.com/backslashxx/bindhosts/blob/master/module/sources.txt"
    click ActionSH "https://github.com/backslashxx/bindhosts/blob/master/module/action.sh"
    click BindHostsSH "https://github.com/backslashxx/bindhosts/blob/master/module/bindhosts.sh"
    click CustomizeSH "https://github.com/backslashxx/bindhosts/blob/master/module/customize.sh"
    click ServiceSH "https://github.com/backslashxx/bindhosts/blob/master/module/service.sh"
    click PostFSDataSH "https://github.com/backslashxx/bindhosts/blob/master/module/post-fs-data.sh"
    click UtilsSH "https://github.com/backslashxx/bindhosts/blob/master/module/utils.sh"
```
