# zgrav/xtream-iptv-player-reactnative architecture

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

- Interactive diagram: https://gitdiagram.com/zgrav/xtream-iptv-player-reactnative
- Repository: https://github.com/zgrav/xtream-iptv-player-reactnative

## Overview

##### Project Type and Purpose
- It is a mobile (and web) app developed with React Native, with separate configurations for Android, iOS, and related web support via Expo.
- The app’s purpose is to provide a UI for watching IPTV streams. The README clarifies that it is “ejected from CRNA” (i.e., it’s not vanilla Create React Native App but uses ExpoKit) and highlights its use case as an IPTV player.

##### File Structure to Identify Major Components
- Root-Level JavaScript Files:
– Files like App.js, Account.js, Live.js, Login.js, Series.js, etc. represent the various UI components/screens.
– They will serve as the building blocks for different views (e.g., live channels, VOD channels, series episodes).
- API Directory:
– Contains scripts (e.g., getCategories.js, getChannels.js, getEPG.js, getSeries.js, getVODInfo.js, etc.) that likely serve as data access or integration layers with the IPTV backend (or mock API endpoints).
- Platform-Specific Folders:
– "android" and "ios" directories include all the native configuration, build scripts, Gradle and Xcode project files, and platform-specific assets. These are the native shells around the React Native layer.
- Utility and Common Directories:
– "utils" contains helper functions such as time conversion, URL building, localized string retrieving, which support the main application logic.
– "common" (though details aren’t listed) might contain shared modules or components used across the app.
- Configuration Files:
– Files like package.json, app.json, .babelrc, .eslintrc.json illustrate the use of modern JavaScript tooling and linting.

##### Core Components and Relationships (
- React Native Frontend (Core UI Layer):
– Root: App.js
– UI Components: Account, Live, LiveChannel, LiveChannelFullEPG, Login, Series, SeriesEpisodePicker, SeriesEpisodeViewer, VODChannel, VODs, PlayeriOS (appears tailored for platform-specific functionality).
– Utility Modules: getLocalizedString, buildUrl, timeConverter, segmentedButton, etc.
- API Layer:
– API scripts (located in the "api" folder) that provide methods for fetching channels, categories, EPG data, series data, and VOD information.
– These could be diagrammed as a separate “data abstraction” or “backend integration” module that the UI components communicate with.
- Native Platform Wrappers:
– Android and iOS directories, representing the native environment that wraps the React Native code.
– ExpoKit & Expo integration (as hinted by the README and directory structure) that handles bridging between JavaScript and native modules.
- External Dependencies:
– Include not only Expo’s services but also various external libraries and dependencies (as indicated by the Maven repositories on Android and pod files on iOS). These can be represented generically as “External Services/Modules” if detailed specifics are not needed.

##### Relationships and Data Flow
- React Native UI components call the API layer (via the JavaScript API scripts) to fetch IPTV-related data.
- The API layer may, in turn, communicate with external IPTV services (though not directly depicted in code, they are implied by the project description).
- Utility modules support data transformation, localization, and building the correct request URLs, feeding information back into the UI components.

