# francoborrelli/spotify-react-web-client architecture

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

- Interactive diagram: https://gitdiagram.com/francoborrelli/spotify-react-web-client
- Repository: https://github.com/francoborrelli/spotify-react-web-client

## Overview

##### Project type and purpose
- This is a single-page, client-side web application (React + TypeScript + Redux) that acts as a Spotify web client.
- It consumes the Spotify Web API (for data fetching) and the Spotify Playback SDK (for in-browser music playback).
- It is packaged as a Dockerized static site served via Nginx (no custom backend).

##### File structure
- Top-level:
- docker/ & Dockerfile + docker-compose.yml – for containerizing and serving the app through Nginx.
- public/ – static assets (index.html, manifest.json, images).
- src/ – application code.
- Within src:
- components/ – reusable UI components (Buttons, Layout, Modals, etc.).
- pages/ – page-level containers organized by route (Home, Search, Album, Artist, Playlist, User, etc.).
- services/ – wrappers around Spotify Web API endpoints and playback logic.
- store/ – Redux setup (store.ts) and feature slices (auth, home, search, playingNow, etc.).
- utils/ & constants/ – helpers, configuration, and app-wide constants.
- i18n/ – internationalization resources.
- Configuration & build scripts: tsconfig.json, package.json, .env.dist.

##### README for additional insights
- Confirms key technologies: React, Redux, Spotify Web API, Spotify Playback SDK.
- Describes features: music browsing, playback controls, playlist management, saved content, devices, follow/unfollow, etc.
- No custom backend – all data comes from Spotify’s services.

##### Elements
- Clear labels: e.g. “React App”, “Redux Store”, “Spotify Web API”, “Nginx”
– UI → Redux actions → Services → Spotify → Redux
– Playback SDK → Audio output in browser
– Browser → Nginx (static asset fetch)
– Green for external services (Spotify endpoints)
– Gray for infrastructure (Docker, Nginx)
- Annotations: list key libraries (Axios, Redux Toolkit, React Router) next to respective components.

##### Final advice
- Both control flow (actions → reducers → UI) and data flow (API calls → state updates).
- The goal is to show, at a glance, how user interactions travel through your React/Redux app to Spotify and back, and how the static assets are served.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["Client Browser"]:::frontend
        Index["Index.tsx"]:::frontend
        App["App.tsx"]:::frontend
        Components["Components"]:::frontend
        Pages["Pages (Routes)"]:::frontend
    end

    %% State Management Layer
    subgraph "State Management"
        direction TB
        Store["Redux Store"]:::state
        AuthSlice["Auth Slice"]:::state
        HomeSlice["Home Slice"]:::state
        SearchSlice["Search Slice"]:::state
        PlayingNowSlice["PlayingNow Slice"]:::state
        OtherSlices["Other Feature Slices"]:::state
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        AxiosConfig["HTTP Client (axios.ts)"]:::service
        AuthService["Auth Service"]:::service
        SpotifyAPI["Spotify Web API Services"]:::service
        PlayerService["Playback SDK Wrapper"]:::service
    end

    %% External Services
    subgraph "External Services"
        direction TB
        WebAPI["Spotify Web API"]:::external
        PlaybackSDK["Spotify Playback SDK"]:::external
        OAuth["Spotify OAuth"]:::external
    end

    %% Deployment Infrastructure
    subgraph "Deployment"
        direction TB
        Docker["Docker & Compose"]:::infra
        Nginx["Nginx"]:::infra
        StaticAssets["Static Assets (public/)"]:::infra
    end

    %% Data & Control Flow
    Browser -->|"GET /"| Nginx
    Nginx --> StaticAssets
    Browser --> Index
    Index --> App
    App --> Pages
    App --> Components
    Pages -->|"dispatch actions"| Store
    Components -->|"dispatch actions"| Store
    Store --> AxiosConfig
    Store --> AuthService
    Store --> SpotifyAPI
    Store --> PlayerService
    AxiosConfig --> WebAPI
    AuthService --> OAuth
    SpotifyAPI --> WebAPI
    PlayerService --> PlaybackSDK
    WebAPI -->|"response data"| Store
    PlaybackSDK -->|"audio stream"| Browser

    %% Click Events
    click Index "https://github.com/francoborrelli/spotify-react-web-client/blob/main/src/index.tsx"
    click App "https://github.com/francoborrelli/spotify-react-web-client/blob/main/src/App.tsx"
    click Components "https://github.com/francoborrelli/spotify-react-web-client/tree/main/src/components/"
    click Pages "https://github.com/francoborrelli/spotify-react-web-client/tree/main/src/pages/"
    click Store "https://github.com/francoborrelli/spotify-react-web-client/blob/main/src/store/store.ts"
    click AuthSlice "https://github.com/francoborrelli/spotify-react-web-client/blob/main/src/store/slices/auth.ts"
    click HomeSlice "https://github.com/francoborrelli/spotify-react-web-client/blob/main/src/store/slices/home.ts"
    click SearchSlice "https://github.com/francoborrelli/spotify-react-web-client/blob/main/src/store/slices/search.ts"
    click PlayingNowSlice "https://github.com/francoborrelli/spotify-react-web-client/blob/main/src/store/slices/playingNow.ts"
    click OtherSlices "https://github.com/francoborrelli/spotify-react-web-client/tree/main/src/store/slices/"
    click AxiosConfig "https://github.com/francoborrelli/spotify-react-web-client/blob/main/src/axios.ts"
    click AuthService "https://github.com/francoborrelli/spotify-react-web-client/blob/main/src/services/auth.ts"
    click SpotifyAPI "https://github.com/francoborrelli/spotify-react-web-client/tree/main/src/services/"
    click PlayerService "https://github.com/francoborrelli/spotify-react-web-client/blob/main/src/services/player.ts"
    click Docker "https://github.com/francoborrelli/spotify-react-web-client/tree/main/Dockerfile"
    click Docker "https://github.com/francoborrelli/spotify-react-web-client/blob/main/docker-compose.yml"
    click Nginx "https://github.com/francoborrelli/spotify-react-web-client/blob/main/docker/nginx/default.conf"
    click StaticAssets "https://github.com/francoborrelli/spotify-react-web-client/tree/main/public/"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0366D6,color:#0366D6
    classDef state fill:#FFEDD5,stroke:#D97706,color:#B45309
    classDef service fill:#EDE9FE,stroke:#7C3AED,color:#5B21B6
    classDef external fill:#D1FAE5,stroke:#10B981,color:#047857
    classDef infra fill:#F3F4F6,stroke:#6B7280,color:#374151
```
