# sh9351/ktv architecture

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

- Interactive diagram: https://gitdiagram.com/sh9351/ktv
- Repository: https://github.com/sh9351/ktv

## Overview

##### Main Components

a. Core Application Layer:
- Electron Main Process (`index.js`)
- Renderer Process (`views/tv.html`)
- IPC Communication Bridge

b. Channel Management Layer:
- Channel Provider System (`providers.js`)
- Channel Manager (`src/channels.js`)

c. Feature Modules:
- Mobile Remote Control Server (Port 30514)
- Recording System (MediaRecorder + ts-ebml)
- UI Components

**┌─ Application Layer ─────────────────────┐**

- Electron Main Process               │
- (index.js)                         │

- ┬───────────────────────┘

**┌────────────────▼───────────────────────┐**

- Channel Management Layer            │
- providers.js                      │
- channels.js                       │

- ┬───────────────────────┘

**┌────────────────▼───────────────────────┐**

- UI Layer (Renderer Process)         │
- tv.html                          │
- Frontend Assets                   │

- ┘

##### Data Flow Representation

- Channel data flow from providers to UI
- IPC communication between main and renderer processes
- Mobile remote control commands
- Recording system data flow

##### External Integration Points

Connections to:
- Official broadcaster websites
- Naver TV
- Other external sources
- Mobile remote control clients

##### Technical Details

- Port specifications (30514 for remote control)
- File formats (webm for recording)
- Key technologies (Node.js, Electron, MediaRecorder)
- DHCP address detection system

##### The integration with external broadcast sources

Remember to include a small section showing the application lifecycle and channel refresh mechanism, as these are critical operational aspects of the system.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Application Layer"
        MainProcess["Electron Main Process<br/>(index.js)"]
        IPC["IPC Bridge"]
    end

    subgraph "Channel Management Layer"
        ChannelProvider["Channel Provider System<br/>(providers.js)"]
        ChannelManager["Channel Manager<br/>(channels.js)"]
    end

    subgraph "UI Layer"
        Renderer["Renderer Process<br/>(tv.html)"]
        UIComponents["UI Components"]
        MediaPlayer["Media Player"]
    end

    subgraph "External Services"
        Broadcasters["Official Broadcasters"]
        NaverTV["Naver TV"]
        OtherSources["Other Sources"]
    end

    subgraph "Features"
        RemoteControl["Mobile Remote Control<br/>(Port: 30514)"]
        RecordingSystem["Recording System<br/>(MediaRecorder + ts-ebml)"]
    end

    %% Core Application Flow
    MainProcess --> IPC
    IPC --> Renderer
    
    %% Channel Management Flow
    Broadcasters --> ChannelProvider
    NaverTV --> ChannelProvider
    OtherSources --> ChannelProvider
    ChannelProvider --> ChannelManager
    ChannelManager --> MainProcess
    
    %% UI Flow
    Renderer --> UIComponents
    UIComponents --> MediaPlayer
    
    %% Feature Integration
    RemoteControl -.-> MainProcess
    MainProcess -.-> RecordingSystem
    RecordingSystem -.-> MediaPlayer

    classDef core fill:#2374ab
    classDef channel fill:#48a9a6
    classDef ui fill:#e4572e
    classDef external fill:#a8a8a8
    classDef feature fill:#c17767,stroke-dasharray: 5 5
    
    class MainProcess,IPC core
    class ChannelProvider,ChannelManager channel
    class Renderer,UIComponents,MediaPlayer ui
    class Broadcasters,NaverTV,OtherSources external
    class RemoteControl,RecordingSystem feature
```
