# thewidlarzgroup/react-native-video architecture

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

- Interactive diagram: https://gitdiagram.com/thewidlarzgroup/react-native-video
- Repository: https://github.com/thewidlarzgroup/react-native-video

## Overview

##### Project type and purpose
- This is an open-source, cross-platform React Native module (“react-native-video”) that exposes a `<Video>` component.
- It provides a JavaScript/TypeScript interface (in `src/`), plus native implementations for Android (`android/`), iOS (`ios/`), Windows (`windows/`) and Web (`src/Video.web.tsx`).
- It also includes Expo plugins (`src/expo-plugins/`), documentation (`docs/`), example apps (`examples/`), build scripts (`scripts/`), and CI/CD definitions (`.github/workflows/`).

##### Main components
a. JavaScript/TypeScript layer
- `src/index.ts` and component files (`Video.tsx`, `Video.web.tsx`)
- Type definitions (`src/types/`) and native-specs (`src/specs/`)
- Expo plugin glue (`src/expo-plugins/`)
b. React Native Bridge
- Auto-generated/native-module registration that connects JS to platform code
- Spec contracts (`NativeVideoManager`, `VideoNativeComponent`)
c. Platform-specific native modules
- Android: Kotlin/Java code under `android/src/main/java/...` leveraging ExoPlayer, HLS, DASH, RTSP, caching, DRM, ads
- iOS: Swift/Obj-C code under `ios/Video/` using AVPlayer, AVContentKeySession, IMA ads, PiP, caching
- Windows: C++/C# code under `windows/ReactNativeVideoCPP*/` implementing React Package, View manager
d. External native SDKs & services
- ExoPlayer (Android), AVFoundation (iOS), Windows Media Foundation
- Google IMA SDK for ads
- DRM/license servers (via HTTP/URLSession)
e. Tooling & CI/CD
- Build/test pipelines in `.github/workflows/` for Android, iOS, JS, docs
- Linting/format scripts (`scripts/`)
- Package publishing (`package.json`, `react-native-video.podspec`, `release-it.json`)
f. Documentation site
- Next.js project in `docs/`
- API reference, guides, asset pipeline, deployed via GitHub Actions
g. Example applications
- Bare React Native (`examples/bare`)
- Expo managed (`examples/expo`)
- Plugin sample (`examples/react-native-video-plugin-sample`)

##### Relationships & data-flow
- Examples import the published JS package and call the `<Video>` API (JS)
- Docs site reads TypeScript definitions / Markdown to generate API docs
- CI/CD pipelines run tests on each platform, build artifacts, and publish docs

##### Architectural patterns & design principles
- Bridge pattern: decoupling JS API from platform implementations
- Plugin architecture: Expo plugins augment native projects at build time
- Modular codegen: each platform’s code is isolated under its directory
- Single-repo monolith with multiple packages (code + docs + examples)

