# amazonappdev/react-native-multi-tv-app-sample architecture

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

- Interactive diagram: https://gitdiagram.com/amazonappdev/react-native-multi-tv-app-sample
- Repository: https://github.com/amazonappdev/react-native-multi-tv-app-sample

## Overview

##### Project type and purpose
- This is a front-end sample app built with React Native and Expo Router, targeting multiple TV platforms (Android TV, Fire TV, tvOS) plus web.
- It demonstrates best practices for TV-specific UI: drawer navigation, grid layout, focus management, remote-control mapping, and video playback.

##### File structure
- Top-level folders:
- app/ : file-based routing (Expo Router) for screens and layouts
- components/ : reusable UI pieces (drawer content, focusable pressables, player controls)
- hooks/ : custom hooks (e.g., useScale)
- Version control and CI/CD:
- .github/ : issue & PR templates
- .husky/ : git hooks for linting and commit message checks
- Configuration files: babel.config.js, metro.config.js, tsconfig.json, eslint.config.js, commitlint.config.js
- No backend or data-service folder – this is purely client-side.

##### README for additional insights
- Core libraries: Expo (router, drawer), react-native-video, react-tv-space-navigation.
- Navigation structure (drawer + nested stacks), platform abstraction for remote control, and a customizable VideoPlayer screen.

