How piyushk2477/music-match works
Project type and purpose
• This is a full-stack web application named “music-match.” The front end is built with React + Vite, and the back end is a Node.js/Express service. It integrates with Spotify’s APIs for authentication and data, persists user and music data in a relational database, and offers features like compare, discover, ranking, and profile pages.
File structure
• Top-level:
– index.html, public/ → static entry for Vite/React
– src/ → React app (components, pages, assets)
– backend/ → Node.js service (server.js, route handlers, DB scripts, migrations)
– Configuration: package.json/lock, vite.config.js, eslint.config.js, .env
• In backend/:
– server.js → Express app bootstrap
– auth.js & spotify-auth.js → OAuth flow with Spotify
– db.js & setup-database.js → Database connection and schema setup
– *.js scripts → migrations and data-fix scripts for tables/columns
– database.sql → raw schema or seed data
• In src/:
– main.jsx → React DOM entry
– App.jsx → top-level router/logic
– pages/ → page components (Home, Login, AuthCallback, Discover, Compare, Ranking, Profile)
– assets/, CSS → styling and images
README
a. Main Components
• Frontend: React + Vite SPA
• Backend: Node.js + Express API server
• Database: Relational (PostgreSQL/MySQL)
• External Service: Spotify Web API (OAuth + data endpoints)
• Optional: Static file host/CDN for public assets
b. Relationships & Interactions
1. User ↔ React SPA (via browser)
2. SPA ↔ Express server over HTTPS (REST or GraphQL endpoints)
3. Server ↔ Database (SQL queries through db.js)
4. Server ↔ Spotify API for OAuth and music data
5. Migration scripts ↔ Database (one-time or CI/CD migrations)
c. Architectural Patterns & Principles
– Clear separation of concerns: presentation (frontend) vs. business logic (backend) vs. persistence (DB)
– Flow-based data retrieval: UI triggers API calls, server mediates between DB and Spotify
– Modular code: separate route handlers, auth modules, migration scripts
– Environment-based config: .env in root and .env.example in backend
d. Key Technologies & Libraries
• Frontend: React, React Router, Vite, ESLint
• Backend: Node.js, Express, dotenv, any SQL client (e.g., node-pg)
• Auth: OAuth2 with Spotify (via auth.js/spotify-auth.js)
• Database: SQL (scripts in database.sql, setup-database.js, migrations)