# amanchoudhary1727/spotify-random-tracks-player architecture

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

- Interactive diagram: https://gitdiagram.com/amanchoudhary1727/spotify-random-tracks-player
- Repository: https://github.com/amanchoudhary1727/spotify-random-tracks-player

## Overview

##### Project type and purpose
- This is a small full-stack web application built with Flask (a Python microframework).
- It accepts artist names from a user, fetches random tracks via the Spotify Web API (using the Spotipy library), and triggers playback through Spotify’s playback endpoints.

##### File structure
- Top-level:
- LICENSE, README.md, requirements.txt – project metadata and dependencies.
- Spotify_Web/ – contains all application code.
- Spotify_Web/app.py – the single Flask application module.
- Spotify_Web/static/css/styles.css – custom styling for the UI.
- Spotify_Web/templates/index.html – the Jinja2 template that renders the user form and embeds the Spotify player.

##### README for additional insights
- Tech stack: Python 3.x, Flask, Spotipy, HTML/CSS.
- Deploy/run instructions: local virtualenv, environment variables for CLIENT_ID/CLIENT_SECRET, Flask server on port 5000, OAuth redirect on port 8888.
- Key flows: user enters artists → OAuth dance for API access → retrieve random tracks → call Spotify playback API.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        Browser["Web Browser"]:::frontend
        Template["View (index.html)"]:::frontend
        CSS["Static Assets (styles.css)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        Flask["Flask App (app.py)"]:::backend
        Spotipy["Spotipy Library"]:::backend
        Config["Env Variables (CLIENT_ID, CLIENT_SECRET, REDIRECT_URI)"]:::config
        Req["Dependency Spec (requirements.txt)"]:::config
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Spotify["Spotify Web API"]:::external
    end

    %% Project Metadata
    subgraph "Project Metadata & Docs"
        direction TB
        README["README.md"]:::config
        LICENSE["LICENSE"]:::config
    end

    %% Flows
    Browser -->|"GET /"| Flask
    Flask -->|"render index.html"| Template
    Template -->|"HTML + Jinja2"| Browser
    Browser -->|"loads CSS"| CSS

    Flask -->|"reads env vars"| Config
    Flask -->|"loads dependencies"| Req

    Flask -->|"uses Spotipy for API calls"| Spotipy
    Spotipy -->|"OAuth + Track API + Playback API"| Spotify
    Flask -->|"direct playback command"| Spotify
    Spotify -->|"stream playback via SDK"| Browser

    %% Click Events
    click Flask "https://github.com/amanchoudhary1727/spotify-random-tracks-player/blob/main/Spotify_Web/app.py"
    click Template "https://github.com/amanchoudhary1727/spotify-random-tracks-player/blob/main/Spotify_Web/templates/index.html"
    click CSS "https://github.com/amanchoudhary1727/spotify-random-tracks-player/blob/main/Spotify_Web/static/css/styles.css"
    click Req "https://github.com/amanchoudhary1727/spotify-random-tracks-player/blob/main/requirements.txt"
    click README "https://github.com/amanchoudhary1727/spotify-random-tracks-player/blob/main/README.md"
    click LICENSE "https://github.com/amanchoudhary1727/spotify-random-tracks-player/tree/main/LICENSE"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
    classDef backend fill:#d4edda,stroke:#155724,color:#155724
    classDef external fill:#ffe5b4,stroke:#ad6d00,color:#ad6d00
    classDef config fill:#e2e3e5,stroke:#383d41,color:#383d41
```