JS → Bridge → Native code → OS/SDK
CI/CD → Build → Publish → npm / CocoaPods / docs
- Protocols and technologies on connectors (e.g., HTTP, react-native bridge, Gradle, Xcode build)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Client Apps"
        bare["Bare RN App"]:::js
        expoApp["Expo App"]:::js
        pluginSample["Plugin Sample App"]:::js
    end

    subgraph "Library Core"
        jsIndex["src/index.ts"]:::js
        videoTSX["src/Video.tsx"]:::js
        videoWeb["src/Video.web.tsx"]:::js
        types["src/types/"]:::js
        specs["src/specs/"]:::js
        expoplugin["src/expo-plugins/"]:::js
        bridge["React Native Bridge"]:::native
        specNativeManager["NativeVideoManager"]:::native
        specVideoNativeComp["VideoNativeComponent"]:::native
    end

    subgraph "Native Modules"
        subgraph Android
            androidManager["ReactNativeVideoManager.kt"]:::native
            videoManagerModule["VideoManagerModule.kt"]:::native
            decoderInfo["VideoDecoderInfoModule.kt"]:::native
        end
        subgraph iOS
            rctVideo["RCTVideo.swift"]:::native
            rctVideoManager["RCTVideoManager.swift"]:::native
            drmManager["DRMManager.swift"]:::native
            imaAds["RCTIMAAdsManager.swift"]:::native
            cachingIOS["ios/VideoCaching/"]:::native
        end
        subgraph Windows
            reactPack["ReactPackageProvider.cpp/.h"]:::native
            viewManager["ReactVideoViewManager.cpp/.h"]:::native
        end
    end

    subgraph "External SDKs/Services"
        exo["ExoPlayer"]:::external
        avf["AVFoundation"]:::external
        wmf["Windows Media Foundation"]:::external
        ima["Google IMA SDK"]:::external
        drmServer["DRM/License Servers"]:::external
    end

    subgraph Documentation
        docsSite["docs/ (Next.js)"]:::docs
    end

    subgraph "CI/CD & Tooling"
        workflows[".github/workflows/"]:::ci
        scripts["scripts/"]:::ci
        publishCfg["package.json & podspec"]:::ci
    end

    bare --> jsIndex
    expoApp --> jsIndex
    pluginSample --> jsIndex

    jsIndex --> bridge
    videoTSX --> bridge
    videoWeb --> bridge
    specs --> bridge
    specNativeManager --> bridge
    specVideoNativeComp --> bridge
    expoplugin --> bridge

    bridge --> androidManager
    bridge --> rctVideo
    bridge --> reactPack

    androidManager --> exo
    videoManagerModule --> exo
    decoderInfo --> exo

    rctVideo --> avf
    rctVideoManager --> avf
    imaAds --> ima
    drmManager --> drmServer
    cachingIOS --> avf

    reactPack --> wmf
    viewManager --> wmf

    docsSite --> specs
    docsSite --> types

    workflows --> androidManager
    workflows --> rctVideo
    workflows --> jsIndex
    workflows --> docsSite

    scripts --> workflows
    publishCfg --> workflows

    click jsIndex "https://github.com/thewidlarzgroup/react-native-video/blob/master/src/index.ts"
    click videoTSX "https://github.com/thewidlarzgroup/react-native-video/blob/master/src/Video.tsx"
    click videoWeb "https://github.com/thewidlarzgroup/react-native-video/blob/master/src/Video.web.tsx"
    click types "https://github.com/thewidlarzgroup/react-native-video/tree/master/src/types/"
    click specs "https://github.com/thewidlarzgroup/react-native-video/tree/master/src/specs/"
    click expoplugin "https://github.com/thewidlarzgroup/react-native-video/tree/master/src/expo-plugins/"
    click specNativeManager "https://github.com/thewidlarzgroup/react-native-video/blob/master/src/specs/NativeVideoManager.ts"
    click specVideoNativeComp "https://github.com/thewidlarzgroup/react-native-video/blob/master/src/specs/VideoNativeComponent.ts"
    click androidManager "https://github.com/thewidlarzgroup/react-native-video/blob/master/android/src/main/java/com/brentvatne/react/ReactNativeVideoManager.kt"
    click videoManagerModule "https://github.com/thewidlarzgroup/react-native-video/blob/master/android/src/main/java/com/brentvatne/react/VideoManagerModule.kt"
    click decoderInfo "https://github.com/thewidlarzgroup/react-native-video/blob/master/android/src/main/java/com/brentvatne/react/VideoDecoderInfoModule.kt"
    click rctVideo "https://github.com/thewidlarzgroup/react-native-video/blob/master/ios/Video/RCTVideo.swift"
    click rctVideoManager "https://github.com/thewidlarzgroup/react-native-video/blob/master/ios/Video/RCTVideoManager.swift"
    click drmManager "https://github.com/thewidlarzgroup/react-native-video/blob/master/ios/Video/Features/DRMManager.swift"
    click imaAds "https://github.com/thewidlarzgroup/react-native-video/blob/master/ios/Video/Features/RCTIMAAdsManager.swift"
    click cachingIOS "https://github.com/thewidlarzgroup/react-native-video/tree/master/ios/VideoCaching/"
    click reactPack "https://github.com/thewidlarzgroup/react-native-video/blob/master/windows/ReactNativeVideoCPP/ReactPackageProvider.cpp"
    click viewManager "https://github.com/thewidlarzgroup/react-native-video/blob/master/windows/ReactNativeVideoCPP/ReactVideoViewManager.cpp"
    click workflows "https://github.com/thewidlarzgroup/react-native-video/tree/master/.github/workflows/"
    click scripts "https://github.com/thewidlarzgroup/react-native-video/tree/master/scripts/"
    click publishCfg "https://github.com/thewidlarzgroup/react-native-video/blob/master/package.json"
    click docsSite "https://github.com/thewidlarzgroup/react-native-video/tree/master/docs/"
    click bare "https://github.com/thewidlarzgroup/react-native-video/tree/master/examples/bare/"
    click expoApp "https://github.com/thewidlarzgroup/react-native-video/tree/master/examples/expo/"
    click pluginSample "https://github.com/thewidlarzgroup/react-native-video/tree/master/examples/react-native-video-plugin-sample/"

    classDef js fill:#cce5ff,stroke:#000,stroke-width:1px
    classDef native fill:#ccffcc,stroke:#000,stroke-width:1px
    classDef external fill:#ffd699,stroke:#000,stroke-width:1px
    classDef docs fill:#e0c1ff,stroke:#000,stroke-width:1px
    classDef ci fill:#e6e6e6,stroke:#000,stroke-width:1px
```
