# comp-alex/mixifystats architecture

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

- Interactive diagram: https://gitdiagram.com/comp-alex/mixifystats
- Repository: https://github.com/comp-alex/mixifystats

## Overview

MixifyStats is a browser-based Spotify listening-stats dashboard with a DJ-style mixer. A user connects Spotify through PKCE authentication; the frontend exchanges or refreshes tokens, requests profile and top-track/artist data, and presents stats and mood analytics. Users can also adjust mixer controls or apply a mood prompt. The backend serves the static app and proxies token requests to Spotify. Source excerpts show the token and data requests, but not all rendering and mood-handler internals, so those links are left unverified.

Main entry points: [`index.html`](https://github.com/comp-alex/mixifystats/blob/main/index.html) (Dashboard UI), [`script.js`](https://github.com/comp-alex/mixifystats/blob/main/script.js) (Stats retrieval), [`api/token.js`](https://github.com/comp-alex/mixifystats/blob/main/api/token.js) (Token exchange), [`server.js`](https://github.com/comp-alex/mixifystats/blob/main/server.js) (App server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard"]
  node_webapp["Dashboard UI<br/>[index.html]"]
  node_stats["Stats retrieval<br/>[script.js]"]
end

subgraph group_auth["Spotify Auth"]
  node_authflow["PKCE sign-in<br/>[script.js]"]
end

subgraph group_mixer["Mood Mixer"]
  node_mood["Mood analytics<br/>[script.js]"]
  node_mixerui["DJ mixer<br/>[index.html]"]
end

subgraph group_backend["Backend"]
  node_tokenroute["Token exchange<br/>[token.js]"]
  node_server["App server<br/>[server.js]"]
end

node_user(("Listener"))
node_spotifydata["Spotify Web API"]

node_user -->|"uses"| node_webapp
node_server -->|"serves static app"| node_webapp
node_webapp -->|"starts sign-in"| node_authflow
node_authflow -->|"exchanges code"| node_tokenroute
node_authflow -->|"loads after sign-in"| node_stats
node_stats -->|"requests profile and tops"| node_spotifydata
node_server -->|"routes POST"| node_tokenroute
node_tokenroute -->|"exchanges or refreshes token"| node_spotifydata
node_user -.->|"adjusts controls"| node_mixerui
node_mixerui -.->|"applies mood prompt"| node_mood
node_mood -.->|"updates mix"| node_mixerui
node_stats -.->|"updates displayed stats"| node_webapp

click node_webapp "https://github.com/comp-alex/mixifystats/blob/main/index.html"
click node_stats "https://github.com/comp-alex/mixifystats/blob/main/script.js"
click node_authflow "https://github.com/comp-alex/mixifystats/blob/main/script.js"
click node_tokenroute "https://github.com/comp-alex/mixifystats/blob/main/api/token.js"
click node_server "https://github.com/comp-alex/mixifystats/blob/main/server.js"
click node_mood "https://github.com/comp-alex/mixifystats/blob/main/script.js"
click node_mixerui "https://github.com/comp-alex/mixifystats/blob/main/index.html"

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_webapp,node_stats toneBlue
class node_authflow toneAmber
class node_mood,node_mixerui,node_spotifydata toneMint
class node_tokenroute,node_server toneRose
class node_user toneIndigo
```

## Components

### Dashboard

- [Dashboard UI](https://github.com/comp-alex/mixifystats/blob/main/index.html): `index.html`
- [Stats retrieval](https://github.com/comp-alex/mixifystats/blob/main/script.js): `script.js`

### Spotify Auth

- [PKCE sign-in](https://github.com/comp-alex/mixifystats/blob/main/script.js): `script.js`

### Mood Mixer

- [Mood analytics](https://github.com/comp-alex/mixifystats/blob/main/script.js): `script.js`
- [DJ mixer](https://github.com/comp-alex/mixifystats/blob/main/index.html): `index.html`

### Backend

- [Token exchange](https://github.com/comp-alex/mixifystats/blob/main/api/token.js): `api/token.js`
- [App server](https://github.com/comp-alex/mixifystats/blob/main/server.js): `server.js`

### Other components

- **Listener**
- **Spotify Web API**

## Connections

- Listener → Dashboard UI: uses (evidence: `README.md`)
- App server → Dashboard UI: serves static app (evidence: `server.js`)
- Dashboard UI → PKCE sign-in: starts sign-in (evidence: `README.md`)
- PKCE sign-in → Token exchange: exchanges code (evidence: `script.js`)
- PKCE sign-in → Stats retrieval: loads after sign-in (evidence: `script.js`)
- Stats retrieval → Spotify Web API: requests profile and tops (evidence: `script.js`)
- App server → Token exchange: routes POST (evidence: `server.js`)
- Token exchange → Spotify Web API: exchanges or refreshes token (evidence: `api/token.js`)
- Listener → DJ mixer: adjusts controls (evidence: `README.md`)
- DJ mixer → Mood analytics: applies mood prompt
- Mood analytics → DJ mixer: updates mix
- Stats retrieval → Dashboard UI: updates displayed stats
