# muradbaghirli/spotifyrecommendationsystem architecture

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

- Interactive diagram: https://gitdiagram.com/muradbaghirli/spotifyrecommendationsystem
- Repository: https://github.com/muradbaghirli/spotifyrecommendationsystem

## Overview

Song Recommender exposes three FastAPI recommendation endpoints. A song query is passed to content-based similarity ranking; playlist endpoints retrieve Spotify playlist data, combine known local song vectors with vectors fetched for unknown tracks, and return recommendations with playlist and track metadata. The README also identifies Spotify API retrieval as a product capability. The excerpts show endpoint dispatch, vector construction, ranking, and Spotify calls, but omit dataset-loading details and much of the playlist implementation; the dataset link is therefore unverified.

Main entry points: [`recommender.py`](https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/recommender.py) (Recommender), [`main.py`](https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/main.py) (Song endpoint), [`final_data.csv`](https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/final_data.csv) (Song dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry points"]
  node_songs_endpoint["Song endpoint<br/>[main.py]"]
  node_playlist_v1_endpoint["Playlist v1 endpoint<br/>[main.py]"]
  node_playlist_v2_endpoint["Playlist v2 endpoint<br/>[main.py]"]
end

subgraph group_recommendations["Recommendation workflows"]
  node_recommender["Recommender<br/>[recommender.py]"]
  node_song_ranking["Song ranking<br/>[recommender.py]"]
  node_playlist_processing["Playlist processing<br/>[recommender.py]"]
  node_unknown_vectors["Unknown-track vectors<br/>[recommender.py]"]
  node_playlist_metadata["Playlist metadata<br/>[recommender.py]"]
end

subgraph group_integrations["Data and integrations"]
  node_local_data[("Song dataset<br/>[final_data.csv]")]
  node_spotify["Spotify API"]
end

node_user(("API user"))

node_user -->|"submits query"| node_songs_endpoint
node_user -->|"submits playlist"| node_playlist_v1_endpoint
node_user -->|"submits playlist"| node_playlist_v2_endpoint
node_songs_endpoint -->|"calls song recommendations"| node_recommender
node_playlist_v1_endpoint -->|"calls playlist v1"| node_recommender
node_playlist_v2_endpoint -->|"calls playlist v2"| node_recommender
node_recommender -->|"ranks by similarity"| node_song_ranking
node_recommender -->|"processes playlists"| node_playlist_processing
node_playlist_processing -->|"builds missing vectors"| node_unknown_vectors
node_playlist_processing -->|"retrieves playlist info"| node_playlist_metadata
node_recommender -->|"retrieves track data"| node_spotify
node_playlist_processing -->|"fetches playlist"| node_spotify
node_recommender -.->|"loads song vectors"| node_local_data

click node_songs_endpoint "https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/main.py"
click node_playlist_v1_endpoint "https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/main.py"
click node_playlist_v2_endpoint "https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/main.py"
click node_recommender "https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/recommender.py"
click node_song_ranking "https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/recommender.py"
click node_playlist_processing "https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/recommender.py"
click node_unknown_vectors "https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/recommender.py"
click node_playlist_metadata "https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/recommender.py"
click node_local_data "https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/final_data.csv"

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_songs_endpoint,node_playlist_v1_endpoint,node_playlist_v2_endpoint,node_user toneBlue
class node_recommender,node_song_ranking,node_playlist_processing,node_unknown_vectors,node_playlist_metadata toneAmber
class node_local_data,node_spotify toneMint
```

## Components

### API entry points

- [Song endpoint](https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/main.py): `main.py`
- [Playlist v1 endpoint](https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/main.py): `main.py`
- [Playlist v2 endpoint](https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/main.py): `main.py`

### Recommendation workflows

- [Recommender](https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/recommender.py): `recommender.py`
- [Song ranking](https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/recommender.py): `recommender.py`
- [Playlist processing](https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/recommender.py): `recommender.py`
- [Unknown-track vectors](https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/recommender.py): `recommender.py`
- [Playlist metadata](https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/recommender.py): `recommender.py`

### Data and integrations

- [Song dataset](https://github.com/muradbaghirli/spotifyrecommendationsystem/blob/master/final_data.csv): `final_data.csv`
- **Spotify API**

### Other components

- **API user**

## Connections

- API user → Song endpoint: submits query (evidence: `main.py`)
- API user → Playlist v1 endpoint: submits playlist (evidence: `main.py`)
- API user → Playlist v2 endpoint: submits playlist (evidence: `main.py`)
- Song endpoint → Recommender: calls song recommendations (evidence: `main.py`)
- Playlist v1 endpoint → Recommender: calls playlist v1 (evidence: `main.py`)
- Playlist v2 endpoint → Recommender: calls playlist v2 (evidence: `main.py`)
- Recommender → Song ranking: ranks by similarity (evidence: `recommender.py`)
- Recommender → Playlist processing: processes playlists (evidence: `recommender.py`)
- Playlist processing → Unknown-track vectors: builds missing vectors (evidence: `recommender.py`)
- Playlist processing → Playlist metadata: retrieves playlist info (evidence: `recommender.py`)
- Recommender → Spotify API: retrieves track data (evidence: `recommender.py`)
- Playlist processing → Spotify API: fetches playlist (evidence: `recommender.py`)
- Recommender → Song dataset: loads song vectors
