# alextud/popcorntimetv architecture

> Architecture diagram of the GitHub repository alextud/popcorntimetv, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alextud/popcorntimetv
- Repository: https://github.com/alextud/popcorntimetv

## Overview

##### Main Components Structure

The system should be represented with these key components:

a. Core Components (PopcornKit):
- HTTP Client Layer
- API Managers
- Models Layer
- Helpers/Utilities

b. Platform-Specific UI Components:
- tvOS Interface
- iOS Interface
- macOS Interface
- TopShelf Extension (tvOS)

##### External Services Integration
- Trakt API Integration
- TMDB API Integration
- OMDb API Integration
- Fanart API Integration
- DHT Network
- Subtitle Services

##### Detailed Component Breakdown

**┌─ User Interface Layer ─────────────────┐**
- Movies Flow                          │
- Shows Flow                           │
- Player                               │
- Downloads                            │
- Settings                             │
- ┘
- ↕
**┌─ PopcornKit (Core Framework) ─────────┐**
- ┌─ Managers ─────┐ ┌─ Models ───────┐ │
- MovieManager │ │ - Movie        │ │
- ShowManager  │ │ - Show         │ │
- AnimeManager │ │ - Episode      │ │
- TraktManager │ │ - Torrent      │ │
- ┘ └───────────────┘ │
- ┌─ HTTP Client ───┐ ┌─ Helpers ────┐ │
- APIClient     │ │ - Extensions  │ │
- RequestConfig │ │ - Utilities   │ │
- ┘ └───────────────┘ │
- ┘
- ↕
**┌─ External Services ──────────────────┐**
- Trakt API                          │
- TMDB API                           │
- OMDb API                           │
- Fanart API                         │
- DHT Network                        │
- Subtitle Services                  │
- ┘

##### Data Flow Indicators

- User interaction flow
- API calls and responses
- Content streaming paths
- Authentication flows

##### Notes for Implementation

- Clear separation between UI and business logic
- PopcornKit as the central framework
- External service dependencies
- Platform-specific implementations
- Security and authentication flows

