# krabswong/android-proxy-setter architecture

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

- Interactive diagram: https://gitdiagram.com/krabswong/android-proxy-setter
- Repository: https://github.com/krabswong/android-proxy-setter

## Overview

##### Project Type and Purpose
- This project is a command-line / GUI tool written in Rust that configures the network proxy of an Android device connected via ADB. It supports multiple modes: an interactive CLI, direct command-line options, and a GUI mode with a system tray. The overall goal is to simplify proxy management for Android devices.

##### Analyzing the File Structure
- The top-level files include standard Rust files (Cargo.toml, Cargo.lock) indicating that this is a Rust application.
- The single source file (src/main.rs) combines the application’s logic.
- A .gitignore file and a DMG file suggest that the project is version-controlled and also packaged for macOS.
- The file tree is quite minimal, indicating that the application is relatively focused in scope. All features (CLI and GUI) share one codebase.

##### Extracting Insights from the README
- The README describes three modes (interactive CLI, direct command-line, and GUI) and explains how each interacts with the Android device via ADB.
- It lists the essential functionalities: auto-detection of local IP, ADB-based communication, and proxy setting/clearing.
- The document details packaging for macOS, showing that deployment, bundling, and distribution are part of the system.
- Visual assets (screenshots) confirm that the UI and system tray integration are key parts of the design.

##### Key Components
a. Input Interfaces:
- CLI Interface for interactive mode.
- Command-Line Argument Handler for direct commands.
b. Core Logic Module:
- Command parsing and decision-making logic that routes the input to the correct mode.
- Proxy configuration routines (including auto IP detection and validation of settings).
c. External Communications:
- ADB Integration: The module responsible for calling ADB commands to set or clear proxy settings on the connected Android device.
- Android Device: Represented as an external entity that receives commands.
d. Packaging / Build Components:

##### Relationships and Interactions
- Feedback paths—such as reading responses from ADB—to reflect success or failure, which then routes back to the UI (CLI output or GUI notifications).

##### Emphasizing Architectural Patterns and Design Principles
- That the design follows a separation of concerns: distinct modules for handling user input, processing logic, and external communications with ADB/Android.
- Use of command-line argument parsing and mode selection. This conditional branching lets the core logic decide between CLI interactive flow, direct command execution, or GUI flow.
- The system encapsulates both synchronous (CLI/command mode) and asynchronous (GUI with notifications) interactions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        CLI["CLI Interactive"]:::ui
        CMD["Command-Line Arguments"]:::ui
        GUI["System Tray GUI & Notifications"]:::ui
    end

    subgraph "Core Processing"
        CORE["Core Logic (Auto IP Detection,Proxy Config,Command Parsing)"]:::core
    end

    subgraph "External Communication"
        ADB["ADB Integration"]:::external
        DEVICE["Android Device"]:::external
    end

    PACK["Packaging (macOS Bundle)"]:::packaging

    CLI -->|"routes_input"| CORE
    CMD -->|"routes_input"| CORE
    GUI -->|"routes_input"| CORE

    CORE -->|"sends_proxy_cmds"| ADB
    ADB -->|"executes_cmds"| DEVICE
    DEVICE -->|"sends_response"| ADB
    ADB -->|"feedback"| CORE
    ADB -->|"notify_result"| GUI

    CORE -->|"build_output"| PACK

    click CLI "https://github.com/krabswong/android-proxy-setter/blob/main/src/main.rs"
    click CMD "https://github.com/krabswong/android-proxy-setter/blob/main/src/main.rs"
    click CORE "https://github.com/krabswong/android-proxy-setter/blob/main/src/main.rs"
    click ADB "https://github.com/krabswong/android-proxy-setter/blob/main/src/main.rs"
    click GUI "https://github.com/krabswong/android-proxy-setter/tree/main/resources"
    click PACK "https://github.com/krabswong/android-proxy-setter/blob/main/Android Proxy Setter.dmg"

    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef core fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef external fill:#FFCC99,stroke:#000,stroke-width:2px;
    classDef packaging fill:#DDA0DD,stroke:#000,stroke-width:2px;
```
