# ipqow/lastfmnowplayingwidget architecture

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

- Interactive diagram: https://gitdiagram.com/ipqow/lastfmnowplayingwidget
- Repository: https://github.com/ipqow/lastfmnowplayingwidget

## Overview

##### Main Components

a. Client-Side Components:
- Browser Source (OBS/Streaming Software)
- Widget Frontend (HTML/CSS/JS)
- Configuration Module

b. External Services:
- Last.fm API
- Music Service Providers (Spotify, YouTube Music, etc.)

**[Streaming Software Layer]**
- ↕
**[Widget Layer]**
- ↕
**[External Services Layer]**

##### Component Details

a. Streaming Software Layer (Top):
- Rectangle labeled "OBS/Streaming Software"
- Connected to Widget Layer via Browser Source

b. Widget Layer (Middle):
- Main container showing three interconnected components:
1. Frontend UI (nowplaying.html + style.css)
2. Widget Logic (widget.js)
3. Configuration (config.js)

c. External Services Layer (Bottom):
- Last.fm API Service
- Connected music providers (as secondary components)

##### Additional Elements

Specific features:
- Dynamic sizing logic indicator
- Animation state management
- API polling mechanism
- Real-time update flow

##### Technical Details to Note

Annotations for:
- Update interval timing
- Dynamic container sizing
- Transition animations
- API authentication flow

##### The animation system for transitions

Special Considerations:
- Dynamic container sizing mechanism as it's a key feature
- Animation flow for opening/closing states
- Configuration injection points
- Demonstrate the Last.fm API integration pattern

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef streaming fill:#9370DB,stroke:#333,stroke-width:2px
    classDef frontend fill:#4682B4,stroke:#333,stroke-width:2px
    classDef external fill:#3CB371,stroke:#333,stroke-width:2px
    classDef config fill:#A9A9A9,stroke:#333,stroke-width:2px

    %% Streaming Layer
    subgraph StreamingLayer["Streaming Software Layer"]
        OBS["OBS/Streaming Software"]:::streaming
    end

    %% Widget Layer
    subgraph WidgetLayer["Widget Layer"]
        Frontend["Frontend UI"]:::frontend
        WidgetLogic["Widget Logic"]:::frontend
        Config["Configuration"]:::config
        
        %% Widget Components
        FrontendHTML["HTML Interface"]:::frontend
        FrontendCSS["Styling"]:::frontend
        Fonts["Font Assets"]:::frontend
        
        %% Component Relationships
        Frontend --> FrontendHTML
        Frontend --> FrontendCSS
        Frontend --> Fonts
        WidgetLogic --> Frontend
        Config --> WidgetLogic
    end

    %% External Services Layer
    subgraph ExternalLayer["External Services Layer"]
        LastFM["Last.fm API"]:::external
        MusicServices["Music Services<br>(Spotify, YouTube Music)"]:::external
    end

    %% Connections between layers
    OBS -.->|"Browser Source"| Frontend
    WidgetLogic -->|"API Requests"| LastFM
    LastFM -->|"Real-time Updates"| WidgetLogic
    MusicServices -->|"Scrobbling"| LastFM

    %% Click events for component mapping
    click FrontendHTML "https://github.com/IPQow/lastfmnowplayingwidget/blob/main/nowplaying.html"
    click FrontendCSS "https://github.com/IPQow/lastfmnowplayingwidget/blob/main/style.css"
    click WidgetLogic "https://github.com/IPQow/lastfmnowplayingwidget/blob/main/widget.js"
    click Config "https://github.com/IPQow/lastfmnowplayingwidget/blob/main/config.js"
    click Fonts "https://github.com/IPQow/lastfmnowplayingwidget/blob/main/Metropolis-Bold.otf"

    %% Legend
    subgraph Legend
        L1[" "]:::streaming
        L2[" "]:::frontend
        L3[" "]:::external
        L4[" "]:::config
        
        L1---L1T["Streaming Components"]
        L2---L2T["Frontend Components"]
        L3---L3T["External Services"]
        L4---L4T["Configuration"]
    end
```