This system design should be created using a professional diagramming tool that supports:
- Nested components
- Custom styling
- Clear typography
- Export in high resolution

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        UI_Movies["Movies Flow"]:::ui
        UI_Shows["Shows Flow"]:::ui
        UI_Player["Player"]:::ui
        UI_Downloads["Downloads"]:::ui
        UI_Settings["Settings"]:::ui
        VLC["VLC Player View"]:::ui
    end

    subgraph "Platform Specific"
        iOS["iOS Interface"]:::platform
        macOS["macOS Interface"]:::platform
        TopShelf["TopShelf Extension"]:::platform
    end

    subgraph "PopcornKit Core Framework"
        subgraph "Managers"
            MovieManager["Movie Manager"]:::core
            ShowManager["Show Manager"]:::core
            AnimeManager["Anime Manager"]:::core
            TraktManager["Trakt Manager"]:::core
        end

        subgraph "Models"
            Movie["Movie Model"]:::model
            Show["Show Model"]:::model
            Episode["Episode Model"]:::model
            Torrent["Torrent Model"]:::model
        end

        subgraph "HTTP Client"
            APIClient["API Client"]:::http
            RequestConfig["Request Config"]:::http
        end

        subgraph "Helpers"
            Extensions["Extensions"]:::utility
            Utilities["Utilities"]:::utility
        end
    end

    subgraph "External Services"
        TraktAPI["Trakt API"]:::external
        TMDBAPI["TMDB API"]:::external
        OMDbAPI["OMDb API"]:::external
        FanartAPI["Fanart API"]:::external
        DHTNetwork["DHT Network"]:::external
        SubtitleServices["Subtitle Services"]:::external
    end

    %% Relationships
    UI_Movies & UI_Shows & UI_Player & UI_Downloads & UI_Settings --> MovieManager & ShowManager & AnimeManager
    UI_Player --> VLC
    MovieManager & ShowManager & AnimeManager --> APIClient
    APIClient --> TraktAPI & TMDBAPI & OMDbAPI & FanartAPI & DHTNetwork & SubtitleServices
    MovieManager --> Movie
    ShowManager --> Show
    ShowManager --> Episode
    MovieManager & ShowManager --> Torrent
    iOS & macOS & TopShelf --> UI_Movies & UI_Shows & UI_Player & UI_Downloads & UI_Settings

    %% Click Events
    click UI_Movies "https://github.com/alextud/PopcornTimeTV/tree/master/PopcornTime/Flows/Movies/"
    click UI_Shows "https://github.com/alextud/PopcornTimeTV/tree/master/PopcornTime/Flows/Shows/"
    click UI_Player "https://github.com/alextud/PopcornTimeTV/tree/master/PopcornTime/Flows/Player/"
    click UI_Downloads "https://github.com/alextud/PopcornTimeTV/tree/master/PopcornTime/Flows/Downloads/"
    click UI_Settings "https://github.com/alextud/PopcornTimeTV/tree/master/PopcornTime/Flows/Settings/"
    click VLC "https://github.com/alextud/PopcornTimeTV/blob/master/PopcornTime/Views/VLCPlayerView.swift"
    click iOS "https://github.com/alextud/PopcornTimeTV/tree/master/iOS/"
    click macOS "https://github.com/alextud/PopcornTimeTV/tree/master/macOS/"
    click TopShelf "https://github.com/alextud/PopcornTimeTV/tree/master/TopShelf/"
    click TraktAPI "https://github.com/alextud/PopcornTimeTV/blob/master/PopcornKit/Sources/Managers/TraktApi.swift"
    click TMDBAPI "https://github.com/alextud/PopcornTimeTV/blob/master/PopcornKit/Sources/Managers/TMDBApi.swift"
    click OMDbAPI "https://github.com/alextud/PopcornTimeTV/blob/master/PopcornKit/Sources/Managers/OMDbApi.swift"
    click FanartAPI "https://github.com/alextud/PopcornTimeTV/blob/master/PopcornKit/Sources/Managers/FanartApi.swift"
    click DHTNetwork "https://github.com/alextud/PopcornTimeTV/blob/master/PopcornKit/Sources/Managers/DHTApi.swift"
    click SubtitleServices "https://github.com/alextud/PopcornTimeTV/blob/master/PopcornKit/Sources/Managers/SubtitlesApi.swift"
    click APIClient "https://github.com/alextud/PopcornTimeTV/tree/master/PopcornKit/Sources/HttpClient/"
    click Extensions "https://github.com/alextud/PopcornTimeTV/tree/master/PopcornKit/Sources/Helpers/"
    click Utilities "https://github.com/alextud/PopcornTimeTV/tree/master/PopcornKit/Sources/Helpers/"
    click Movie "https://github.com/alextud/PopcornTimeTV/tree/master/PopcornKit/Sources/Models/"
    click Show "https://github.com/alextud/PopcornTimeTV/tree/master/PopcornKit/Sources/Models/"
    click Episode "https://github.com/alextud/PopcornTimeTV/tree/master/PopcornKit/Sources/Models/"
    click Torrent "https://github.com/alextud/PopcornTimeTV/tree/master/PopcornKit/Sources/Models/"
    click MovieManager "https://github.com/alextud/PopcornTimeTV/tree/master/PopcornKit/Sources/Managers/"
    click ShowManager "https://github.com/alextud/PopcornTimeTV/tree/master/PopcornKit/Sources/Managers/"
    click AnimeManager "https://github.com/alextud/PopcornTimeTV/tree/master/PopcornKit/Sources/Managers/"
    click TraktManager "https://github.com/alextud/PopcornTimeTV/tree/master/PopcornKit/Sources/Managers/"

    %% Styles
    classDef ui fill:#2374ab
    classDef platform fill:#48a9a6
    classDef core fill:#4caf50
    classDef model fill:#78909c
    classDef http fill:#ff7043
    classDef utility fill:#bdbdbd
    classDef external fill:#ff9800

    %% Legend
    subgraph Legend
        L1["UI Components"]:::ui
        L2["Platform Specific"]:::platform
        L3["Core Components"]:::core
        L4["Models"]:::model
        L5["HTTP Components"]:::http
        L6["Utilities"]:::utility
        L7["External Services"]:::external
    end
```
