# pipluppp/spotify-unwrap architecture

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

- Interactive diagram: https://gitdiagram.com/pipluppp/spotify-unwrap
- Repository: https://github.com/pipluppp/spotify-unwrap

## Overview

##### Main Components

a) Frontend Layer:
- Static web assets (HTML, CSS, JS) served from the resources/public directory
- User interface components for displaying analysis results

b) Backend Layer:
- Java-based server application
- Analysis components (separate the different analysis types)
- Data processing services
- Spotify API integration

c) Data Layer:
- CSV file storage (streams.csv)
- Potential caching mechanisms

##### Component Relationships

**[Frontend Layer]**

- ▼
**[Backend Controller Layer]**

- ▼
**[Service Layer]**
- SpotifyDataService
- SpotifyAPIService
- Analysis Components

- ▼
**[Data Layer]**

##### Specific Implementation Details

a) Frontend Components (Top Layer):
- index.html
- script.js
- style.css

b) Controller Layer:
- REST endpoints

c) Service Layer:
- SpotifyDataService (data processing)
- SpotifyAPIService (external API integration)
- Analysis Components:
- TopSongsAnalysis
- TopAlbumsAnalysis
- TopArtistsAnalysis
- PlayedSongsByDayAnalysis

d) Data Layer:
- streams.csv file
- Any caching mechanisms

##### Flow Indicators

- HTTP requests from frontend to backend
- Data flow between services
- File I/O operations
- External API calls to Spotify

##### Additional Elements

Include:
- Notes about the LocalDateTimeTypeAdapter utility
- Potential rate limiting considerations with Spotify API
- Data flow direction indicators

##### Technical Details to Highlight

- Java-based backend architecture
- RESTful API design
- CSV data processing capabilities
- Integration with Spotify's API
- Analysis pipeline flow

Remember to include a note about potential scaling considerations, especially regarding Spotify API rate limits and data processing optimization.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef analysis fill:#e67e22,stroke:#d35400,color:white
    classDef data fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#e74c3c,stroke:#c0392b,color:white

    %% Frontend Layer
    subgraph Frontend
        UI["Web Interface"]
        HTML["index.html"]
        JS["script.js"]
        CSS["style.css"]
        
        UI --> HTML
        UI --> JS
        UI --> CSS
    end

    %% Backend Controller Layer
    subgraph Controller
        CTRL["SpotifyDataController"]
    end

    %% Service Layer
    subgraph Services
        SDS["SpotifyDataService"]
        SAPI["SpotifyAPIService"]
    end

    %% Analysis Components
    subgraph Analysis
        TSA["TopSongsAnalysis"]
        TAA["TopAlbumsAnalysis"]
        TARA["TopArtistsAnalysis"]
        PSBD["PlayedSongsByDayAnalysis"]
    end

    %% Data Layer
    subgraph Data
        CSV["streams.csv"]
        SHE["StreamingHistoryEntry"]
        LDTA["LocalDateTimeTypeAdapter"]
    end

    %% External Services
    SPOT["Spotify API"]:::external

    %% Relationships
    UI --> CTRL
    CTRL --> SDS
    CTRL --> SAPI
    SDS --> TSA & TAA & TARA & PSBD
    SDS --> CSV
    SDS --> SHE
    SAPI --> SPOT
    SHE --> LDTA

    %% Click Events
    click HTML "https://github.com/Pipluppp/spotify-unwrap/blob/main/src/main/resources/public/index.html"
    click JS "https://github.com/Pipluppp/spotify-unwrap/blob/main/src/main/resources/public/script.js"
    click CSS "https://github.com/Pipluppp/spotify-unwrap/blob/main/src/main/resources/public/style.css"
    click CTRL "https://github.com/Pipluppp/spotify-unwrap/blob/main/src/main/java/SpotifyDataController.java"
    click SDS "https://github.com/Pipluppp/spotify-unwrap/blob/main/src/main/java/SpotifyDataService.java"
    click SAPI "https://github.com/Pipluppp/spotify-unwrap/blob/main/src/main/java/SpotifyAPIService.java"
    click TSA "https://github.com/Pipluppp/spotify-unwrap/blob/main/src/main/java/TopSongsAnalysis.java"
    click TAA "https://github.com/Pipluppp/spotify-unwrap/blob/main/src/main/java/TopAlbumsAnalysis.java"
    click TARA "https://github.com/Pipluppp/spotify-unwrap/blob/main/src/main/java/TopArtistsAnalysis.java"
    click PSBD "https://github.com/Pipluppp/spotify-unwrap/blob/main/src/main/java/PlayedSongsByDayAnalysis.java"
    click CSV "https://github.com/Pipluppp/spotify-unwrap/blob/main/streams.csv"
    click SHE "https://github.com/Pipluppp/spotify-unwrap/blob/main/src/main/java/StreamingHistoryEntry.java"
    click LDTA "https://github.com/Pipluppp/spotify-unwrap/blob/main/src/main/java/LocalDateTimeTypeAdapter.java"

    %% Style Applications
    class UI,HTML,JS,CSS frontend
    class CTRL,SDS,SAPI backend
    class TSA,TAA,TARA,PSBD analysis
    class CSV,SHE,LDTA data
```
