# aws/amazon-ivs-react-native-player architecture

> Architecture diagram of the GitHub repository aws/amazon-ivs-react-native-player, 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/aws/amazon-ivs-react-native-player
- Repository: https://github.com/aws/amazon-ivs-react-native-player

## Overview

##### Main Components
- JavaScript/React Native Layer – This is primarily represented in the src directory and relevant configuration files (e.g., package.json, tsconfig.json). This layer exports the IVSPlayer component, which is the bridge between your React Native app and the native modules.
- Android Native Module – Found in the android directory, including Kotlin files (e.g., AmazonIvsPackage.kt, AmazonIvsView.kt, and AmazonIvsViewManager.kt) and Gradle build scripts. This component encapsulates the Android-specific implementation of the player.
- iOS Native Module – The ios directory contains the iOS-specific code (Objective-C and Swift, like AmazonIvsManager.m, AmazonIvsManager.swift, and AmazonIvsView.swift) that implements the corresponding native functionality.
- Example Applications – The example folder demonstrates how the library is integrated into a React Native app with platform-specific code (both Android and iOS projects are present). This illustrates real-world usage.
- Build and Configuration Process – Although not a system component, include references to build files (podspec, Gradle files, podfile) and configuration scripts that orchestrate the build, deployment, and testing of the native modules and JS bundle.

##### Relationships and Interactions
- Data/Command Flow – Show how the IVSPlayer React component (from the JS layer) invokes methods on the native modules through the React Native Bridge.
- Native to JavaScript Communication – Indicate callbacks or event propagation mechanisms originating from the native modules returning signals or events to the JS layer.
- Example App Integration – Optionally show how the sample app wraps these components together, demonstrating usage both in the development sample and as a guide for integration.

##### Architectural Patterns and Design Principles
- Bridge Pattern – The React Native Bridge that connects the JavaScript layer with the native modules should be emphasized.
- Separation of Concerns – Distinct boundaries exist between presentation (JS components), native implementation (platform code), and build/configuration (Gradle, Podfiles, etc.).
- Modular Design – Each platform-specific module is self-contained (with its own configurations) and can be independently tested (as seen from the existence of e2e tests and example projects).

##### Relevant Technologies, Frameworks, and Libraries
- React Native – Serving as the primary framework for the JavaScript layer.
- Native SDKs – iOS and Android native code that interacts directly with the Amazon IVS SDK.
- Build Tools – For Android: Gradle; for iOS: CocoaPods (with the .podspec file); and Node.js based tools for running JavaScript tests (e.g., Jest in the e2e folder).
- Testing Frameworks – E2E tests and unit tests present within __tests__ and e2e directories.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "React Native JS Layer"
        A1("IVSPlayer Component"):::js
        A2("src/IVSPlayer.tsx"):::js
        A3("src/index.ts"):::js
        A4("package.json"):::js
        A5("tsconfig.json"):::js
    end

    subgraph "Android Native Module"
        B1("AmazonIvsPackage.kt"):::android
        B2("AmazonIvsView.kt"):::android
        B3("AmazonIvsViewManager.kt"):::android
        B4("android/build.gradle"):::android
    end

    subgraph "iOS Native Module"
        C1("AmazonIvsManager.m"):::ios
        C2("AmazonIvsManager.swift"):::ios
        C3("AmazonIvsView.swift"):::ios
        C4("amazon-ivs-react-native-player.podspec"):::ios
    end

    subgraph "Example Application"
        D1("example"):::example
    end

    subgraph "Testing & Documentation"
        E1("e2e"):::testing
        E2("docs"):::testing
    end

    %% Relationships
    A1 -->|"bridgeCall"| B1
    A1 -->|"bridgeCall"| C1
    B1 -->|"nativeEvent"| A1
    C1 -->|"nativeEvent"| A1
    D1 -->|"integrates"| A1

    %% Click Events - React Native JS Layer
    click A2 "https://github.com/aws/amazon-ivs-react-native-player/blob/main/src/IVSPlayer.tsx"
    click A3 "https://github.com/aws/amazon-ivs-react-native-player/blob/main/src/index.ts"
    click A4 "https://github.com/aws/amazon-ivs-react-native-player/blob/main/package.json"
    click A5 "https://github.com/aws/amazon-ivs-react-native-player/blob/main/tsconfig.json"

    %% Click Events - Android Native Module
    click B1 "https://github.com/aws/amazon-ivs-react-native-player/blob/main/android/src/main/java/com/amazonaws/ivs/reactnative/player/AmazonIvsPackage.kt"
    click B2 "https://github.com/aws/amazon-ivs-react-native-player/blob/main/android/src/main/java/com/amazonaws/ivs/reactnative/player/AmazonIvsView.kt"
    click B3 "https://github.com/aws/amazon-ivs-react-native-player/blob/main/android/src/main/java/com/amazonaws/ivs/reactnative/player/AmazonIvsViewManager.kt"
    click B4 "https://github.com/aws/amazon-ivs-react-native-player/blob/main/android/build.gradle"

    %% Click Events - iOS Native Module
    click C1 "https://github.com/aws/amazon-ivs-react-native-player/blob/main/ios/AmazonIvsManager.m"
    click C2 "https://github.com/aws/amazon-ivs-react-native-player/blob/main/ios/AmazonIvsManager.swift"
    click C3 "https://github.com/aws/amazon-ivs-react-native-player/blob/main/ios/AmazonIvsView.swift"
    click C4 "https://github.com/aws/amazon-ivs-react-native-player/blob/main/ios/amazon-ivs-react-native-player.podspec"

    %% Click Events - Example Application
    click D1 "https://github.com/aws/amazon-ivs-react-native-player/tree/main/example"

    %% Click Events - Testing & Documentation
    click E1 "https://github.com/aws/amazon-ivs-react-native-player/tree/main/e2e"
    click E2 "https://github.com/aws/amazon-ivs-react-native-player/tree/main/docs"

    %% Styles
    classDef js fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef android fill:#ABEBC6,stroke:#28B463,stroke-width:2px;
    classDef ios fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef example fill:#F5CBA7,stroke:#CA6F1E,stroke-width:2px;
    classDef testing fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
```
