# lakshya-saini/music-streaming-app architecture

> Architecture diagram of the GitHub repository lakshya-saini/music-streaming-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lakshya-saini/music-streaming-app
- Repository: https://github.com/lakshya-saini/music-streaming-app

## Overview

Sonora’s main workflow is catalog browsing and authenticated playback, alongside two admin ingestion paths: direct WAV upload and YouTube import. The React client routes pages, maintains auth/library state, and calls a NestJS API; the backend manages catalog metadata, processes audio into renditions, and streams byte ranges from S3. The graph preserves documented adaptive playback and cover-art capabilities. Some client playback and backend streaming details are described only in the README; those links are cited there rather than presented as inspected implementation.

Main entry points: [`server/src/modules/tracks/services/tracks.service.ts`](https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/tracks/services/tracks.service.ts) (Track service), [`client/src/App.tsx`](https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/App.tsx) (App routes), [`server/src/modules/tracks/controllers/tracks.controller.ts`](https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/tracks/controllers/tracks.controller.ts) (Track endpoints), [`server/src/modules/auth/controllers/auth.controller.ts`](https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/auth/controllers/auth.controller.ts) (Auth endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_app["App routes<br/>[App.tsx]"]
  node_authstate["Auth state<br/>[AuthContext.tsx]"]
  node_library["Library state<br/>[LibraryContext.tsx]"]
  node_browse["Browse pages<br/>[BrowsePage.tsx]"]
  node_uploadui["Upload page<br/>[UploadPage.tsx]"]
  node_clientauth["Auth API<br/>[auth.ts]"]
  node_clienttracks["Tracks API<br/>[tracks.ts]"]
  node_player["Music player<br/>[MusicPlayer.tsx]"]
end

subgraph group_identity["Identity"]
  node_authcontroller["Auth endpoints<br/>[auth.controller.ts]"]
  node_authservice["Auth service<br/>[auth.service.ts]"]
  node_users[("User records<br/>[user.schema.ts]")]
  node_jwtguard["JWT guard<br/>[jwt-auth.guard.ts]"]
end

subgraph group_catalog["Catalog and playback"]
  node_trackscontroller["Track endpoints"]
  node_tracksservice["Track service<br/>[tracks.service.ts]"]
  node_trackrecords[("Track records<br/>[track.schema.ts]")]
  node_assetrecords[("Audio assets")]
  node_mongodb[("MongoDB")]
end

subgraph group_ingestion["Ingestion and media"]
  node_processing["Audio processing"]
  node_youtube["YouTube import"]
  node_storage["Audio storage"]
  node_s3[("S3 storage")]
end

node_listener(("Listener"))
node_admin(("Admin"))

node_listener -->|"browses"| node_app
node_admin -->|"uses upload"| node_app
node_app -->|"routes to"| node_browse
node_app -->|"guards route"| node_uploadui
node_app -->|"provides"| node_authstate
node_app -->|"provides"| node_library
node_authstate -->|"uses"| node_clientauth
node_library -->|"loads catalog"| node_clienttracks
node_uploadui -->|"requests uploads"| node_clienttracks
node_browse -->|"reads library"| node_library
node_clientauth -->|"calls auth API"| node_authcontroller
node_clienttracks -->|"calls tracks API"| node_trackscontroller
node_listener -->|"starts playback"| node_player
node_player -->|"requests stream"| node_trackscontroller
node_authcontroller -->|"delegates"| node_authservice
node_authservice -->|"reads and writes"| node_users
node_authcontroller -->|"protects profile"| node_jwtguard
node_trackscontroller -->|"delegates"| node_tracksservice
node_trackscontroller -->|"guards stream"| node_jwtguard
node_tracksservice -->|"reads and writes"| node_trackrecords
node_tracksservice -->|"reads and writes"| node_assetrecords
node_tracksservice -->|"encodes renditions"| node_processing
node_tracksservice -->|"downloads media"| node_youtube
node_tracksservice -->|"uploads and streams"| node_storage
node_storage -->|"reads and writes"| node_s3
node_tracksservice -->|"persists catalog"| node_mongodb
node_tracksservice -->|"stores media"| node_s3

click node_app "https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/App.tsx"
click node_authstate "https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/state/AuthContext.tsx"
click node_library "https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/state/LibraryContext.tsx"
click node_browse "https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/pages/BrowsePage.tsx"
click node_uploadui "https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/pages/UploadPage.tsx"
click node_clientauth "https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/api/auth.ts"
click node_clienttracks "https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/api/tracks.ts"
click node_player "https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/components/MusicPlayer.tsx"
click node_authcontroller "https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/auth/controllers/auth.controller.ts"
click node_authservice "https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/auth/services/auth.service.ts"
click node_users "https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/auth/schemas/user.schema.ts"
click node_jwtguard "https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/auth/guards/jwt-auth.guard.ts"
click node_trackscontroller "https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/tracks/controllers/tracks.controller.ts"
click node_tracksservice "https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/tracks/services/tracks.service.ts"
click node_trackrecords "https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/tracks/schemas/track.schema.ts"
click node_assetrecords "https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/tracks/schemas/audio-asset.schema.ts"
click node_processing "https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/tracks/services/audio-processing.service.ts"
click node_youtube "https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/tracks/services/youtube-import.service.ts"
click node_storage "https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/tracks/services/audio-storage.service.ts"

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_app,node_authstate,node_library,node_browse,node_uploadui,node_clientauth,node_clienttracks,node_player toneBlue
class node_authcontroller,node_authservice,node_users,node_jwtguard toneAmber
class node_trackscontroller,node_tracksservice,node_trackrecords,node_assetrecords,node_mongodb toneMint
class node_processing,node_youtube,node_storage,node_s3 toneRose
class node_listener,node_admin toneIndigo
```

## Components

### React client

- [App routes](https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/App.tsx): `client/src/App.tsx`
- [Auth state](https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/state/AuthContext.tsx): `client/src/state/AuthContext.tsx`
- [Library state](https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/state/LibraryContext.tsx): `client/src/state/LibraryContext.tsx`
- [Browse pages](https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/pages/BrowsePage.tsx): `client/src/pages/BrowsePage.tsx`
- [Upload page](https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/pages/UploadPage.tsx): `client/src/pages/UploadPage.tsx`
- [Auth API](https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/api/auth.ts): `client/src/api/auth.ts`
- [Tracks API](https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/api/tracks.ts): `client/src/api/tracks.ts`
- [Music player](https://github.com/lakshya-saini/music-streaming-app/blob/master/client/src/components/MusicPlayer.tsx): `client/src/components/MusicPlayer.tsx`

### Identity

- [Auth endpoints](https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/auth/controllers/auth.controller.ts): `server/src/modules/auth/controllers/auth.controller.ts`
- [Auth service](https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/auth/services/auth.service.ts): `server/src/modules/auth/services/auth.service.ts`
- [User records](https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/auth/schemas/user.schema.ts): `server/src/modules/auth/schemas/user.schema.ts`
- [JWT guard](https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/auth/guards/jwt-auth.guard.ts): `server/src/modules/auth/guards/jwt-auth.guard.ts`

### Catalog and playback

- [Track endpoints](https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/tracks/controllers/tracks.controller.ts): `server/src/modules/tracks/controllers/tracks.controller.ts`
- [Track service](https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/tracks/services/tracks.service.ts): `server/src/modules/tracks/services/tracks.service.ts`
- [Track records](https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/tracks/schemas/track.schema.ts): `server/src/modules/tracks/schemas/track.schema.ts`
- [Audio assets](https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/tracks/schemas/audio-asset.schema.ts): `server/src/modules/tracks/schemas/audio-asset.schema.ts`
- **MongoDB**

### Ingestion and media

- [Audio processing](https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/tracks/services/audio-processing.service.ts): `server/src/modules/tracks/services/audio-processing.service.ts`
- [YouTube import](https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/tracks/services/youtube-import.service.ts): `server/src/modules/tracks/services/youtube-import.service.ts`
- [Audio storage](https://github.com/lakshya-saini/music-streaming-app/blob/master/server/src/modules/tracks/services/audio-storage.service.ts): `server/src/modules/tracks/services/audio-storage.service.ts`
- **S3 storage**

### Other components

- **Listener**
- **Admin**

## Connections

- Listener → App routes: browses
- Admin → App routes: uses upload
- App routes → Browse pages: routes to (evidence: `client/src/App.tsx`)
- App routes → Upload page: guards route (evidence: `client/src/App.tsx`)
- App routes → Auth state: provides (evidence: `client/src/App.tsx`)
- App routes → Library state: provides (evidence: `client/src/App.tsx`)
- Auth state → Auth API: uses (evidence: `client/src/state/AuthContext.tsx`)
- Library state → Tracks API: loads catalog (evidence: `client/src/state/LibraryContext.tsx`)
- Upload page → Tracks API: requests uploads (evidence: `client/src/pages/UploadPage.tsx`)
- Browse pages → Library state: reads library (evidence: `client/src/pages/BrowsePage.tsx`)
- Auth API → Auth endpoints: calls auth API
- Tracks API → Track endpoints: calls tracks API
- Listener → Music player: starts playback
- Music player → Track endpoints: requests stream
- Auth endpoints → Auth service: delegates (evidence: `server/src/modules/auth/controllers/auth.controller.ts`)
- Auth service → User records: reads and writes (evidence: `server/src/modules/auth/services/auth.service.ts`)
- Auth endpoints → JWT guard: protects profile (evidence: `server/src/modules/auth/controllers/auth.controller.ts`)
- Track endpoints → Track service: delegates (evidence: `server/src/modules/tracks/controllers/tracks.controller.ts`)
- Track endpoints → JWT guard: guards stream (evidence: `server/src/modules/tracks/controllers/tracks.controller.ts`)
- Track service → Track records: reads and writes (evidence: `server/src/modules/tracks/services/tracks.service.ts`)
- Track service → Audio assets: reads and writes (evidence: `server/src/modules/tracks/services/tracks.service.ts`)
- Track service → Audio processing: encodes renditions (evidence: `server/src/modules/tracks/services/tracks.service.ts`)
- Track service → YouTube import: downloads media (evidence: `server/src/modules/tracks/services/tracks.service.ts`)
- Track service → Audio storage: uploads and streams (evidence: `server/src/modules/tracks/services/tracks.service.ts`)
- Audio storage → S3 storage: reads and writes (evidence: `server/src/modules/tracks/services/audio-storage.service.ts`)
- Track service → MongoDB: persists catalog
- Track service → S3 storage: stores media
