# ndofhiwa/spotify-recommender architecture

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

- Interactive diagram: https://gitdiagram.com/ndofhiwa/spotify-recommender
- Repository: https://github.com/ndofhiwa/spotify-recommender

## Overview

This is a Streamlit Spotify music recommender. A user authenticates with Spotify, the app loads a normalized song dataset, selects a seed song, computes feature-based similar tracks, and displays recommendations; users can also create Spotify playlists from recommendations or manually selected songs. A separate authenticated analytics page summarizes the dataset, audio features, recommendation history, clusters, and artists. The principal runtime calls are visible in the main entry point and sampled modules; analytics capabilities are documented or visible in excerpts, though some internal details are unsampled.

Main entry points: [`main.py`](https://github.com/ndofhiwa/spotify-recommender/blob/main/main.py) (App Orchestrator), [`pages/analytics.py`](https://github.com/ndofhiwa/spotify-recommender/blob/main/pages/analytics.py) (Analytics Page), [`Recommender/analytics.py`](https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/analytics.py) (Analytics Dashboard), [`Recommender/ui.py`](https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/ui.py) (Streamlit Interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and Interface"]
  node_main["App Orchestrator<br/>[main.py]"]
  node_ui["Streamlit Interface<br/>[ui.py]"]
  node_analytics_page["Analytics Page<br/>[analytics.py]"]
end

subgraph group_recommendations["Recommendation Data"]
  node_data["Song Data Loader<br/>[data.py]"]
  node_song_csv["Normalized Songs"]
  node_recommend["Similarity Recommender<br/>[recommend.py]"]
end

subgraph group_spotify["Spotify Integration"]
  node_login["Session Login<br/>[login.py]"]
  node_auth["Spotify OAuth<br/>[auth.py]"]
  node_spotify_api{{"Spotify Web API"}}
  node_playlist["Playlist Operations<br/>[playlist_utils.py]"]
end

subgraph group_insights["Analytics"]
  node_tracking["Recommendation Tracking<br/>[analytics.py]"]
  node_dashboard["Analytics Dashboard<br/>[analytics.py]"]
  node_visuals["Feature Visualizations<br/>[analytics.py]"]
  node_clusters["Music Clusters<br/>[analytics.py]"]
  node_artist_insights["Artist Insights<br/>[analytics.py]"]
end

node_user(("Listener"))

node_user -->|"uses"| node_main
node_main -->|"checks login"| node_login
node_login -->|"requests client"| node_auth
node_auth -->|"authenticates"| node_spotify_api
node_main -->|"loads songs"| node_data
node_data -.->|"reads"| node_song_csv
node_main -->|"renders interface"| node_ui
node_main -->|"gets suggestions"| node_recommend
node_main -->|"records results"| node_tracking
node_main -->|"creates custom playlist"| node_playlist
node_ui -->|"creates recommendations playlist"| node_playlist
node_playlist -->|"searches and writes"| node_spotify_api
node_ui -->|"opens page"| node_analytics_page
node_analytics_page -->|"checks login"| node_login
node_analytics_page -->|"loads songs"| node_data
node_analytics_page -->|"shows dashboard"| node_dashboard
node_dashboard -->|"renders sections"| node_visuals
node_dashboard -->|"renders section"| node_clusters
node_dashboard -->|"renders section"| node_artist_insights

click node_main "https://github.com/ndofhiwa/spotify-recommender/blob/main/main.py"
click node_ui "https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/ui.py"
click node_analytics_page "https://github.com/ndofhiwa/spotify-recommender/blob/main/pages/analytics.py"
click node_login "https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/login.py"
click node_auth "https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/auth.py"
click node_data "https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/data.py"
click node_song_csv "https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/songs_normalize.csv"
click node_recommend "https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/recommend.py"
click node_playlist "https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/playlist_utils.py"
click node_tracking "https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/analytics.py"
click node_dashboard "https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/analytics.py"
click node_visuals "https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/analytics.py"
click node_clusters "https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/analytics.py"
click node_artist_insights "https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/analytics.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_ui,node_analytics_page toneBlue
class node_data,node_song_csv,node_recommend toneAmber
class node_login,node_auth,node_spotify_api,node_playlist toneMint
class node_tracking,node_dashboard,node_visuals,node_clusters,node_artist_insights toneRose
class node_user toneIndigo
```

## Components

### App and Interface

- [App Orchestrator](https://github.com/ndofhiwa/spotify-recommender/blob/main/main.py): `main.py`
- [Streamlit Interface](https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/ui.py): `Recommender/ui.py`
- [Analytics Page](https://github.com/ndofhiwa/spotify-recommender/blob/main/pages/analytics.py): `pages/analytics.py`

### Recommendation Data

- [Song Data Loader](https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/data.py): `Recommender/data.py`
- [Normalized Songs](https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/songs_normalize.csv): `Recommender/songs_normalize.csv`
- [Similarity Recommender](https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/recommend.py): `Recommender/recommend.py`

### Spotify Integration

- [Session Login](https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/login.py): `Recommender/login.py`
- [Spotify OAuth](https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/auth.py): `Recommender/auth.py`
- **Spotify Web API**
- [Playlist Operations](https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/playlist_utils.py): `Recommender/playlist_utils.py`

### Analytics

- [Recommendation Tracking](https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/analytics.py): `Recommender/analytics.py`
- [Analytics Dashboard](https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/analytics.py): `Recommender/analytics.py`
- [Feature Visualizations](https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/analytics.py): `Recommender/analytics.py`
- [Music Clusters](https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/analytics.py): `Recommender/analytics.py`
- [Artist Insights](https://github.com/ndofhiwa/spotify-recommender/blob/main/Recommender/analytics.py): `Recommender/analytics.py`

### Other components

- **Listener**

## Connections

- Listener → App Orchestrator: uses (evidence: `README.md`)
- App Orchestrator → Session Login: checks login (evidence: `main.py`)
- Session Login → Spotify OAuth: requests client (evidence: `Recommender/login.py`)
- Spotify OAuth → Spotify Web API: authenticates (evidence: `Recommender/auth.py`)
- App Orchestrator → Song Data Loader: loads songs (evidence: `main.py`)
- Song Data Loader → Normalized Songs: reads
- App Orchestrator → Streamlit Interface: renders interface (evidence: `main.py`)
- App Orchestrator → Similarity Recommender: gets suggestions (evidence: `main.py`)
- App Orchestrator → Recommendation Tracking: records results (evidence: `main.py`)
- App Orchestrator → Playlist Operations: creates custom playlist (evidence: `main.py`)
- Streamlit Interface → Playlist Operations: creates recommendations playlist (evidence: `Recommender/ui.py`)
- Playlist Operations → Spotify Web API: searches and writes (evidence: `Recommender/playlist_utils.py`)
- Streamlit Interface → Analytics Page: opens page (evidence: `Recommender/ui.py`)
- Analytics Page → Session Login: checks login (evidence: `pages/analytics.py`)
- Analytics Page → Song Data Loader: loads songs (evidence: `pages/analytics.py`)
- Analytics Page → Analytics Dashboard: shows dashboard (evidence: `pages/analytics.py`)
- Analytics Dashboard → Feature Visualizations: renders sections (evidence: `Recommender/analytics.py`)
- Analytics Dashboard → Music Clusters: renders section (evidence: `Recommender/analytics.py`)
- Analytics Dashboard → Artist Insights: renders section (evidence: `Recommender/analytics.py`)
