{"id":23270149,"url":"https://github.com/sushank-ghimire/spotifyclone-backend","last_synced_at":"2026-05-08T05:39:28.808Z","repository":{"id":262592818,"uuid":"886675161","full_name":"Sushank-ghimire/spotifyClone-backend","owner":"Sushank-ghimire","description":"A backend for a Spotify Clone built with Express.js, Node.js, and MongoDB, using Clerk/express for user authentication. Features include secure user registration, login, and session management. Users can upload audio files, create and manage playlists, and stream music. ","archived":false,"fork":false,"pushed_at":"2024-11-20T15:34:02.000Z","size":98,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-20T15:37:28.728Z","etag":null,"topics":["backend","clerkauth","dababase","express","mern","mongodb"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sushank-ghimire.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-11T12:03:18.000Z","updated_at":"2024-11-20T15:34:06.000Z","dependencies_parsed_at":"2024-11-13T09:29:03.323Z","dependency_job_id":null,"html_url":"https://github.com/Sushank-ghimire/spotifyClone-backend","commit_stats":null,"previous_names":["sushank-ghimire/spotifyclone-backend"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sushank-ghimire%2FspotifyClone-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sushank-ghimire%2FspotifyClone-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sushank-ghimire%2FspotifyClone-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sushank-ghimire%2FspotifyClone-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sushank-ghimire","download_url":"https://codeload.github.com/Sushank-ghimire/spotifyClone-backend/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230487783,"owners_count":18233860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","clerkauth","dababase","express","mern","mongodb"],"created_at":"2024-12-19T18:47:56.919Z","updated_at":"2026-05-08T05:39:28.796Z","avatar_url":"https://github.com/Sushank-ghimire.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🎵 SpotifyClone Backend\n\nThis is the backend service for the **SpotifyClone** application. It handles user authentication, database management, and real-time communication to support a rich music streaming experience. Built using modern technologies such as **Node.js**, **Express.js**, **Mongoose**, **Socket.IO**, and **Clerk**, this backend is designed to provide a scalable and robust foundation for the SpotifyClone frontend.\n\n---\n\n## 📑 Table of Contents\n\n- [Tech Stack](#tech-stack)\n- [Features](#features)\n- [Installation](#installation)\n- [Environment Variables](#environment-variables)\n- [API Endpoints](#api-endpoints)\n  - [Authentication](#authentication)\n  - [User Routes](#user-routes)\n  - [Admin Routes](#admin-routes)\n  - [Stats Routes](#stats-routes)\n- [Socket.IO Events](#socketio-events)\n- [Project Structure](#project-structure)\n- [Contributing](#contributing)\n- [License](#license)\n\n---\n\n## 🛠️ Tech Stack\n\n- **Node.js**: JavaScript runtime environment for server-side logic.\n- **Express.js**: Web framework for building RESTful APIs.\n- **Mongoose**: MongoDB object modeling for Node.js.\n- **Socket.IO**: Real-time, bidirectional communication between the server and clients.\n- **Clerk/Express**: Authentication and session management.\n\n---\n\n## ✨ Features\n\n- **User Authentication**: Sign up, login, and manage sessions using Clerk.\n- **Music Streaming**: Real-time music playback and controls.\n- **Album \u0026 Song Management**: Create, update, and manage songs and albums.\n- **Search**: Find songs, artists, and albums.\n- **Real-time Messaging**: Chat with other users using Socket.IO.\n- **Scalable Architecture**: Modular and maintainable code structure.\n\n---\n\n## 🚀 Installation\n\n1. **Clone the Repository**:\n\n   ```bash\n   git clone https://github.com/Sushank-ghimire/SpotifyClone-backend.git\n   cd SpotifyClone-backend\n   ```\n\n2. **Install Dependencies**:\n\n   ```bash\n   npm install\n   ```\n\n3. **Set Up Environment Variables**:  \n   Create a `.env` file in the root directory and add the following variables:\n\n   ```env\n   PORT=3000\n   MONGO_URI=\"mongodb://localhost:27017/Spotify\"\n   NODE_ENV=\"development\"\n   ADMIN_EMAIL=\n   ADMIN_PASSWORD=\n   ACCESS_TOKEN_SECRET=\n   JWT_SECRET_KEY=\n   REFRESH_TOKEN_SECRET=\n   CLOUDINARY_CLOUD_NAME=\n   CLOUDINARY_URL=\n   CLOUDINARY_API_KEY=\n   CLOUDINARY_API_SECRET=\n   CLERK_PUBLISHABLE_KEY=\n   CLERK_SECRET_KEY=\n   ```\n\n4. **Run the Server**:\n\n   ```bash\n   npm run start\n   ```\n\n   The server will start on `http://localhost:3000`.\n\n---\n\n## 📡 API Endpoints\n\n### **Authentication**\n\n- **POST** `/api/v1/users/register`: Register a new user.\n\n---\n\n### **User Routes**\n\n#### **Songs**\n- **GET** `/api/v1/songs`: Fetch all available songs.\n- **GET** `/api/v1/songs/:id`: Get details of a specific song by ID.\n- **GET** `/api/v1/songs/trending`: Get the trending songs.\n- **GET** `/api/v1/songs/made-for-you`: Get the songs of your choice and you liked.\n- **GET** `/api/v1/songs/featured`: Get the featured songs.\n\n#### **Albums**\n- **GET** `/api/v1/album`: Fetch all available albums.\n- **GET** `/api/v1/album/:id`: Get details of a specific album by ID.\n\n---\n\n## 🔐 Admin Routes (`/api/v1/admin`)\n\nThese routes are restricted to admin users and require authentication.\n\n### **Admin Authentication**\n- **GET** `/api/v1/admin/check`\n  - **Description**: Verifies if the logged-in user has admin privileges.\n  - **Response**:\n    - `200 OK`: `{ isAdmin: true }`\n    - `403 Forbidden`: `{ error: \"Not authorized\" }`\n\n### **Admin Songs Management**\n- **POST** `/api/v1/admin/songs/create`\n  - **Description**: Adds a new song to the database.\n  - **Body Parameters**:\n    ```json\n    {\n      \"title\": \"Song Title\",\n      \"artist\": \"Artist Name\",\n      \"album\": \"Album ID\",\n      \"duration\": \"3:45\",\n      \"genre\": \"Pop\"\n    }\n    ```\n  - **Response**:\n    - `201 Created`: `{ message: \"Song created successfully\" }`\n    - `400 Bad Request`: `{ error: \"Invalid data\" }`\n\n- **DELETE** `/api/v1/admin/songs/:songId`\n  - **Description**: Deletes a song by its ID.\n  - **Response**:\n    - `200 OK`: `{ message: \"Song deleted successfully\" }`\n    - `404 Not Found`: `{ error: \"Song not found\" }`\n\n- **GET** `/api/v1/admin/allsongs`\n  - **Description**: Retrieves a list of all songs.\n  - **Response**: Array of song objects.\n\n### **Admin Album Management**\n- **POST** `/api/v1/admin/album/create`\n  - **Description**: Creates a new album.\n  - **Body Parameters**:\n    ```json\n    {\n      \"name\": \"Album Name\",\n      \"artist\": \"Artist Name\",\n      \"releaseDate\": \"2024-01-01\",\n      \"coverImage\": \"URL of cover image\"\n    }\n    ```\n  - **Response**:\n    - `201 Created`: `{ message: \"Album created successfully\" }`\n\n- **DELETE** `/api/v1/admin/album/:albumId`\n  - **Description**: Deletes an album by its ID.\n  - **Response**:\n    - `200 OK`: `{ message: \"Album deleted successfully\" }`\n    - `404 Not Found`: `{ error: \"Album not found\" }`\n\n---\n\n## 📊 Stats Routes (`/api/v1/stats`)\n\nThe stats routes are only accessible by admins.\n\n- **GET** `/api/v1/stats/totalStats`\n  - **Description**: Retrieves overall statistics about songs, albums, and users.\n  - **Response**:\n    - `200 OK`: `{ totalUsers, totalSongs, totalAlbums }`\n    - `403 Forbidden`: `{ error: \"Not authorized\" }`\n\n---\n\n## 🔌 Socket.IO Events\n\n| Event            | Description                          |\n| ---------------- | ------------------------------------ |\n| `connection`     | Establish a connection with a client |\n| `joinRoom`       | Join a specific chat room            |\n| `sendMessage`    | Send a message to the room           |\n| `receiveMessage` | Listen for incoming messages         |\n| `disconnect`     | Handle client disconnection          |\n\n---\n\n## 🤝 Contributing\n\nContributions are welcome! Feel free to open issues or submit pull requests to improve the project.\n\n1. Fork the repository.\n2. Create a new branch: `git checkout -b feature-branch`.\n3. Make your changes and commit them.\n4. Push to your branch: `git push origin feature-branch`.\n5. Open a pull request.\n\n---\n\n## 📝 License\n\nThis project is licensed under the **MIT License**.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsushank-ghimire%2Fspotifyclone-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsushank-ghimire%2Fspotifyclone-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsushank-ghimire%2Fspotifyclone-backend/lists"}