How ahmadijmail/royatask works
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).