# tsargt/trend-for-you-ui architecture

> Architecture diagram of the GitHub repository tsargt/trend-for-you-ui, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tsargt/trend-for-you-ui
- Repository: https://github.com/tsargt/trend-for-you-ui

## Overview

This is a Spotify discovery and listening-analytics web app. The home page presents country/global and genre charts; the dashboard loads a track dataset for statistics and charts, supports Spotify connection and personal listening analytics, and offers personalized playlist creation. The graph follows the sampled page, hook, and function-invocation relationships; some dashboard details and endpoint wiring are only partially visible, so uncertain links are omitted or marked dashed.

Main entry points: [`src/pages/Dashboard.tsx`](https://github.com/tsargt/trend-for-you-ui/blob/main/src/pages/Dashboard.tsx) (Dashboard Page), [`src/pages/Index.tsx`](https://github.com/tsargt/trend-for-you-ui/blob/main/src/pages/Index.tsx) (Discovery Page), [`src/hooks/useSpotify.ts`](https://github.com/tsargt/trend-for-you-ui/blob/main/src/hooks/useSpotify.ts) (Spotify Hook), [`src/App.tsx`](https://github.com/tsargt/trend-for-you-ui/blob/main/src/App.tsx) (App Router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_app["App Router<br/>[App.tsx]"]
  node_navbar["Navigation<br/>[Navbar.tsx]"]
end

subgraph group_discovery["Music Discovery"]
  node_home["Discovery Page<br/>[Index.tsx]"]
  node_trackcard["Track Cards<br/>[TrackCard.tsx]"]
end

subgraph group_analytics["Analytics And Playlists"]
  node_dashboard["Dashboard Page<br/>[Dashboard.tsx]"]
  node_dataset["Dataset Hook<br/>[useDataset.ts]"]
  node_csv["CSV Statistics<br/>[csvParser.ts]"]
  node_analytics_ui["Dashboard Views"]
  node_recommendations["Recommendation Engine<br/>[recommendations.ts]"]
  node_personal["Personal Music View"]
  node_playlists["Saved Playlists"]
end

subgraph group_integrations["External Integrations"]
  node_spotify_hook["Spotify Hook<br/>[useSpotify.ts]"]
  node_callback["OAuth Callback"]
  node_supabase["Supabase Client<br/>[client.ts]"]
  node_auth_fn["Spotify Auth Function<br/>[index.ts]"]
  node_data_fn["Spotify Data Function<br/>[index.ts]"]
  node_genre_fn["Genre Charts Function<br/>[index.ts]"]
  node_top50_fn["Top 50 Function<br/>[index.ts]"]
  node_playlist_fn["Playlist Function<br/>[index.ts]"]
end

node_user(("Listener"))
node_dataset_file["Track Dataset"]
node_spotify["Spotify"]

node_user -->|"opens"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_callback
node_home -->|"renders"| node_navbar
node_home -->|"renders"| node_trackcard
node_home -->|"invokes"| node_supabase
node_home -->|"requests"| node_genre_fn
node_home -.->|"requests"| node_top50_fn
node_dashboard -->|"renders"| node_navbar
node_dashboard -->|"loads"| node_dataset
node_dataset -->|"parses"| node_csv
node_dataset -->|"fetches"| node_dataset_file
node_dashboard -->|"renders"| node_analytics_ui
node_dashboard -->|"uses"| node_spotify_hook
node_dashboard -->|"uses"| node_playlists
node_dashboard -->|"generates with"| node_recommendations
node_dashboard -->|"renders"| node_personal
node_personal -->|"imports"| node_recommendations
node_navbar -->|"uses"| node_spotify_hook
node_callback -->|"uses"| node_spotify_hook
node_spotify_hook -->|"invokes"| node_supabase
node_spotify_hook -->|"requests"| node_auth_fn
node_spotify_hook -->|"requests"| node_data_fn
node_auth_fn -.->|"authenticates"| node_spotify
node_data_fn -.->|"fetches data"| node_spotify
node_dashboard -.->|"creates playlist"| node_playlist_fn
node_playlist_fn -.->|"creates playlist"| node_spotify

click node_app "https://github.com/tsargt/trend-for-you-ui/blob/main/src/App.tsx"
click node_home "https://github.com/tsargt/trend-for-you-ui/blob/main/src/pages/Index.tsx"
click node_navbar "https://github.com/tsargt/trend-for-you-ui/blob/main/src/components/Navbar.tsx"
click node_trackcard "https://github.com/tsargt/trend-for-you-ui/blob/main/src/components/TrackCard.tsx"
click node_dashboard "https://github.com/tsargt/trend-for-you-ui/blob/main/src/pages/Dashboard.tsx"
click node_dataset "https://github.com/tsargt/trend-for-you-ui/blob/main/src/hooks/useDataset.ts"
click node_csv "https://github.com/tsargt/trend-for-you-ui/blob/main/src/lib/csvParser.ts"
click node_analytics_ui "https://github.com/tsargt/trend-for-you-ui/tree/main/src/components/dashboard"
click node_recommendations "https://github.com/tsargt/trend-for-you-ui/blob/main/src/lib/recommendations.ts"
click node_personal "https://github.com/tsargt/trend-for-you-ui/blob/main/src/components/dashboard/PersonalMusicTab.tsx"
click node_playlists "https://github.com/tsargt/trend-for-you-ui/blob/main/src/hooks/useUserPlaylists.ts"
click node_spotify_hook "https://github.com/tsargt/trend-for-you-ui/blob/main/src/hooks/useSpotify.ts"
click node_callback "https://github.com/tsargt/trend-for-you-ui/blob/main/src/pages/SpotifyCallback.tsx"
click node_supabase "https://github.com/tsargt/trend-for-you-ui/blob/main/src/integrations/supabase/client.ts"
click node_auth_fn "https://github.com/tsargt/trend-for-you-ui/blob/main/supabase/functions/spotify-auth/index.ts"
click node_data_fn "https://github.com/tsargt/trend-for-you-ui/blob/main/supabase/functions/spotify-data/index.ts"
click node_genre_fn "https://github.com/tsargt/trend-for-you-ui/blob/main/supabase/functions/spotify-genre/index.ts"
click node_top50_fn "https://github.com/tsargt/trend-for-you-ui/blob/main/supabase/functions/spotify-top50/index.ts"
click node_playlist_fn "https://github.com/tsargt/trend-for-you-ui/blob/main/supabase/functions/create-playlist/index.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_navbar toneBlue
class node_home,node_trackcard toneAmber
class node_dashboard,node_dataset,node_csv,node_analytics_ui,node_recommendations,node_personal,node_playlists toneMint
class node_spotify_hook,node_callback,node_supabase,node_auth_fn,node_data_fn,node_genre_fn,node_top50_fn,node_playlist_fn toneRose
class node_user,node_dataset_file,node_spotify toneIndigo
```

## Components

### Application

- [App Router](https://github.com/tsargt/trend-for-you-ui/blob/main/src/App.tsx): `src/App.tsx`
- [Navigation](https://github.com/tsargt/trend-for-you-ui/blob/main/src/components/Navbar.tsx): `src/components/Navbar.tsx`

### Music Discovery

- [Discovery Page](https://github.com/tsargt/trend-for-you-ui/blob/main/src/pages/Index.tsx): `src/pages/Index.tsx`
- [Track Cards](https://github.com/tsargt/trend-for-you-ui/blob/main/src/components/TrackCard.tsx): `src/components/TrackCard.tsx`

### Analytics And Playlists

- [Dashboard Page](https://github.com/tsargt/trend-for-you-ui/blob/main/src/pages/Dashboard.tsx): `src/pages/Dashboard.tsx`
- [Dataset Hook](https://github.com/tsargt/trend-for-you-ui/blob/main/src/hooks/useDataset.ts): `src/hooks/useDataset.ts`
- [CSV Statistics](https://github.com/tsargt/trend-for-you-ui/blob/main/src/lib/csvParser.ts): `src/lib/csvParser.ts`
- [Dashboard Views](https://github.com/tsargt/trend-for-you-ui/tree/main/src/components/dashboard): `src/components/dashboard`
- [Recommendation Engine](https://github.com/tsargt/trend-for-you-ui/blob/main/src/lib/recommendations.ts): `src/lib/recommendations.ts`
- [Personal Music View](https://github.com/tsargt/trend-for-you-ui/blob/main/src/components/dashboard/PersonalMusicTab.tsx): `src/components/dashboard/PersonalMusicTab.tsx`
- [Saved Playlists](https://github.com/tsargt/trend-for-you-ui/blob/main/src/hooks/useUserPlaylists.ts): `src/hooks/useUserPlaylists.ts`

### External Integrations

- [Spotify Hook](https://github.com/tsargt/trend-for-you-ui/blob/main/src/hooks/useSpotify.ts): `src/hooks/useSpotify.ts`
- [OAuth Callback](https://github.com/tsargt/trend-for-you-ui/blob/main/src/pages/SpotifyCallback.tsx): `src/pages/SpotifyCallback.tsx`
- [Supabase Client](https://github.com/tsargt/trend-for-you-ui/blob/main/src/integrations/supabase/client.ts): `src/integrations/supabase/client.ts`
- [Spotify Auth Function](https://github.com/tsargt/trend-for-you-ui/blob/main/supabase/functions/spotify-auth/index.ts): `supabase/functions/spotify-auth/index.ts`
- [Spotify Data Function](https://github.com/tsargt/trend-for-you-ui/blob/main/supabase/functions/spotify-data/index.ts): `supabase/functions/spotify-data/index.ts`
- [Genre Charts Function](https://github.com/tsargt/trend-for-you-ui/blob/main/supabase/functions/spotify-genre/index.ts): `supabase/functions/spotify-genre/index.ts`
- [Top 50 Function](https://github.com/tsargt/trend-for-you-ui/blob/main/supabase/functions/spotify-top50/index.ts): `supabase/functions/spotify-top50/index.ts`
- [Playlist Function](https://github.com/tsargt/trend-for-you-ui/blob/main/supabase/functions/create-playlist/index.ts): `supabase/functions/create-playlist/index.ts`

### Other components

- **Listener**
- **Track Dataset**
- **Spotify**

## Connections

- Listener → App Router: opens (evidence: `src/App.tsx`)
- App Router → Discovery Page: routes to (evidence: `src/App.tsx`)
- App Router → Dashboard Page: routes to (evidence: `src/App.tsx`)
- App Router → OAuth Callback: routes to (evidence: `src/App.tsx`)
- Discovery Page → Navigation: renders (evidence: `src/pages/Index.tsx`)
- Discovery Page → Track Cards: renders (evidence: `src/pages/Index.tsx`)
- Discovery Page → Supabase Client: invokes (evidence: `src/pages/Index.tsx`)
- Discovery Page → Genre Charts Function: requests (evidence: `src/pages/Index.tsx`)
- Discovery Page → Top 50 Function: requests
- Dashboard Page → Navigation: renders (evidence: `src/pages/Dashboard.tsx`)
- Dashboard Page → Dataset Hook: loads (evidence: `src/pages/Dashboard.tsx`)
- Dataset Hook → CSV Statistics: parses (evidence: `src/hooks/useDataset.ts`)
- Dataset Hook → Track Dataset: fetches (evidence: `src/hooks/useDataset.ts`)
- Dashboard Page → Dashboard Views: renders (evidence: `src/pages/Dashboard.tsx`)
- Dashboard Page → Spotify Hook: uses (evidence: `src/pages/Dashboard.tsx`)
- Dashboard Page → Saved Playlists: uses (evidence: `src/pages/Dashboard.tsx`)
- Dashboard Page → Recommendation Engine: generates with (evidence: `src/pages/Dashboard.tsx`)
- Dashboard Page → Personal Music View: renders (evidence: `src/pages/Dashboard.tsx`)
- Personal Music View → Recommendation Engine: imports (evidence: `src/components/dashboard/PersonalMusicTab.tsx`)
- Navigation → Spotify Hook: uses (evidence: `src/components/Navbar.tsx`)
- OAuth Callback → Spotify Hook: uses (evidence: `src/pages/SpotifyCallback.tsx`)
- Spotify Hook → Supabase Client: invokes (evidence: `src/hooks/useSpotify.ts`)
- Spotify Hook → Spotify Auth Function: requests (evidence: `src/hooks/useSpotify.ts`)
- Spotify Hook → Spotify Data Function: requests (evidence: `src/hooks/useSpotify.ts`)
- Spotify Auth Function → Spotify: authenticates
- Spotify Data Function → Spotify: fetches data
- Dashboard Page → Playlist Function: creates playlist
- Playlist Function → Spotify: creates playlist
