A full-stack Spotify Clone application built with the MERN stack (MongoDB, Express, React, Node.js). This project serves as a learning ground for modern web technologies including React 19, Express 5, and real-time data handling.
Project Status: This project is complete as of January 25, 2026. All core requirements have been met.
- Full-Stack Architecture: Monorepo structure with a React frontend and a Node.js/Express backend.
- Secure Authentication: User management via Clerk, including protected routes, OAuth 2.0 (Google), and JWT-based API authorization.
- Real-time Communication:
- Live Chat: Real-time messaging between users using Socket.io.
- Friends Activity: A sidebar displaying users' online status and their current listening activity.
- Complete Music Playback System:
- Global playback state management with Zustand (
usePlayerStore). - Features include play/pause, next/previous track, volume control, a seekable progress bar, and track autoplay.
- Synchronized
AudioPlayercomponent for robust HTML5 audio playback.
- Global playback state management with Zustand (
- Content Management:
- Admin Dashboard: A dedicated UI for managing songs and albums, viewing platform statistics, and performing content uploads.
- Cloudinary Integration: Robust media hosting for song audio and album artwork.
- Automated Metadata Extraction: Automatically extracts metadata (title, artist, album, year, genre) and embedded cover art from audio files during upload.
- Dynamic Frontend:
- Responsive Layout: A Spotify-like interface built with
react-resizable-panels. - Component-Based UI: Built with Radix UI primitives and styled with Tailwind CSS.
- Data-Driven Pages: Pages for viewing albums, discovering featured content, and interacting with the player.
- Smooth UX: Includes loading skeletons for asynchronous data fetching states.
- Responsive Layout: A Spotify-like interface built with
- Robust Backend:
- RESTful API: Comprehensive API for handling songs, albums, users, chat, playlists, and admin functions.
- Database Seeding: Scripts to populate the database with initial song and album data.
- Centralized Error Handling: Production-ready error middleware for consistent API responses.
POST /api/auth/callback- Handle Clerk OAuth callback and sync user to the database.
GET /api/songs- Get all songsGET /api/songs/featured- Get featured songs (6 random songs)GET /api/songs/made-for-you- Get personalized songs (4 random songs)GET /api/songs/trending- Get trending songs (4 random songs)GET /api/songs/:id- Get a song by its ID.
GET /api/albums- Get all albumsGET /api/albums/:AlbumId- Get album by ID with songs
POST /api/admin/songs- Create new song (Admin only)DELETE /api/admin/songs/:id- Delete song (Admin only)POST /api/admin/albums- Create new album (Admin only)DELETE /api/admin/albums/:id- Delete album (Admin only)GET /api/admin/check- Check admin status
GET /api/users- Get all users except current user (Authenticated)GET /api/users/messages/:userId- Get chat messages between two users (Authenticated).
POST /api/users/playlist- Create a new playlistGET /api/users/playlists- Get all playlistsGET /api/users/playlists/:PlaylistId- Get playlist by ID
GET /api/stats- Get platform statistics including songs, users, albums, and unique artists count (Admin only)
- User clicks "Continue with Google" (
SignInOAuthButton). - Clerk redirects to Google OAuth.
- OAuth callback redirects to
/sso-callback. - Final redirect to
/auth-callbackwith Clerk token. AuthCallBackPagesyncs the user with the backend via aPOSTrequest to/api/auth/callback.- The
authProvidercomponent wraps the application and sets the authorization header for all axios requests using the token from Clerk. - API requests include
Authorization: Bearer <token>header.
/-HomePagewrapped inMainLayout./chat-ChatPagefor real-time messaging, wrapped inMainLayout./albums/:albumId-AlbumPagewrapped inMainLayout./sso-callback- Clerk OAuth redirect handler./auth-callback-AuthCallBackPagefor token extraction and user synchronization./admin- Admin dashboard for content management.
- MainLayout: The core application wrapper providing the resizable 3-pane layout (Sidebar, Content, Friends).
- FriendsActivity: Displays a list of users/friends and their real-time listening status.
- ChatPage Components: Enables chat in realtime using Socket.io
- TopBar: Navigation bar with admin link (currently hardcoded to not show), sign in/out buttons.
- AudioPlayer: Handles synchronized HTML5 audio playback and state updates.
- SignInOAuthButton: Google OAuth integration with Clerk.
- authProvider: A component that wraps the application and sets the authorization header for axios requests.
- Axios Instance: Pre-configured HTTP client.
- UI System: Built with Radix UI primitives and Tailwind CSS (
Button,Card,Resizable,ScrollArea).
spotify-clone/
├── backend/
│ └── src/
│ ├── controllers/
│ ├── lib/
│ ├── middleware/
│ ├── models/
│ ├── routes/
│ └── seeds/
└── frontend/
├── public/
└── src/
├── components/
├── layout/
├── lib/
├── pages/
├── providers/
├── stores/
└── types/
- Node.js (v18+)
- MongoDB Instance
- Clerk Account
- Cloudinary Account (for media hosting)
-
Backend
cd backend npm install cp .env.sample .env # Edit .env with your credentials npm run dev
Backend Environment Variables:
PORT- Server port (default: 8080)MONGODB_URI- MongoDB connection stringADMIN_EMAIL- Email address for admin accessNODE_ENV- Environment (development/production)CLOUDINARY_API_KEY- Cloudinary API keyCLOUDINARY_API_SECRET- Cloudinary API secretCLOUDINARY_CLOUD_NAME- Cloudinary cloud nameCLERK_PUBLISHABLE_KEY- Clerk frontend keyCLERK_SECRET_KEY- Clerk backend secret key
-
Frontend
cd frontend npm install cp .env.sample .env # Edit .env with your Clerk key npm run dev
Frontend Environment Variables:
VITE_CLERK_PUBLISHABLE_KEY- Clerk frontend publishable key
- Date: January 25, 2026
- Status: Final project completion. All core requirements met.
This project was inspired by the comprehensive tutorial: Advanced Spotify Clone: Build & Deploy a MERN Stack Spotify Application with React.js
MIT