Skip to content

Victorthedev/Groovz-Backend-JS

Repository files navigation

Groovz - Spotify Playlist Generator

Groovz is a web application that allows users to create custom Spotify playlists based on a seed track. It uses the Spotify Web API to authenticate users, fetch their playlists, and generate new playlists with recommended tracks.

Table of Contents

Features

  • Spotify OAuth 2.0 authentication
  • Fetch user's Spotify playlists
  • Create custom playlists based on a seed track
  • Error handling and logging

Prerequisites

Before you begin, ensure you have met the following requirements:

  • Node.js (v14 or later)
  • npm (v6 or later)
  • A Spotify Developer account and registered application

Installation

  1. Clone the repository:
  1. Install the dependencies:
  • npm install

Configuration

  1. Create a .env file in the root directory of the project.

  2. Add the following environment variables to the .env file:

Replace your_spotify_client_id and your_spotify_client_secret with your actual Spotify application credentials.

Usage

To start the server, run:

  • node app

The server will start running on http://localhost:4000 (or the port specified in your .env file).

API Endpoints

Authentication

  • GET /auth/login: Initiates the Spotify OAuth 2.0 login process
  • GET /auth/callback: Handles the Spotify OAuth 2.0 callback

Playlists

  • GET /playlist: Fetches the user's Spotify playlists

    • Query parameters:
      • offset (optional): The index of the first playlist to return (default: 0)
      • limit (optional): The maximum number of playlists to return (default: 20)
  • POST /playlist/create: Creates a new playlist based on a seed track

    • Request body:
      {
        "seedTrackId": "spotify:track:1234567890abcdef"
      }
    • Query parameters:
      • userId: The Spotify user ID for whom to create the playlist

Project Structure

. ├── controllers │ ├── authController.js │ └── playlistController.js ├── routes │ ├── authRoutes.js │ └── playlistRoutes.js ├── services │ └── spotifyService.js ├── utils │ └── spotifyApi.js ├── .env ├── .gitignore ├── package.json ├── README.md └── server.js

  • controllers/: Contains the logic for handling requests and responses
  • routes/: Defines the API routes and maps them to controller functions
  • services/: Implements the business logic and interacts with external APIs
  • utils/: Houses utility functions and configurations
  • server.js: The main entry point of the application

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published