# ahmadijmail/royatask architecture

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

- Interactive diagram: https://gitdiagram.com/ahmadijmail/royatask
- Repository: https://github.com/ahmadijmail/royatask

## Overview

##### Project Type and Purpose
- This is a cross-platform React Native mobile app (iOS + Android) written in TypeScript.
- Purpose: play videos with custom controls and integrated ads (pre-roll, mid-roll, post-roll) in a dark-themed UI.

##### File Structure
- Top-Level Config & Tooling:
- .eslintrc.js, .prettierrc.js, babel.config.js, metro.config.js, jest.config.js, tsconfig.json
- Entry & Build Scripts:
- index.js, App.tsx, package.json, package-lock.json
- Native Android Folder:
- android/ (Gradle scripts, MainActivity.kt, MainApplication.kt, resources, manifests)
- Native iOS Folder:
- ios/ (Xcode project, AppDelegate.swift, Pods, assets, Info.plist)
- JavaScript Source in src/:
- assets/ (blankVideo.mp4)
- components/ (ad-player.tsx, video-player.tsx, video-player-controls.tsx)
- hooks/ (video-player-hook.tsx)
- lib/ (helper.ts)
- screens/ (home-screen.tsx, video-player-screen.tsx)
- types/ (video-player-types.ts)
- Tests: __tests__/
- Ruby/Gemfile: Fastlane or other iOS automation

##### Additional Insights from README
- Uses React Navigation for routing.
- Uses react-native-video for playback.
- Strong focus on ad workflow and transparent fallback handling.

##### Components
a. Main Components
- React Native JS Layer
– App.tsx (Navigation Container)
– HomeScreen & VideoScreen
– VideoPlayer, AdPlayer, VideoPlayerControls (components/)
– useVideoPlayer hook (hooks/) + helper.ts (lib/)
– Local asset (blankVideo.mp4)
- Native Bridge & Modules
– index.js → React Native Bridge
– react-native-video native module
– Android Native (MainActivity.kt, Gradle)
– iOS Native (AppDelegate.swift, CocoaPods)
- External Services
– Ad Server (fetch ads)
– (Optional) Analytics / Error Reporting
b. Relationships & Data Flows
- User taps “Watch Video” → React Navigation → VideoScreen
- VideoScreen → useVideoPlayer hook
- useVideoPlayer schedules ads → AdPlayer requests ads from Ad Server
- AdPlayer drives VideoPlayer
- VideoPlayer wraps react-native-video → Native Module → OS Media APIs
- VideoPlayerControls send play/pause/seek commands back
c. Architectural Patterns & Principles
- Component-based UI (screens vs reusable components)
- Hook-based state & side-effects (useVideoPlayer)
- Clear layering: UI → Business Logic → Native Bridge → Platform
- Single codebase for both Android & iOS with platform‐specific configs
d. Key Technologies & Libraries
- React Native + React Navigation
- TypeScript
- react-native-video
- Metro/Babel (bundler), Jest (tests)
- Android Gradle & iOS CocoaPods (build)

##### Detail
- Break the project into as many discrete components as possible: screens, UI components, hooks, helper libs, native bridge, platform modules, external services.
- Both runtime data flows (user interactions, video/ad streams) and build/deploy architecture (Gradle, CocoaPods).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "JS UI Layer"
        direction TB
        RN_BRIDGE["index.js"]:::native
        App["App.tsx"]:::ui
        Home["HomeScreen"]:::ui
        VideoScreen["VideoPlayerScreen"]:::ui
    end

    subgraph "UI Components"
        direction TB
        VPComp["VideoPlayer Component"]:::ui
        APComp["AdPlayer Component"]:::ui
        VPCtrl["VideoPlayerControls"]:::ui
    end

    subgraph "Business Logic"
        direction TB
        Hook["useVideoPlayer Hook"]:::biz
        Helper["helper.ts"]:::biz
        Types["video-player-types.ts"]:::biz
    end

    subgraph "Assets"
        direction TB
        Asset["blankVideo.mp4"]:::asset
    end

    subgraph "Native Modules & Bridge"
        direction TB
        RNVideo["react-native-video Module"]:::native
        AndroidAct["MainActivity.kt"]:::native
        AndroidApp["MainApplication.kt"]:::native
        AndroidGradle["Android Gradle Config"]:::build
        iOSDelegate["AppDelegate.swift"]:::native
        CocoaPods["CocoaPods Config"]:::build
    end

    subgraph "External Services"
        direction TB
        AdServer["Ad Server"]:::external
        Analytics["Analytics/Error Reporting"]:::external
    end

    RN_BRIDGE --> App
    App --> Home
    App --> VideoScreen
    VideoScreen --> Hook
    Hook --> Helper
    Hook --> APComp
    Helper --> Types
    APComp --> AdServer
    APComp --> VPComp
    VPComp --> RNVideo
    RNVideo --> AndroidAct
    RNVideo --> iOSDelegate
    VPComp --> Asset
    VideoScreen --> VPCtrl
    VPCtrl --> VPComp
    RN_BRIDGE --> AndroidApp
    AndroidApp --> AndroidAct
    iOSDelegate --> CocoaPods

    click RN_BRIDGE "https://github.com/ahmadijmail/royatask/blob/main/index.js"
    click App "https://github.com/ahmadijmail/royatask/blob/main/App.tsx"
    click Home "https://github.com/ahmadijmail/royatask/blob/main/src/screens/home-screen.tsx"
    click VideoScreen "https://github.com/ahmadijmail/royatask/blob/main/src/screens/video-player-screen.tsx"
    click VPComp "https://github.com/ahmadijmail/royatask/blob/main/src/components/video-player.tsx"
    click APComp "https://github.com/ahmadijmail/royatask/blob/main/src/components/ad-player.tsx"
    click VPCtrl "https://github.com/ahmadijmail/royatask/blob/main/src/components/video-player-controls.tsx"
    click Hook "https://github.com/ahmadijmail/royatask/blob/main/src/hooks/video-player-hook.tsx"
    click Helper "https://github.com/ahmadijmail/royatask/blob/main/src/lib/helper.ts"
    click Types "https://github.com/ahmadijmail/royatask/blob/main/src/types/video-player-types.ts"
    click Asset "https://github.com/ahmadijmail/royatask/blob/main/src/assets/blankVideo.mp4"
    click AndroidAct "https://github.com/ahmadijmail/royatask/blob/main/android/app/src/main/java/com/royatask/MainActivity.kt"
    click AndroidApp "https://github.com/ahmadijmail/royatask/blob/main/android/app/src/main/java/com/royatask/MainApplication.kt"
    click AndroidGradle "https://github.com/ahmadijmail/royatask/blob/main/android/app/build.gradle"
    click iOSDelegate "https://github.com/ahmadijmail/royatask/blob/main/ios/RoyaTask/AppDelegate.swift"
    click CocoaPods "https://github.com/ahmadijmail/royatask/tree/main/ios/Podfile"

    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef biz fill:#90EE90,stroke:#333,stroke-width:1px
    classDef native fill:#FFA500,stroke:#333,stroke-width:1px
    classDef build fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef external fill:#D8BFD8,stroke:#333,stroke-width:1px
    classDef asset fill:#808080,stroke:#333,stroke-width:1px
```
