# ypatel2022/esp32-spotify-display architecture

> Architecture diagram of the GitHub repository ypatel2022/esp32-spotify-display, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ypatel2022/esp32-spotify-display
- Repository: https://github.com/ypatel2022/esp32-spotify-display

## Overview

##### Hardware Layer
- ESP32 WROOM 32 Module
- 1.5-inch OLED Display
- Physical connections between these components

##### Software Components
- Flask Server (Python)
- Spotify API Integration
- ESP32 Firmware

##### Data Flow Representation

- ESP32 → Flask Server (HTTP requests)
- Flask Server → Spotify API (API calls)
- Spotify API → Flask Server (album art data)
- Flask Server → ESP32 (processed image data)
- ESP32 → OLED Display (display commands)

##### Component Details

Server Components (use rectangles):
- main.py (entry point)
- server.py (Flask application)
- spotify.py (Spotify integration)
- Environment configuration (.env)

ESP32 Components (use embedded device symbols):
- WiFi Module
- Application Logic (embedded.ino)
- Controller

##### Authentication Flow
A separate section for:
- Spotify API credentials
- Refresh token mechanism
- WiFi connectivity

- Blue: External Services (Spotify API)
- Green: Server Components
- Yellow: ESP32 Hardware
- Purple: Data Flow Paths
- Red: Authentication/Security Elements

Important Elements to Highlight:
##### Authentication Points

Additional Considerations:
- Notes about key configuration requirements
- Error handling paths
- Real-time update mechanism

- Technical accuracy (showing actual components)
- Clarity (easy to understand at a glance)
- Completeness (including all major systems)
- Practical detail (avoiding over-complexity)

Remember to include version information and any relevant notes about scaling considerations or future enhancements.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        SpotifyAPI[Spotify Web API]:::external
    end

    subgraph Server
        Flask["Flask Server"]:::server
        click Flask "https://github.com/ypatel2022/esp32-spotify-display/blob/main/server/server.py"
        
        Main["Main Entry Point"]:::server
        click Main "https://github.com/ypatel2022/esp32-spotify-display/blob/main/server/main.py"
        
        SpotifyModule["Spotify Integration"]:::server
        click SpotifyModule "https://github.com/ypatel2022/esp32-spotify-display/blob/main/server/spotify.py"
        
        EnvConfig["Environment Config"]:::config
        click EnvConfig "https://github.com/ypatel2022/esp32-spotify-display/blob/main/server/.env.template"
        
        Docker["Docker Container"]:::container
        click Docker "https://github.com/ypatel2022/esp32-spotify-display/tree/main/server/Dockerfile"
        
        Dependencies["Dependencies"]:::config
        click Dependencies "https://github.com/ypatel2022/esp32-spotify-display/blob/main/server/requirements.txt"
    end

    subgraph IoT_Device
        ESP32["ESP32 WROOM 32"]:::hardware
        click ESP32 "https://github.com/ypatel2022/esp32-spotify-display/blob/main/embedded/embedded.ino"
        
        OLED["1.5-inch OLED Display"]:::hardware
        
        EmbeddedConfig["Embedded Config"]:::config
        click EmbeddedConfig "https://github.com/ypatel2022/esp32-spotify-display/blob/main/embedded/template.env.h"
        
        WiFiModule["WiFi Module"]:::hardware
    end

    %% Connections
    SpotifyAPI <--> |API Calls| SpotifyModule
    Main --> Flask
    Flask --> SpotifyModule
    EnvConfig --> Flask
    Dependencies --> Flask
    Docker --> |Contains| Flask
    
    ESP32 <--> |HTTP Requests| Flask
    ESP32 --> WiFiModule
    ESP32 --> OLED
    EmbeddedConfig --> ESP32

    %% Styles
    classDef external fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef server fill:#90EE90,stroke:#333,stroke-width:2px
    classDef hardware fill:#FFE4B5,stroke:#333,stroke-width:2px
    classDef config fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef container fill:#DDA0DD,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        ExtService["External Service"]:::external
        ServerComp["Server Component"]:::server
        HardwareComp["Hardware Component"]:::hardware
        ConfigComp["Configuration"]:::config
        ContainerComp["Container"]:::container
    end
```