a. Main components
- Presentation Layer (UI Screens):
– DrawerLayout (_layout.tsx under app/(drawer))
– Explore, TV grid, Details, Player screens
- Navigation Layer:
– Expo Router file-based routes (+html.tsx, +not-found.tsx, _layout.tsx)
– CustomDrawerContent
- Input Management:
– RemoteControlManager.ts[x]/android/ios + SupportedKeys
– React TV Space Navigation for focus management
- Media Engine:
– react-native-video integrated in VideoPlayer component
- Assets Store:
- Native Platform Adapters:
– Expo (Android TV, tvOS, Web)
b. Relationships and interactions
- User remote input → RemoteControlManager → Focus Management → UI Screens via React TV Space Navigation
- UI Screens → Navigation Layer (Expo Router) → Renders appropriate React component
- Player Screen → Media Engine for video decoding and playback
c. Architectural patterns
- File-based routing (Router) for automatic route registration
- Single-Page App style with nested layouts (drawer + content)
- Separation of concerns: input management, navigation, presentation, media playback
d. Key technologies
- Expo Router & Drawer
- react-native-video
- react-tv-space-navigation
- TypeScript + React Native + Metro Bundler

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Input
    UserRemote["User Remote"]:::external

    %% Input Management
    subgraph "Remote Control Manager"
        direction TB
        RC_Interface["RemoteControlManager.interface.ts"]:::input
        RC_Core["RemoteControlManager.ts"]:::input
        RC_Android["RemoteControlManager.android.ts"]:::input
        RC_iOS["RemoteControlManager.ios.ts"]:::input
        SK["SupportedKeys.ts"]:::input
        GBC["GoBackConfiguration.tsx"]:::input
    end

    %% Focus Management
    subgraph "Focus Management"
        direction TB
        FTSN["react-tv-space-navigation"]:::input
        FP["FocusablePressable"]:::input
    end

    %% Navigation Layer
    subgraph "Navigation Layer"
        direction TB
        ER["Expo Router"]:::navigation
        DD["DrawerLayout (_layout.tsx)"]:::navigation
        CD["CustomDrawerContent"]:::navigation
    end

    %% Screens
    subgraph "UI Screens"
        direction TB
        GlobalLayout["Global App Layout"]:::navigation
        HTML["HTML Root"]:::navigation
        NotFound["Not Found Screen"]:::navigation
        DrawerIndex["Drawer Index"]:::navigation
        Explore["Explore Screen"]:::navigation
        TVGrid["TV Grid Screen"]:::navigation
        Details["Details Screen"]:::navigation
        PlayerScr["Player Screen"]:::navigation
    end

    %% Media Engine
    subgraph "Media Engine"
        direction TB
        VideoComp["VideoPlayer Component"]:::media
        Controls["Player Controls"]:::media
        Seek["Player SeekBar"]:::media
        Exit["Player Exit Button"]:::media
        RNVideo["react-native-video"]:::media
    end

    %% Assets Store
    subgraph "Assets Store"
        direction TB
        Fonts["Font Assets"]:::assets
        Images["Image Assets"]:::assets
        Icons["TV Icons"]:::assets
    end

    %% Platform Adapters
    subgraph "Platform Adapters"
        Expo["Expo Platform Targets"]:::navigation
    end

    %% Utilities & Config
    subgraph "Utilities & Config"
        direction TB
        Husky[".husky/"]:::util
        GitHub[".github/"]:::util
        ConfigFiles["Config Files"]:::util
        HookScale["useScale.ts"]:::util
    end

    %% Connections
    UserRemote --> RC_Core
    RC_Core --> FTSN
    FTSN --> FP
    FTSN --> Explore
    FTSN --> TVGrid
    FTSN --> Details
    FTSN --> PlayerScr

    UserRemote --> GBC
    UserRemote --> SK

    Explore -->|"loads assets"| Fonts
    Explore -->|"loads assets"| Images
    Explore -->|"loads assets"| Icons
    TVGrid -->|"loads assets"| Fonts
    TVGrid -->|"loads assets"| Images
    TVGrid -->|"loads assets"| Icons
    Details -->|"loads assets"| Fonts
    Details -->|"loads assets"| Images
    Details -->|"loads assets"| Icons
    PlayerScr -->|"loads assets"| Fonts
    PlayerScr -->|"loads assets"| Images
    PlayerScr -->|"loads assets"| Icons

    PlayerScr --> VideoComp
    VideoComp --> RNVideo
    VideoComp --> Controls
    Controls --> Seek
    Controls --> Exit

    Explore --> ER
    TVGrid --> ER
    Details --> ER
    PlayerScr --> ER

    ER --> GlobalLayout
    ER --> HTML
    ER --> NotFound
    GlobalLayout --> DD
    DD --> DrawerIndex
    DD --> Explore
    DD --> TVGrid

    Expo --> ER
    Expo --> RNVideo
    Expo --> RC_Core
    Expo --> FTSN

    %% Click Events
    click DD "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/app/(drawer)/_layout.tsx"
    click Explore "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/app/(drawer)/explore.tsx"
    click TVGrid "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/app/(drawer)/tv.tsx"
    click DrawerIndex "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/app/(drawer)/index.tsx"
    click GlobalLayout "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/app/_layout.tsx"
    click HTML "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/app/+html.tsx"
    click NotFound "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/app/+not-found.tsx"
    click Details "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/app/details.tsx"
    click PlayerScr "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/app/player.tsx"
    click RC_Core "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/app/remote-control/RemoteControlManager.ts"
    click RC_Android "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/app/remote-control/RemoteControlManager.android.ts"
    click RC_iOS "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/app/remote-control/RemoteControlManager.ios.ts"
    click RC_Interface "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/app/remote-control/RemoteControlManager.interface.ts"
    click SK "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/app/remote-control/SupportedKeys.ts"
    click GBC "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/app/remote-control/GoBackConfiguration.tsx"
    click CD "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/components/CustomDrawerContent.tsx"
    click FP "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/components/FocusablePressable.tsx"
    click HookScale "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/hooks/useScale.ts"
    click VideoComp "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/components/player/VideoPlayer.tsx"
    click Controls "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/components/player/Controls.tsx"
    click Seek "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/components/player/SeekBar.tsx"
    click Exit "https://github.com/amazonappdev/react-native-multi-tv-app-sample/blob/main/components/player/ExitButton.tsx"
    click Fonts "https://github.com/amazonappdev/react-native-multi-tv-app-sample/tree/main/assets/fonts/"
    click Images "https://github.com/amazonappdev/react-native-multi-tv-app-sample/tree/main/assets/images/"
    click Icons "https://github.com/amazonappdev/react-native-multi-tv-app-sample/tree/main/assets/tv_icons/"

    %% Styles
    classDef navigation fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef input fill:#D0FFD8,stroke:#333,stroke-width:1px
    classDef media fill:#FFE0B2,stroke:#333,stroke-width:1px
    classDef assets fill:#E0E0E0,stroke:#333,stroke-width:1px
    classDef util fill:#F5F5F5,stroke:#333,stroke-width:1px
    classDef external fill:#CCCCCC,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
