# geocld/xstreaming architecture

> Architecture diagram of the GitHub repository geocld/xstreaming, 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/geocld/xstreaming
- Repository: https://github.com/geocld/xstreaming

## Overview

##### Project Type and Purpose
- It is a mobile application (React Native based) that acts as a remote client for Xbox streaming.
- The purpose is to stream video/audio from Xbox consoles or cloud services while also integrating gamepad control (both physical and virtual), sensor support, and various device-specific functionalities.

##### File Structure
- Key top-level directories include:
- “android”: Contains the native Android code with modules (such as BatteryModule, FullScreenManager, Gamepad, Sensor, UsbRumble, etc.), configurations, and gradle build files.
- “src”: Contains the React Native client code – pages, components, assets, state management (store), utilities, localization (i18n), themes, and tokens.
- “docs”: Documentation files that detail aspects such as Auth, Web API, and Streaming functionality.
- Other configuration files (package.json, tsconfig.json, babel.config.js, etc.) that set up the development environment.
- The structure hints at a layered architecture with a clear separation between the UI/base logic (React Native) and native platform support (Android modules).

##### Extract Architectural Insights from the README
- The README describes it as an “Opensource Xbox Remote Client” targeted to streaming Xbox games/video content.
- It notes native support for gamepad controls (virtual, OTG, or Bluetooth) and mentions streaming under various conditions (1080P, vibrational feedback, additional network support like IPv6).
- There are cross-platform concerns mentioned (note the iOS version available on TestFlight), so while Android is fully visible in the file tree, the design should be flexible enough to be extended to iOS.

##### Key Components
a. UI/Application Layer (React Native):
- Components: src/App.tsx, various pages (Home, Login, Settings, Stream, etc.), and custom UI components (gamepad visuals, console items, etc.).
- State management: Using “src/store” modules (gamepadStore, settingStore, etc.) to manage global app state.
- Utilities, token management (src/tokens), internationalization (src/i18n and languages folder), and theming.

b. Native Layer (Android Native Modules):
- Dedicated Android packages (e.g., BatteryModule, GamepadManager, SensorModule, FullScreenManager, etc.) found under “android/app/src/main/java/com/xstreaming” as well as specialized gamepad input modules under “android/app/src/main/java/com/xstreaming/input”.
- These modules provide low-level integrations and are likely bridged to the React Native layer.

c. Streaming and External Service Interaction:
- Components that handle streaming logic (video/audio decoding, processing) and manage connections to external Xbox/xCloud streaming services.
- This may include APIs or network utilities under “src/utils/http.ts” and the streaming-related assets in “android/app/src/main/assets/stream”.

d. Cross-Cutting Concerns:
- Authentication (src/Authentication.ts), settings, and configuration management (src/common/settings).
- Localization and theming to support different languages and UI modes.

##### Relationships and Interactions
- UI components in React Native send commands (like gamepad button presses) via bridging APIs to the corresponding native modules (e.g., GamepadPackage, SensorPackage).
- The state management system (Redux or similar pattern in “src/store”) interacts with utilities and network functions to fetch data and update the UI.
- Assets and resources (from the “assets” directories in both the React Native and Android folders) serve the upfront UI and streaming interfaces.

##### Architectural Patterns and Design Principles
- Layered Architecture: Distinct separation between front-end (React Native code and UI) and back-end/natives (Android modules).
- Modular Design: Independent components for gamepad controls, sensors, streaming, and authentication.
- Bridging/Interoperability: The use of React Native’s mechanism to call native code, which is critical for functionalities that need low-level access.
- State Management: Centralized state (via “src/store”) that governs UI updates and data fetching.
- Extensibility: Directory structure showing potential for multi-platform support (with directories like web, xCloud, xal).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "React Native UI Layer"
        UI_App["App Component"]:::ui
        UI_Pages["Pages (Home,Login,Settings,Stream)"]:::ui
        UI_Custom["Custom UI Components (Gamepad,Console, etc.)"]:::ui
    end

    subgraph "State Management & Business Logic"
        SM_Global["Global State Management"]:::state
        SM_Utils["Utilities & Configuration"]:::state
    end

    subgraph "Authentication Module"
        Auth_Node["Authentication Handler"]:::auth
    end

    subgraph "Token and Device Settings"
        Token_Node["Token & Device Settings"]:::token
    end

    subgraph "Native Android Modules"
        N_Core["Core Native Modules (Battery,GamepadManager,Sensor,FullScreenManager,etc.)"]:::native
        N_Input["Gamepad Input Modules"]:::native
    end

    subgraph "Streaming Service Interface"
        Stream_Assets["Streaming Assets"]:::stream
        Stream_Net["Network Streaming Utilities"]:::stream
    end

    subgraph "Localization & Theming"
        Locale_Node["Localization"]:::localization
        Theme_Node["Themes"]:::localization
    end

    %% Data Flow Connections
    UI_App -->|"triggers"| SM_Global
    UI_Pages -->|"userInteraction"| SM_Global
    UI_Custom -->|"sendsInput"| SM_Global

    SM_Global -->|"authCheck"| Auth_Node
    SM_Global -->|"fetchConfig"| Token_Node
    SM_Global -->|"bridgeCall"| N_Core
    SM_Global -->|"bridgeCall"| N_Input

    N_Core -->|"streamsData"| Stream_Assets
    N_Input -->|"processesInput"| Stream_Assets
    Stream_Assets -->|"deliversStream"| Stream_Net
    Stream_Net -->|"dataResponse"| SM_Utils

    SM_Utils -->|"stateUpdate"| SM_Global
    SM_Global -->|"uiUpdate"| UI_App

    %% Localization & Theming Integration
    UI_App -->|"applies"| Locale_Node
    UI_App -->|"applies"| Theme_Node
    UI_Pages -->|"applies"| Theme_Node

    %% Click Events for UI/Application Layer
    click UI_App "https://github.com/geocld/xstreaming/blob/main/src/App.tsx"
    click UI_Pages "https://github.com/geocld/xstreaming/tree/main/src/pages"
    click UI_Custom "https://github.com/geocld/xstreaming/tree/main/src/components"

    %% Click Events for State Management & Business Logic
    click SM_Global "https://github.com/geocld/xstreaming/tree/main/src/store"
    click SM_Utils "https://github.com/geocld/xstreaming/blob/main/src/utils/http.ts"
    click Token_Node "https://github.com/geocld/xstreaming/tree/main/src/common/settings"

    %% Click Event for Authentication Module
    click Auth_Node "https://github.com/geocld/xstreaming/blob/main/src/Authentication.ts"

    %% Click Events for Native Android Modules
    click N_Core "https://github.com/geocld/xstreaming/tree/main/android/app/src/main/java/com/xstreaming"
    click N_Input "https://github.com/geocld/xstreaming/tree/main/android/app/src/main/java/com/xstreaming/input"

    %% Click Events for Streaming Service Interface
    click Stream_Assets "https://github.com/geocld/xstreaming/tree/main/android/app/src/main/assets/stream"
    click Stream_Net "https://github.com/geocld/xstreaming/blob/main/src/utils/http.ts"

    %% Click Events for Localization & Theming
    click Locale_Node "https://github.com/geocld/xstreaming/blob/main/src/i18n.ts"
    click Theme_Node "https://github.com/geocld/xstreaming/tree/main/src/theme"

    %% Styles
    classDef ui fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef state fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef auth fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;
    classDef token fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef native fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef stream fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef localization fill:#D5F5E3,stroke:#28B463,stroke-width:2px;
```
