# nawar/kodi-cli architecture

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

- Interactive diagram: https://gitdiagram.com/nawar/kodi-cli
- Repository: https://github.com/nawar/kodi-cli

## Overview

##### Main Components

a) Client-Side Components:
- kodi-cli Script (Central Component)
- Configuration Handler (.kodirc)
- Input Processor (CLI Arguments)
- JSON-RPC Client

b) External Services/Dependencies:
- Kodi Media Center
- YouTube (Optional Integration)
- mps-youtube (Optional Component)

##### User Interface Layer
- Command options (-p, -y, -q, etc.)

##### Core Processing Layer
- Configuration Management (reading .kodirc)
- Command Processing
- JSON-RPC Request Formation

##### Communication Layer
- HTTP/JSON-RPC Client
- Authentication Handler

##### External Systems Layer
- Kodi Media Center
- YouTube API (indirect through URL processing)

##### Flow Representation

**User Input → Command Processing → JSON-RPC Formation → Kodi Server**
**Configuration → Authentication → JSON-RPC Client**
**YouTube URLs → URL Processing → Kodi Command Formation**

##### Important Details

a) Configuration Flow:
**.kodirc → Config Parser → Authentication Manager**

b) Command Flow:
**CLI Arguments → Command Validator → Command Processor → JSON-RPC Client**

c) Media Control Flow:
**YouTube URL → URL Parser → Kodi Player Interface**

##### Technical Details to Note

- JSON-RPC over HTTP as the primary communication protocol
- Configuration file format and structure
- Command processing pipeline
- Authentication mechanism

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef cli fill:#90EE90,stroke:#333,stroke-width:2px
    classDef config fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef external fill:#FFA500,stroke:#333,stroke-width:2px
    classDef optional fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef communication fill:#87CEEB,stroke:#333,stroke-width:2px

    %% User Interface Layer
    Terminal["Terminal Interface"]:::cli
    CLI["kodi-cli Command Line Tool"]:::cli
    click CLI "https://github.com/nawar/kodi-cli/tree/master/kodi-cli"

    %% Configuration Layer
    Config[".kodirc Configuration"]:::config
    click Config "https://github.com/nawar/kodi-cli/blob/master/.kodirc"

    %% Core Processing Layer
    subgraph CoreProcessing["Core Processing"]
        CmdProcessor["Command Processor"]
        ConfigManager["Configuration Manager"]
        AuthHandler["Authentication Handler"]
        JSONRPCFormatter["JSON-RPC Request Formatter"]
    end

    %% Communication Layer
    subgraph Communication["Communication Layer"]
        JSONRPCClient["JSON-RPC Client"]:::communication
        HTTPClient["HTTP Client"]:::communication
    end

    %% External Systems
    Kodi["Kodi Media Center"]:::external
    YouTube["YouTube"]:::external
    MPSYoutube["mps-youtube"]:::optional

    %% Optional Components
    PlaylistTool["playlist_to_kodi"]:::optional
    click PlaylistTool "https://github.com/nawar/kodi-cli/tree/master/playlist_to_kodi"

    %% Connections
    Terminal --> CLI
    CLI --> CmdProcessor
    Config --> ConfigManager
    click Config "https://github.com/nawar/kodi-cli/blob/master/.kodirc"
    ConfigManager --> AuthHandler
    CmdProcessor --> JSONRPCFormatter
    AuthHandler --> JSONRPCClient
    JSONRPCFormatter --> JSONRPCClient
    JSONRPCClient --> HTTPClient
    HTTPClient --> Kodi
    CLI --> PlaylistTool
    PlaylistTool --> JSONRPCFormatter
    CLI -.-> YouTube
    YouTube -.-> MPSYoutube
    MPSYoutube -.-> JSONRPCFormatter

    %% Legend
    subgraph Legend
        L1["Core Components"]:::cli
        L2["Configuration"]:::config
        L3["External Services"]:::external
        L4["Optional Components"]:::optional
        L5["Communication"]:::communication
    end
```
