How feli05/spotifytracker works
Project type and purpose
• This is a full-stack, containerized web application called Spotify-Tracker.
• Frontend and backend logic are implemented as a Next.js app (React + serverless API routes).
• A separate Python/Flask “ml-service” container performs model training and inference for music recommendations.
• Data stores include MongoDB Atlas (song metadata, user preferences, recommendations) and Supabase PostgreSQL (Spotify OAuth tokens and user auth).
Main components
a. User Interface (Next.js App)
• Renders pages (login/register, dashboard, recommendation flows) in the browser.
• Hosted in the “web” Docker container.
b. Next.js Serverless API
• Routes under /src/app/api/*.
• Handles:
• Auth endpoints (login, logout) via Supabase.
• Spotify OAuth flows and profile/data fetch.
• MongoDB CRUD (songs, preferences, questionnaires, recommendations).
• Proxy to ML service: /api/ml/process-data.
• External preview-finder calls.
c. ML Service (Flask App)
• Separate Docker container “ml-service.”
• Exposes REST endpoints for clustering, feature extraction, scoring, recommendation.
d. Databases
• Supabase/PostgreSQL: stores OAuth tokens (spotify_tokens), user accounts.
• MongoDB Atlas: stores collections: songs, user preferences, questionnaires, generated recommendations.
e. External Services
• Spotify API: user data, top tracks/artists, playback preview.
• Supabase Auth: sign-up/login, row-level security.
f. Import Scripts
• One-off Node scripts under src/import-scripts that fetch and seed song data into MongoDB.
Relationships and interactions (data flows)
• Browser → Next.js serverless API → Supabase Auth (login/signup).
• Browser → Next.js → Spotify OAuth → Supabase PostgreSQL (store tokens).
• Browser → Next.js → MongoDB (fetch songs, preferences, recs).
• Next.js API → ML service → MongoDB (upon /api/ml/process-data requests).
• Import scripts (CLI, Node) → Spotify Web API & MongoDB (initial seed).
Architectural patterns and design principles
• Separation of Concerns:
• Presentation layer (React pages, components)
• Business logic (API routes)
• Data layer (MongoDB, PostgreSQL)
• ML layer (Flask service)
• Micro-service boundary: isolates compute-heavy ML workloads.
• Serverless functions: Next.js API routes auto-scale.
• Containerization: Docker Compose for environment consistency.
Technologies, frameworks, libraries
• Next.js (App Router), TypeScript, Tailwind CSS, HeroUI, Framer Motion
• Flask, scikit-learn, pandas
• MongoDB Atlas, Supabase (Postgres + Auth)
• Docker, Docker Compose
• spotify-preview-finder utility
• Component boundaries clearly drawn.
• Docker Compose orchestration indicated (web ⇄ ml-service).
• Environment variables/config layers (e.g., .env) can be noted but are optional.