# jiotv-go/jiotv_go_app architecture

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

- Interactive diagram: https://gitdiagram.com/jiotv-go/jiotv_go_app
- Repository: https://github.com/jiotv-go/jiotv_go_app

## Overview

##### Project Architecture Type
- This is a native Android application that acts as a streaming server.
- The primary purpose is to initialize a server environment on the device, execute binaries for streaming, manage updates, and provide a clean and responsive user interface to navigate channels and settings.
- It caters to IPTV integration by providing the streaming channels via an accessible URL that external IPTV player apps can use.

##### Break Down the Core Components
a. User Interface (UI) Layer:
- This consists of Android activities and UI components found in “app/src/main/java/com/skylake/skytv/jgorunner/activities”, “screens”, and “ui/components”.
- Key classes: AppListActivity, CastActivity, ExoplayerActivity, MainActivity, WebPlayerActivity, and various screens (e.g., HomeScreen, SettingsScreen, etc.).
- UI Themes and resources are managed under “ui/theme” and “res” (layouts, drawables).

b. Core Business Logic:
- Organized in packages under “core”.
- Break this into several submodules:
- Data Management – e.g., JTVConfiguration and JTVConfigurationManager that handle configuration data.
- Execution – classes like BinaryExecutor, ExecutionManager, LiveStreamHandler, and CastMediaPlayer handle the core functions of executing commands (e.g., launching binaries, managing streams).
- Updates – modules for updating the application or its binaries (ApplicationUpdater, BinaryUpdater, and download-related classes). These components ensure that the server binaries and assets are always current.

c. Services and Background Processes:
- The “services” package contains components like BinaryService that run background tasks essential for maintaining the streaming service.
- The “receivers” package (BootReceiver, CastOptionsProvider) supports event handling (like startup initialization and receiving casting intents).

d. Utility and Helper Functions:
- Located in “utils”, such as JsonFileHandler, for managing file-based operations.
- There are additional shared resources under “data” (like SkySharedPref) to maintain persistence and configuration storage.

e. Development and Build Infrastructure:
- Gradle build files, version control configurations (e.g., .gitignore, .gitattributes), and GitHub workflows are present to ensure continuous integration and proper build management.
- While not part of the runtime architecture, they play an essential role in how the app is built and deployed.

##### Relationships and Interactions
- The UI components (activities and screens) interact with the core modules to present data and accept user input. For instance, a user action in the HomeScreen might trigger the ExecutionManager to start a stream.
- The core update and execution components interact with services (e.g., BinaryService) to run background operations, download updates, or execute binaries.
- Receivers like BootReceiver ensure that on system startup, the necessary background services (and potentially update routines) are triggered, ensuring the app remains operational.
- The app makes available an HTTP interface (as implied by the IPTV playlist URL structure) so external IPTV players can retrieve streams via a well-defined API endpoint.

##### Architectural Patterns and Design Principles
- Modular Breakdown: The structure clearly separates UI, core business logic, and background services.
- Event-Driven: Receivers and services handle asynchronous tasks such as boot events and binary executions.
- Update/Execution Pipeline: An important flow (user triggers an update or stream request → update/execution manager handles the binary/service call → feedback provided to UI) should be highlighted.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        UI1("Activities"):::uiLayer
        UI2("Screens"):::uiLayer
        UI3("UI Themes & Resources"):::uiLayer
    end

    %% Core Business Logic
    subgraph "Core Business Logic"
        CB1("Data Management"):::coreBusiness
        CB2("Execution Module"):::coreBusiness
        CB3("Update Management"):::coreBusiness
    end

    %% Services & Background Processes
    subgraph "Services & Background"
        SV1("Binary Service"):::services
        SV2("Receivers"):::services
    end

    %% Utility and Helper Functions
    subgraph "Utilities"
        UT1("Utility Functions"):::utilities
        UT2("Persistence/Data"):::utilities
    end

    %% External Integration
    subgraph "External Integration"
        EX1("IPTV HTTP Endpoint"):::external
    end

    %% Build and Deployment Infrastructure
    subgraph "Build & Deployment"
        BD1("Build Infrastructure"):::build
        BD2("CI/CD Config"):::build
        BD3("Version Control"):::build
    end

    %% Relationships and Interactions
    UI1 -- "initiates" --> CB2
    UI2 -- "displays from" --> CB1
    UI3 -- "applies to" --> UI2
    CB2 -- "executes binaries" --> SV1
    CB3 -- "triggers updates" --> SV1
    SV2 -- "activates service" --> SV1
    CB1 -- "provides config to" --> CB2
    CB3 -- "verifies/downloads" --> UT2
    UT1 -- "supports" --> CB1
    CB2 -- "exposes stream" --> EX1
    BD1 -- "builds" --> UI1
    BD1 -- "builds" --> CB1
    BD1 -- "builds" --> SV1
    BD2 -- "integrates with" --> BD1
    BD3 -- "manages" --> BD1

    %% Click Events for Component Mapping
    click UI1 "https://github.com/jiotv-go/jiotv_go_app/tree/develop/app/src/main/java/com/skylake/skytv/jgorunner/activities"
    click UI2 "https://github.com/jiotv-go/jiotv_go_app/tree/develop/app/src/main/java/com/skylake/skytv/jgorunner/ui/screens"
    click UI3 "https://github.com/jiotv-go/jiotv_go_app/tree/develop/app/src/main/java/com/skylake/skytv/jgorunner/ui/theme"
    click CB1 "https://github.com/jiotv-go/jiotv_go_app/tree/develop/app/src/main/java/com/skylake/skytv/jgorunner/core/data"
    click CB2 "https://github.com/jiotv-go/jiotv_go_app/tree/develop/app/src/main/java/com/skylake/skytv/jgorunner/core/execution"
    click CB3 "https://github.com/jiotv-go/jiotv_go_app/tree/develop/app/src/main/java/com/skylake/skytv/jgorunner/core/update"
    click SV1 "https://github.com/jiotv-go/jiotv_go_app/blob/develop/app/src/main/java/com/skylake/skytv/jgorunner/services/BinaryService.kt"
    click SV2 "https://github.com/jiotv-go/jiotv_go_app/tree/develop/app/src/main/java/com/skylake/skytv/jgorunner/receivers"
    click UT1 "https://github.com/jiotv-go/jiotv_go_app/blob/develop/app/src/main/java/com/skylake/skytv/jgorunner/utils/JsonFileHandler.kt"
    click UT2 "https://github.com/jiotv-go/jiotv_go_app/blob/develop/app/src/main/java/com/skylake/skytv/jgorunner/data/SkySharedPref.kt"
    click BD1 "https://github.com/jiotv-go/jiotv_go_app/blob/develop/build.gradle"
    click BD2 "https://github.com/jiotv-go/jiotv_go_app/tree/develop/.github/workflows"
    click BD3 "https://github.com/jiotv-go/jiotv_go_app/blob/develop/.gitignore"

    %% Styles
    classDef uiLayer fill:#b3cde0,stroke:#005b96,stroke-width:2px;
    classDef coreBusiness fill:#fbb4ae,stroke:#de2d26,stroke-width:2px;
    classDef services fill:#ccebc5,stroke:#31a354,stroke-width:2px;
    classDef utilities fill:#decbe4,stroke:#6a51a3,stroke-width:2px;
    classDef external fill:#ffffcc,stroke:#ffeb3b,stroke-width:2px;
    classDef build fill:#fddaec,stroke:#d81b60,stroke-width:2px;
```
