# roialfassi/iptv-saba architecture

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

- Interactive diagram: https://gitdiagram.com/roialfassi/iptv-saba
- Repository: https://github.com/roialfassi/iptv-saba

## Overview

##### Project type and purpose
- This is a desktop IPTV streaming application written in Python, following an MVC‐like pattern.
- Purpose: allow multiple user profiles, manage M3U playlists, browse/favorite channels, support an “Easy Mode” for elderly users, and play streams via VLC.

##### File structure
- Top‑level:
- iptv_app.py – application entry point
- requirements.txt, README.md, .gitignore
- src/
- controller/ – orchestrates user actions and connects view ↔ model
– controller.py
- model/ – in‑memory representations
– channel_model.py, group_model.py, profile.py
- data/ – persistence, config, download, profile management
– config_manager.py, data_loader.py, downloader.py, profile_manager.py
- view/ – UI screens
– login_view.py, choose_channel_screen.py, full_screen_view.py, easy_mode_screen.py

##### Additional insights from README
- Relies on VLC Media Player for playback (external dependency).
- Data persists via config_manager/profile_manager – likely local JSON or database files.
- Streaming URLs are fetched via data/downloader from M3U playlists.

##### Main components
a. User Interface (View layer)
– Login Screen
– Channel Selection Screen
– Easy Mode Screen
– Full‑Screen Player
b. Controller
– Routes events from UI to model/data
– Applies business logic (e.g., favorite toggling, playlist filtering)
c. Model
– Channel, Group, Profile objects encapsulating state
d. Data Layer
– Config Manager (read/write user settings)
– Profile Manager (create/delete profiles, persist favorites/history)
– Data Loader/Downloader (fetch and parse M3U playlists)
e. External Services
– VLC Media Player (playback engine)
– Internet/M3U provider (stream source)
– Local file system or lightweight DB (where profiles & history are saved)

##### Relationships and interactions
- User clicks in the View → Controller receives input → Controller calls Model/Data methods → Data layer fetches or persists data → Controller updates Model → Controller instructs View to re-render.
- On “Play” action: Controller hands stream URL to VLC component → VLC renders video in Full‑Screen Player view.
- Easy Mode: Controller reads Profile favorites → passes only favorites to View for simplified navigation.

##### Architectural patterns and important design principles
- MVC (or Model‑View‑Controller) separation: clean UI ↔ business logic ↔ data persistence
- Single Responsibility: each module focuses on one area (e.g., data/downloader only handles playlist fetching)
- Extensibility: additional features (EPG, new view modes) can be added by creating new view/controller/model classes without major rewrite.

##### Final checklist
- Clear component labels (e.g., “Profile Manager”, “Full‑Screen Player View”)
- Optionally, numbering the main data flows (1–5) to guide readers through a use case (e.g., app startup, login, channel selection, playback, exit).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Application Entry
    App["Application Entry<br>iptv_app.py"]:::entry
    click App "https://github.com/roialfassi/iptv-saba/blob/master/src/iptv_app.py"

    %% View Layer
    subgraph "User Interface (View)" 
        direction TB
        Login["Login Screen"]:::view
        click Login "https://github.com/roialfassi/iptv-saba/blob/master/src/view/login_view.py"
        ChooseChannel["Channel Selection Screen"]:::view
        click ChooseChannel "https://github.com/roialfassi/iptv-saba/blob/master/src/view/choose_channel_screen.py"
        EasyMode["Easy Mode Screen"]:::view
        click EasyMode "https://github.com/roialfassi/iptv-saba/blob/master/src/view/easy_mode_screen.py"
        FullScreen["Full‑Screen Player View"]:::view
        click FullScreen "https://github.com/roialfassi/iptv-saba/blob/master/src/view/full_screen_view.py"
    end

    %% Controller Layer
    subgraph "Controller" 
        direction TB
        Controller["Controller<br>controller.py"]:::controller
        click Controller "https://github.com/roialfassi/iptv-saba/blob/master/src/controller/controller.py"
    end

    %% Model Layer
    subgraph "Model Objects"
        direction TB
        Channel["Channel Model"]:::model
        click Channel "https://github.com/roialfassi/iptv-saba/blob/master/src/model/channel_model.py"
        Group["Group Model"]:::model
        click Group "https://github.com/roialfassi/iptv-saba/blob/master/src/model/group_model.py"
        ProfileModel["Profile Model"]:::model
        click ProfileModel "https://github.com/roialfassi/iptv-saba/blob/master/src/model/profile.py"
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        ConfigMgr["Config Manager"]:::data
        click ConfigMgr "https://github.com/roialfassi/iptv-saba/blob/master/src/data/config_manager.py"
        ProfileMgr["Profile Manager"]:::data
        click ProfileMgr "https://github.com/roialfassi/iptv-saba/blob/master/src/data/profile_manager.py"
        DataLoader["Data Loader"]:::data
        click DataLoader "https://github.com/roialfassi/iptv-saba/blob/master/src/data/data_loader.py"
        Downloader["Downloader"]:::data
        click Downloader "https://github.com/roialfassi/iptv-saba/blob/master/src/data/downloader.py"
    end

    %% Assets
    Assets["Static Assets"]:::data
    click Assets "https://github.com/roialfassi/iptv-saba/tree/master/src/Assets"

    %% External Services
    subgraph "External Services"
        direction TB
        VLC["VLC Media Player"]:::external
        Internet["Internet / M3U Provider"]:::external
        FileSys["Local File System"]:::external
    end

    %% Main Flows
    App -->|"start"| Login
    Login -->|"login event"| Controller
    Controller -->|"load profiles"| ProfileMgr
    ProfileMgr -->|"profiles data"| Controller
    Controller -->|"init models"| ProfileModel
    Controller -->|"render"| Login

    Controller -->|"show channels"| ChooseChannel
    Controller -->|"fetch local data"| DataLoader
    DataLoader -->|"local playlist"| Controller
    Controller -->|"download playlist"| Downloader
    Downloader -->|"parsed playlist"| Controller
    Controller -->|"update view"| ChooseChannel

    Controller -->|"toggle easy mode"| EasyMode
    EasyMode -->|"select favorite"| Controller

    Controller -->|"play stream"| VLC
    VLC -->|"video output"| FullScreen
    FullScreen -->|"controls input"| Controller

    Controller -->|"save settings"| ConfigMgr
    ConfigMgr -->|"ack"| Controller
    Controller -->|"persist history"| ProfileMgr
    ProfileMgr -->|"ack"| Controller

    %% Dependencies on Models
    Controller -->|"use channel data"| Channel
    Controller -->|"use group data"| Group
    Controller -->|"use profile data"| ProfileModel

    %% External interactions
    Downloader -->|"HTTP get"| Internet
    ProfileMgr -->|"read/write"| FileSys
    ConfigMgr -->|"read/write"| FileSys

    %% Styling
    classDef view fill:#D0E8FF,stroke:#0288D1,stroke-width:1px
    classDef controller fill:#FFE0B2,stroke:#FB8C00,stroke-width:1px
    classDef model fill:#C8E6C9,stroke:#388E3C,stroke-width:1px
    classDef data fill:#DCEDC8,stroke:#7CB342,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#757575,stroke-width:1px
    classDef entry fill:#FFF9C4,stroke:#FBC02D,stroke-width:1px
```
