The Problem

Spotify's built-in "Wrapped" gives you stats once a year. your_spotify solves that by continuously polling the Spotify API and storing your listening history in MongoDB, then presenting it through a self-hosted dashboard. You get persistent, queryable statistics instead of an annual snapshot.

What This Does

The repo is a fork of Yooooomi/your_spotify (4,547 stars upstream). It's a monorepo with two applications under apps/: a Node/Express server (apps/server) that polls Spotify's API and writes to MongoDB, and a React client (apps/client) that renders the statistics dashboard. The server handles OAuth with Spotify, imports historical data from Spotify's privacy export, and serves the REST API. The client is a TypeScript/React SPA with Redux state management, charts, and playlist management.

How It Is Wired

The entry point is apps/client/src/App.tsx, which mounts the React tree and sets up routing. The client talks to the server through apps/client/src/services/apis/api.ts, which wraps all REST calls. That module is a hub with 45 incoming dependencies and sits inside an import cycle with apps/client/src/services/redux/modules/user/selector.ts and apps/client/src/services/redux/tools.ts — changing the API layer touches nearly every feature, and the cycle makes refactoring harder than it should be.

The server side polls Spotify's API via apps/server/src/tools/apis/spotifyApi.ts, which has deep nesting (indentation depth 6) and is a candidate for refactoring with guard clauses. Data flows from Spotify → server → MongoDB → client API → Redux store → UI components. The most-connected module is apps/client/src/components/Text/index.ts with 68 dependents; it's a stable, low-churn component, but any change there has wide blast radius.

The client uses Redux with hooks (apps/client/src/services/hooks/hooks.ts, 47 dependents) and a typed service layer (apps/client/src/services/types.ts, 53 dependents). The App.tsx component imports 28 modules, making it the top-level integration point.

How To Use It

Setup: Clone and install with pnpm (the package manager is pnpm per the lockfile):

git clone https://github.com/moses-y/your_spotify
cd your_spotify
pnpm install

Configuration: Required environment variables, per the README: CLIENT_ENDPOINT, API_ENDPOINT, SPOTIFY_PUBLIC, SPOTIFY_SECRET, and optionally TIMEZONE and MONGO_ENDPOINT. You must create a Spotify application via their developer dashboard and add your redirect URI.

Running it: The README documents Docker Compose as the recommended path. The repo includes Dockerfile.client, Dockerfile.server, and production variants. For local development, follow LOCAL_INSTALL.md — the client entry point is apps/client/scripts/run/run.sh and the server starts via its own scripts under apps/server/scripts/.

Real-World Use

Self-hosted listening analytics: deploy the server and client containers behind a reverse proxy, point them at a MongoDB instance, and let the server poll Spotify every few minutes. The dashboard shows top artists, songs, albums, listening time, and trends over custom date ranges. You can also import your full Spotify privacy export (JSON files) via the server's import endpoint to backfill history before the tracker was installed.

Code Health & Issues

Static analysis found 63 findings (37 high, 26 medium) across 5 kinds:

  • High – Import cycles (28 instances): apps/client/src/services/apis/api.ts, apps/client/src/services/redux/modules/user/selector.ts, apps/client/src/services/redux/tools.ts participate in circular imports. Fix: extract shared types or invert dependencies.
  • High – Hub modules (21 instances): apps/client/src/components/Text/index.ts (68 dependents), apps/client/src/services/types.ts (53), apps/client/src/services/hooks/hooks.ts (47). Keep these stable.
  • High – Deep nesting (9 instances): apps/server/src/tools/apis/spotifyApi.ts, apps/server/src/database/queries/user.ts, apps/client/src/components/ThreePoints/ThreePoints.tsx hit indentation depth 6. Flatten with early returns.
  • High – Duplicated code (254 repeated blocks across 50 files): History.tsx, Songs.tsx, Track.tsx, Album.tsx. Extract shared helpers.
  • Medium – High branching density: apps/client/src/scenes/ArtistStats/ArtistRank/ArtistRank.tsx has 20 branch points over 51 lines.

SDLC observations from the structure: no test files exist despite 387 source files (high risk), GitHub Actions workflows don't pin action versions to commit SHAs (supply-chain risk), no permissions block on workflows, no Dependabot config, and Dockerfiles use mutable base image tags (node:25-alpine) without digests. No committed secrets were detected.

The Bottom Line

A functional self-hosted Spotify tracker with a solid feature set inherited from a popular upstream project. The main risks are the absence of tests, circular imports in the core API layer, and CI/CD hygiene gaps. Worth using if you want persistent listening stats and control over your data, but budget time for hardening before relying on it in production.