# siddharthsky/custtermux architecture

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

- Interactive diagram: https://gitdiagram.com/siddharthsky/custtermux
- Repository: https://github.com/siddharthsky/custtermux

## Overview

##### Main System Components
- Android Application Layer:
- The primary “app” module contains most of the UI components (activities, fragments, layouts) and logic for TV streaming. This encompasses the Login Activity, Settings, IPTV startup functionality, and the setup workflows.
- Terminal and Shell Components:
- “terminal-emulator” and “terminal-view” are modules that handle terminal sessions, rendering, and low-level command execution. They should be represented as components that serve as the core command-processing engine.
- Shared Libraries and Utilities:
- “termux-shared” provides common utilities for file operations, JNI wrappers, error handling, logging, theming, and other helper methods. It acts as the backbone supporting both the terminal and the app modules.
- Bootstrapping and Native Shell Scripts:
- The “_BootStrap” folder contains various shell scripts and configuration files that are used during the initial setup and boot process. Consider representing these as part of a “Bootstrapping/Startup” engine.
- Native Code and JNI:
- CI/CD and Developer Infrastructure:
- Although not a runtime component, note the presence of GitHub workflows, Gradle configuration files, and other build scripts. These components can be represented off to the side as “Build/Deployment Pipeline” supporting continuous integration.

##### Establish Relationships and Data Flows
- The UI (Android Application Layer) interacts with the terminal core (terminal-emulator/view) to allow user input (commands, IPTV channel selections, login requests) and display real-time terminal results.
- BootReceiver and similar components within the “app” module should be linked to the Bootstrapping scripts (_BootStrap) to illustrate how the application auto-starts and configures its environment.
- Shared libraries (termux-shared) support both UI functions and terminal operations by handling common tasks (file system access, JNI calls, shell command execution).
- Native code (C/C++ via JNI) is invoked by the application for performance-critical tasks and interfacing with the Android OS.

##### Important Architectural Patterns and Technologies
- Modular design: The project is separated into distinct modules (app, terminal-emulator, terminal-view, termux-shared) to encourage separation of concerns.
- MVC/MVVM-like approach in the Android app where activities/fragments represent the view and the business logic resides in separate service or helper classes.
- Use of Gradle for build automation and GitHub workflows for automated testing and builds.
- The native layer is accessed via JNI bridges, highlighting an integration pattern between Java and C/C++.

##### Putting It All Together
- UI/TV Streaming Module (app): handling login, settings, IPTV channel selection, and video streaming.
- Terminal and Command Processing Modules (terminal-emulator and terminal-view): dealing with shell execution and terminal rendering.
- Shared and Native Modules (termux-shared and native C/C++ code): providing utilities, system interfacing, and performance-critical functions.
- Bootstrapping Unit (_BootStrap): initiating required scripts on startup.
- Small “external” blocks for integrations like jiotv_go that feed directly into the TV streaming features.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Android Application Layer
    subgraph "Android Application Layer"
        UI["CustTermux UI (Activities/Fragments)"]:::ui
        TV["TV Optimized UI"]:::ui
        JIOTV["jiotv_go Integration"]:::cd
    end

    %% Terminal and Shell Components
    subgraph "Terminal & Shell Components"
        TE["Terminal Emulator Core"]:::backend
        TR["Terminal Rendering/Display"]:::backend
    end

    %% Shared and Bootstrapping/Native Modules
    subgraph "Shared & Boot/Native Modules"
        TSL["Termux Shared Library"]:::shared
        BS["Bootstrapping Scripts"]:::shared
        subgraph "Native/JNI Layer"
            A_Native["App Native Code"]:::native
            T_Native["Terminal Native Code"]:::native
            S_Native["Shared Native Code"]:::native
        end
    end

    %% CI/CD and Developer Infrastructure
    BDP["Build/Deployment Pipeline"]:::cd

    %% Connections
    UI -->|"CommandInput"| TE
    UI -->|"AutoStart"| BS
    UI -->|"UtilityCalls"| TSL
    TE -->|"UtilityCalls"| TSL
    TE -->|"RenderOutput"| TR
    UI -->|"JNICalls"| A_Native
    TE -->|"JNICalls"| T_Native
    JIOTV -->|"StreamIntegration"| TV
    BDP -.->|"BuildProcess"| UI

    %% Click Events
    click UI "https://github.com/siddharthsky/custtermux/tree/main/app/src/main/java/com/termux/"
    click TV "https://github.com/siddharthsky/custtermux/tree/main/app/src/main/java/com/termux/tv_ui"
    click TE "https://github.com/siddharthsky/custtermux/tree/main/terminal-emulator/src/main/java/com/termux/terminal"
    click TR "https://github.com/siddharthsky/custtermux/tree/main/terminal-view/src/main/java/com/termux/view"
    click TSL "https://github.com/siddharthsky/custtermux/tree/main/termux-shared"
    click BS "https://github.com/siddharthsky/custtermux/tree/main/_BootStrap"
    click A_Native "https://github.com/siddharthsky/custtermux/tree/main/app/src/main/cpp"
    click T_Native "https://github.com/siddharthsky/custtermux/tree/main/terminal-emulator/src/main/jni"
    click S_Native "https://github.com/siddharthsky/custtermux/tree/main/termux-shared/src/main/cpp"
    click BDP "https://github.com/siddharthsky/custtermux/tree/main/.github/workflows"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1B4F72,color:#154360,stroke-width:2px;
    classDef backend fill:#ABEBC6,stroke:#27AE60,color:#186A3B,stroke-width:2px;
    classDef shared fill:#FAD7A0,stroke:#D35400,color:#7D6608,stroke-width:2px;
    classDef native fill:#F5B7B1,stroke:#C0392B,color:#641E16,stroke-width:2px;
    classDef cd fill:#D7BDE2,stroke:#8E44AD,color:#4A235A,stroke-width:2px;
```
