# jatinmishra/jstream architecture

> Architecture diagram of the GitHub repository jatinmishra/jstream, 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/jatinmishra/jstream
- Repository: https://github.com/jatinmishra/jstream

## Overview

##### Main Components
- App Entry Point: Represent the JStreamApp.swift file which is the main SwiftUI entry point.
- Analytics Module: Include an Analytics block that encapsulates components like AnalyticsManager.swift, ConvivaAnalyticsService.swift, and MuxAnalyticsService.swift. This indicates external integration with MUX and possibly Conviva.
- Base/UI Module: Show the Base component housing the LaunchScreen, Theme (handling theme switching via ThemeChanger.swift and ThemeViewModifier.swift), and the VideoList functionality. The VideoList subcomponent should further detail its composition – video models (VideoItem.swift), the list view (VideoListView.swift), view model (VideoListViewModel.swift), and Row view (VideoRowView.swift).
- VideoPlayerSDK Module: Represent the dedicated module for video playback. It includes the VideoPlayerSDK.swift, configuration (VideoPlayerSDKConfiguration.swift), player view (VideoPlayerView.swift), and the overlay for controls (VideoControlsOverlay.swift). This module is largely responsible for wrapping and customizing AVPlayer functionalities as well as UIKit integrations (for AirPlay support).

##### Relationships and Interactions
- The App (JStreamApp.swift) orchestrates the presentation by connecting to the Base module to set up the UI and navigations.
- The Base module uses its VideoList components to display video content, and forwards playback actions to the VideoPlayerSDK.
- The VideoPlayerSDK handles video playback tasks utilizing AVPlayer, displaying video streams and interacting with the custom video controls overlay.
- The Analytics module is integrated into the playback flow, collecting metrics from the video playback events and likely feeding results to external analytics services.
- The Theme components in Base provide dynamic styling (switching between Light and Dark modes) altering the app’s user interface.

##### Architectural Patterns and Design Principles
- Modular Design: Each major feature (video playback, analytics, theming, video listing) is encapsulated in its own module or directory, ensuring separation of concerns.
- MVVM Pattern: Evidence from the use of view models (e.g., VideoListViewModel.swift) suggests an MVVM approach, typical in SwiftUI applications.
- Integration of UIKit with SwiftUI: The VideoPlayerSDK not only uses SwiftUI components but also integrates AVPlayerViewController for AirPlay support, indicating a hybrid approach where the best of both frameworks is leveraged.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Application Block
    A["JStreamApp.swift<br/>(App Entry Point)"]:::app
    click A "https://github.com/jatinmishra/jstream/blob/main/JStream/JStreamApp.swift"

    %% Base/UI Module
    subgraph "Base/UI Module"
        B1["LaunchScreen.swift<br/>(Launch Screen)"]:::base
        click B1 "https://github.com/jatinmishra/jstream/blob/main/JStream/Base/LaunchScreen.swift"
        
        B2["ThemeChanger.swift<br/>(Theme Management)"]:::base
        click B2 "https://github.com/jatinmishra/jstream/blob/main/JStream/Base/Theme/ThemeChanger.swift"
        
        B3["ThemeViewModifier.swift<br/>(Theme Modifier)"]:::base
        click B3 "https://github.com/jatinmishra/jstream/blob/main/JStream/Base/Theme/ThemeViewModifier.swift"
        
        subgraph "Video List"
            BL1["VideoItem.swift<br/>(Video Model)"]:::base
            click BL1 "https://github.com/jatinmishra/jstream/blob/main/JStream/Base/VideoList/Models/VideoItem.swift"
            
            BL2["VideoListView.swift<br/>(List View)"]:::base
            click BL2 "https://github.com/jatinmishra/jstream/blob/main/JStream/Base/VideoList/VideoListView.swift"
            
            BL3["VideoListViewModel.swift<br/>(ViewModel)"]:::base
            click BL3 "https://github.com/jatinmishra/jstream/blob/main/JStream/Base/VideoList/VideoListViewModel.swift"
            
            BL4["VideoRowView.swift<br/>(Row View)"]:::base
            click BL4 "https://github.com/jatinmishra/jstream/blob/main/JStream/Base/VideoList/VideoRowView.swift"
        end
    end

    %% VideoPlayerSDK Module
    subgraph "VideoPlayerSDK Module"
        S1["VideoPlayerSDK.swift<br/>(Core SDK)"]:::sdk
        click S1 "https://github.com/jatinmishra/jstream/blob/main/JStream/VideoPlayerSDK/VideoPlayerSDK.swift"
        
        S2["VideoPlayerSDKConfiguration.swift<br/>(SDK Configuration)"]:::sdk
        click S2 "https://github.com/jatinmishra/jstream/blob/main/JStream/VideoPlayerSDK/VideoPlayerSDKConfiguration.swift"
        
        S3["VideoPlayerView.swift<br/>(Player View)"]:::sdk
        click S3 "https://github.com/jatinmishra/jstream/blob/main/JStream/VideoPlayerSDK/VideoPlayerView.swift"
        
        S4["VideoControlsOverlay.swift<br/>(Controls Overlay)"]:::sdk
        click S4 "https://github.com/jatinmishra/jstream/blob/main/JStream/VideoPlayerSDK/VideoControlsOverlay.swift"
        
        S5["AVPlayer<br/>(UIKit Integration)"]:::external
    end

    %% Analytics Module
    subgraph "Analytics Module"
        AN1["AnalyticsManager.swift"]:::analytics
        click AN1 "https://github.com/jatinmishra/jstream/blob/main/JStream/Analytics/AnalyticsManager.swift"
        
        AN2["ConvivaAnalyticsService.swift"]:::analytics
        click AN2 "https://github.com/jatinmishra/jstream/blob/main/JStream/Analytics/ConvivaAnalyticsService.swift"
        
        AN3["MuxAnalyticsService.swift"]:::analytics
        click AN3 "https://github.com/jatinmishra/jstream/blob/main/JStream/Analytics/MuxAnalyticsService.swift"
    end

    %% Interactions
    A -->|"initUI"| B1
    B1 -->|"navigate"| BL2
    B1 -->|"applyTheme"| B2
    B2 -->|"modifies"| B3
    BL2 -->|"selectVideo"| S1
    S1 -->|"uses"| S5
    S1 -->|"reportsPlayback"| AN1
    AN1 -->|"integratesWith"| AN2
    AN1 -->|"integratesWith"| AN3

    %% Styles
    classDef app fill:#d4a5ff,stroke:#5e3c99,stroke-width:2px;
    classDef base fill:#a5d8ff,stroke:#1c7ed6,stroke-width:2px;
    classDef sdk fill:#c3f0ca,stroke:#2b8a3e,stroke-width:2px;
    classDef analytics fill:#ffadad,stroke:#d90429,stroke-width:2px;
    classDef external fill:#ffe066,stroke:#fab005,stroke-width:2px;
```
