# davidoliver/live_cue architecture

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

- Interactive diagram: https://gitdiagram.com/davidoliver/live_cue
- Repository: https://github.com/davidoliver/live_cue

## Overview

Key Components to Include:

##### Frontend Layer
- Assets directory structure (CSS and JavaScript)
- LiveView components, especially the CueLive and AlbumComponent

##### Backend Layer
- Phoenix Framework components:
- Endpoint (entry point for web requests)
- Router (request routing)
- LiveView handlers
- Controllers
- Core Application Components:
- Collection Manager (handles music file processing)
- Player Interface (integration with cmus)
- Database Interface

##### External Services
- cmus (audio player)
- ZeroTier (networking layer)
- Local File System (music collection)

##### Component Relationships
- Flow from music files through the collection processing pipeline
- Interaction between the Player module and cmus
- ZeroTier's network layer spanning across the entire system

##### Processing Flows
- Two main data flows:
a. Collection Processing Flow:
Files → Parse Collection → Store Data → LiveView Interface
b. Playback Flow:
User Input → LiveView → Player Module → cmus → Audio Output

##### Key Technical Details
- WebSocket connection for LiveView
- TCP ports (4369 and 9001)
- Supported file formats (FLAC)
- Database interactions
- ZeroTier network integration

Specific Implementation Notes:

- Collection processing pipeline
- Real-time playback synchronization
- LiveView component hierarchy

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
        Assets["Assets"]:::frontend
        CSS["CSS"]:::frontend
        JS["JavaScript"]:::frontend
    end

    subgraph "Phoenix Application"
        Endpoint["Phoenix Endpoint"]:::backend
        Router["Router"]:::backend
        
        subgraph "LiveView Components"
            CueLive["CueLive Component"]:::liveview
            AlbumComponent["Album Component"]:::liveview
        end
        
        subgraph "Core Components"
            CollectionManager["Collection Manager"]:::core
            PlayerInterface["Player Interface"]:::core
            DBInterface["Database Interface"]:::core
            MainApp["Main Application"]:::core
            WebInterface["Web Interface"]:::core
        end
    end

    subgraph "External Services"
        CMUS[("cmus Player")]:::external
        ZeroTier{{"ZeroTier Network"}}:::network
        FileSystem[("Local File System")]:::storage
        Database[("Database")]:::storage
    end

    %% Relationships
    Browser <--> Endpoint
    Assets --> CSS & JS
    Endpoint --> Router
    Router --> CueLive & AlbumComponent
    CueLive --> CollectionManager
    CollectionManager --> FileSystem
    CollectionManager --> DBInterface
    DBInterface --> Database
    PlayerInterface --> CMUS
    CueLive --> PlayerInterface
    ZeroTier -.- Browser
    ZeroTier -.- Endpoint

    %% Click Events
    click Assets "https://github.com/DavidOliver/live_cue/tree/master/assets"
    click CSS "https://github.com/DavidOliver/live_cue/blob/master/assets/app.css"
    click JS "https://github.com/DavidOliver/live_cue/blob/master/assets/js/app.js"
    click CueLive "https://github.com/DavidOliver/live_cue/blob/master/lib/live_cue_web/live/cue_live.ex"
    click AlbumComponent "https://github.com/DavidOliver/live_cue/blob/master/lib/live_cue_web/live/cue/album_component.ex"
    click Endpoint "https://github.com/DavidOliver/live_cue/blob/master/lib/live_cue_web/endpoint.ex"
    click Router "https://github.com/DavidOliver/live_cue/blob/master/lib/live_cue_web/router.ex"
    click CollectionManager "https://github.com/DavidOliver/live_cue/blob/master/lib/live_cue/collection.ex"
    click PlayerInterface "https://github.com/DavidOliver/live_cue/blob/master/lib/live_cue/player.ex"
    click DBInterface "https://github.com/DavidOliver/live_cue/blob/master/lib/live_cue/db.ex"
    click MainApp "https://github.com/DavidOliver/live_cue/blob/master/lib/live_cue/application.ex"
    click WebInterface "https://github.com/DavidOliver/live_cue/blob/master/lib/live_cue_web.ex"

    %% Styling
    classDef frontend fill:#d4d4d4,stroke:#333
    classDef backend fill:#a8d1f0,stroke:#333
    classDef liveview fill:#90caf9,stroke:#333
    classDef core fill:#fff176,stroke:#333
    classDef external fill:#81c784,stroke:#333
    classDef network fill:#ce93d8,stroke:#333
    classDef storage fill:#ffab91,stroke:#333

    %% Legend
    subgraph Legend
        Frontend["Frontend"]:::frontend
        Backend["Backend"]:::backend
        LiveView["LiveView"]:::liveview
        Core["Core"]:::core
        External["External Services"]:::external
        Network["Network"]:::network
        Storage["Storage"]:::storage
    end
```
