Design Music Streaming Service like Spotify

Difficulty: Hard Source: awesome-low-level-design

Requirements

  1. Browse/search songs, albums, artists
  2. Create/manage playlists
  3. User authentication/authorization
  4. Play, pause, skip, seek within songs
  5. Recommendations based on preferences/history
  6. Handle concurrent requests
  7. Scalable
  8. Extensible (social sharing, offline playback)

Class Diagram

Class Diagram


Classes, Interfaces and Enumerations

Class/Interface Description
Song Core music entity with title, artist, album, duration
Album Collection of songs by an artist with release info
Artist Artist name, albums, songs catalog
User Id, username, password, playlists list
Playlist List of songs with add/remove operations
MusicLibrary Singleton; stores and manages songs, albums, artists
UserManager Singleton; registration, login
MusicPlayer Play, pause, skip, seek functionality
MusicRecommender Singleton; recommendations from preferences/history

Design Patterns Used

Pattern Application
Singleton MusicLibrary centralizes the music catalog; UserManager handles all user operations; MusicRecommender provides a single recommendation engine

Code Implementations

Language Source Code
Java View on GitHub
Python View on GitHub
C++ View on GitHub
C# View on GitHub
Go View on GitHub