# nishigandhachoudhury/spotify_clustering architecture

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

- Interactive diagram: https://gitdiagram.com/nishigandhachoudhury/spotify_clustering
- Repository: https://github.com/nishigandhachoudhury/spotify_clustering

## Overview

This repository trains Spotify-song clusters in a Colab-style notebook and serves them through a Streamlit music-discovery app. The training workflow cleans audio features, scales them, fits KMeans, and exports artifacts; the app loads those artifacts and clustered data so users can explore a mood prediction, visualizations, dataset summaries, and cluster insights. The notebook also documents PCA and t-SNE analysis. Source excerpts are partial, so app links are limited to relationships shown there or documented in the README.

Main entry points: [`app.py`](https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/app.py) (Streamlit app), [`spotify_clustering.py`](https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/spotify_clustering.py) (Feature scaling), [`clustered_songs.csv`](https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/clustered_songs.csv) (Clustered songs), [`kmeans_model.pkl`](https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/kmeans_model.pkl) (Model and scaler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Model training"]
  node_notebook["Training workflow"]
  node_clean["Feature cleaning"]
  node_scale["Feature scaling"]
  node_kmeans["KMeans fitting"]
  node_projection["PCA and t-SNE"]
end

subgraph group_artifacts["Model artifacts"]
  node_clustered_data[("Clustered songs")]
  node_model_files["Model and scaler<br/>[kmeans_model.pkl]"]
end

subgraph group_app["Discovery app"]
  node_streamlit["Streamlit app<br/>[app.py]"]
  node_mood["Mood prediction<br/>[app.py]"]
  node_visualizations["Cluster visualizations<br/>[app.py]"]
  node_overview["Dataset overview<br/>[app.py]"]
  node_insights["Cluster insights<br/>[app.py]"]
end

node_kaggle[("Kaggle songs")]
node_user(("Music explorer"))

node_kaggle -->|"downloads dataset"| node_notebook
node_notebook -->|"cleans features"| node_clean
node_clean -->|"scales features"| node_scale
node_scale -->|"fits clusters"| node_kmeans
node_scale -->|"projects features"| node_projection
node_kmeans -->|"writes labels"| node_clustered_data
node_kmeans -->|"saves model"| node_model_files
node_user -->|"adjusts sliders"| node_streamlit
node_streamlit -->|"loads artifacts"| node_model_files
node_streamlit -->|"loads songs"| node_clustered_data
node_streamlit -->|"predicts mood"| node_mood
node_streamlit -->|"renders views"| node_visualizations
node_streamlit -->|"shows dataset"| node_overview
node_streamlit -->|"shows insights"| node_insights

click node_notebook "https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/spotify_clustering.py"
click node_clean "https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/spotify_clustering.py"
click node_scale "https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/spotify_clustering.py"
click node_kmeans "https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/spotify_clustering.py"
click node_projection "https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/spotify_clustering.py"
click node_clustered_data "https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/clustered_songs.csv"
click node_model_files "https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/kmeans_model.pkl"
click node_streamlit "https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/app.py"
click node_mood "https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/app.py"
click node_visualizations "https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/app.py"
click node_overview "https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/app.py"
click node_insights "https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/app.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_notebook,node_clean,node_scale,node_kmeans,node_projection toneBlue
class node_clustered_data,node_model_files,node_kaggle toneAmber
class node_streamlit,node_mood,node_visualizations,node_overview,node_insights toneMint
class node_user toneIndigo
```

## Components

### Model training

- [Training workflow](https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/spotify_clustering.py): `spotify_clustering.py`
- [Feature cleaning](https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/spotify_clustering.py): `spotify_clustering.py`
- [Feature scaling](https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/spotify_clustering.py): `spotify_clustering.py`
- [KMeans fitting](https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/spotify_clustering.py): `spotify_clustering.py`
- [PCA and t-SNE](https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/spotify_clustering.py): `spotify_clustering.py`

### Model artifacts

- [Clustered songs](https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/clustered_songs.csv): `clustered_songs.csv`
- [Model and scaler](https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/kmeans_model.pkl): `kmeans_model.pkl`

### Discovery app

- [Streamlit app](https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/app.py): `app.py`
- [Mood prediction](https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/app.py): `app.py`
- [Cluster visualizations](https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/app.py): `app.py`
- [Dataset overview](https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/app.py): `app.py`
- [Cluster insights](https://github.com/nishigandhachoudhury/spotify_clustering/blob/main/app.py): `app.py`

### Other components

- **Kaggle songs**
- **Music explorer**

## Connections

- Kaggle songs → Training workflow: downloads dataset (evidence: `spotify_clustering.py`)
- Training workflow → Feature cleaning: cleans features (evidence: `spotify_clustering.py`)
- Feature cleaning → Feature scaling: scales features (evidence: `spotify_clustering.py`)
- Feature scaling → KMeans fitting: fits clusters (evidence: `spotify_clustering.py`)
- Feature scaling → PCA and t-SNE: projects features (evidence: `spotify_clustering.py`)
- KMeans fitting → Clustered songs: writes labels (evidence: `spotify_clustering.py`)
- KMeans fitting → Model and scaler: saves model (evidence: `spotify_clustering.py`)
- Music explorer → Streamlit app: adjusts sliders (evidence: `app.py`)
- Streamlit app → Model and scaler: loads artifacts (evidence: `app.py`)
- Streamlit app → Clustered songs: loads songs (evidence: `app.py`)
- Streamlit app → Mood prediction: predicts mood (evidence: `app.py`)
- Streamlit app → Cluster visualizations: renders views (evidence: `README.md`)
- Streamlit app → Dataset overview: shows dataset (evidence: `app.py`)
- Streamlit app → Cluster insights: shows insights (evidence: `app.py`)