##### Architectural Patterns and Design Principles
- Separation of concerns: clear division between UI components, API integration, and utility/helper functions.
- Cross-platform architecture: a shared React Native codebase that is adapted to both Android and iOS, with each platform’s native configuration managed separately.
- Use of ExpoKit indicates a hybrid approach where updates and hot reloading might be managed via Expo, yet the app is “detached” to allow custom native code.
- Modular design: distribution of files (API in its own folder; platform-specific configurations; shared utilities) suggests compartmentalization for easier maintenance and scalability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User"]:::external

    subgraph "React Native UI"
        App["App.js"]:::frontend
        Account["Account.js"]:::frontend
        Live["Live.js"]:::frontend
        LiveChannel["LiveChannel.js"]:::frontend
        LiveChannelFullEPG["LiveChannelFullEPG.js"]:::frontend
        Login["Login.js"]:::frontend
        Series["Series.js"]:::frontend
        SeriesEpisodePicker["SeriesEpisodePicker.js"]:::frontend
        SeriesEpisodeViewer["SeriesEpisodeViewer.js"]:::frontend
        VODChannel["VODChannel.js"]:::frontend
        VODs["VODs.js"]:::frontend
        PlayeriOS["PlayeriOS.js"]:::frontend
    end

    subgraph "API Integration Layer"
        getCategories["getCategories.js"]:::api
        getChannels["getChannels.js"]:::api
        getEPG["getEPG.js"]:::api
        getFullEPG["getFullEPG.js"]:::api
        getSeries["getSeries.js"]:::api
        getVODInfo["getVODInfo.js"]:::api
        getVODs["getVODs.js"]:::api
        login["login.js"]:::api
    end

    subgraph "Utility Modules"
        buildUrl["buildUrl.js"]:::utility
        getLocalizedString["getLocalizedString.js"]:::utility
        timeConverter["timeConverter.js"]:::utility
        segmentedButton["segmentedButton.js"]:::utility
        locales["locales (dir)"]:::utility
    end

    subgraph "Common Shared Components"
        common["common (dir)"]:::utility
    end

    subgraph "Native Wrappers"
        Android["Android (ExpoKit)"]:::native
        iOS["iOS (ExpoKit)"]:::native
    end

    ExternalIPTV["IPTV Service (External)"]:::external

    %% Data Flow Connections
    User -->|"interacts"| App

    %% React Native UI to API Integration
    App -->|"fetches_data"| getCategories
    App -->|"fetches_data"| getChannels
    Login -->|"calls"| login
    Live -->|"calls"| getEPG
    LiveChannel -->|"calls_API"| getFullEPG
    Series -->|"calls_API"| getSeries
    VODs -->|"calls_API"| getVODInfo
    VODs -->|"calls_API"| getVODs

    %% React Native UI uses Utility Modules
    App -->|"uses"| buildUrl
    Account -->|"uses"| getLocalizedString
    Live -->|"uses"| timeConverter
    LiveChannelFullEPG -->|"uses"| segmentedButton

    %% Integration with Native Wrappers
    App -->|"runs_on"| Android
    App -->|"runs_on"| iOS
    PlayeriOS -->|"integrates_with"| iOS

    %% API Integration Layer communication with External IPTV
    getChannels -->|"fetches_from"| ExternalIPTV
    getVODs -->|"fetches_from"| ExternalIPTV

    %% Native Wrappers bridging with React Native Core
    Android -->|"bridges"| App
    iOS -->|"bridges"| App

    %% Click Events for React Native Core UI
    click App "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/App.js"
    click Account "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/Account.js"
    click Live "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/Live.js"
    click LiveChannel "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/LiveChannel.js"
    click LiveChannelFullEPG "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/LiveChannelFullEPG.js"
    click Login "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/Login.js"
    click Series "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/Series.js"
    click SeriesEpisodePicker "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/SeriesEpisodePicker.js"
    click SeriesEpisodeViewer "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/SeriesEpisodeViewer.js"
    click VODChannel "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/VODChannel.js"
    click VODs "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/VODs.js"
    click PlayeriOS "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/PlayeriOS.js"

    %% Click Events for API Integration Layer
    click getCategories "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/api/getCategories.js"
    click getChannels "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/api/getChannels.js"
    click getEPG "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/api/getEPG.js"
    click getFullEPG "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/api/getFullEPG.js"
    click getSeries "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/api/getSeries.js"
    click getVODInfo "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/api/getVODInfo.js"
    click getVODs "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/api/getVODs.js"
    click login "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/api/login.js"

    %% Click Events for Utility Modules
    click buildUrl "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/utils/buildUrl.js"
    click getLocalizedString "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/utils/getLocalizedString.js"
    click timeConverter "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/utils/timeConverter.js"
    click segmentedButton "https://github.com/zgrav/xtream-iptv-player-reactnative/blob/master/utils/segmentedButton.js"
    click locales "https://github.com/zgrav/xtream-iptv-player-reactnative/tree/master/utils/locales"

    %% Click Events for Common Shared Components
    click common "https://github.com/zgrav/xtream-iptv-player-reactnative/tree/master/common"

    %% Click Events for Native Wrappers
    click Android "https://github.com/zgrav/xtream-iptv-player-reactnative/tree/master/android"
    click iOS "https://github.com/zgrav/xtream-iptv-player-reactnative/tree/master/ios"

    %% Styling Definitions
    classDef frontend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef api fill:#F9E79F,stroke:#7D6608,stroke-width:2px;
    classDef native fill:#C39BD3,stroke:#6C3483,stroke-width:2px;
    classDef utility fill:#ABEBC6,stroke:#1E8449,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#B03A2E,stroke-width:2px;
```
