Skip to content

jardo5/melodify-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Melodify

Melodify - Spring Boot Backend

Main Tools Used

Java Apache Maven MongoDB JWT Spotify ChatGPT AWS Docker GitHub Actions

Introduction

Melodify is a Spring Boot backend service designed to power a music-related application. It interacts with various external APIs, such as Spotify and Genius, to fetch, analyze, and manage song data. The backend provides several endpoints for managing user accounts, songs, artists, and other related resources. This README will guide you through the setup, usage, and functionalities provided by Melodify.

Table of Contents

Installation

To set up the Melodify backend, follow these steps:

1.Clone the repository:

    git clone https://github.com/jardo5/melodify-backend.git
    cd melodify-backend

2.Configure environment variables:

Add a .env file to the root of the project. With the following keys:
    GENIUS_API_KEY=
    SPOTIFY_CLIENT_ID=
    SPOTIFY_CLIENT_SECRET=
    SPOTIFY_REDIRECT_URI=
    LYRICS_API_URL= (lyricsovh API Key)
    SENTIMENT_API_KEY= (GPT API Key)
    SENTIMENT_PROMPT= (GPT Prompt return JSON format)
    MONGODB_URI=
    MONGODB_DATABASE_NAME==
    JWT_KEY=

3.Build the project using Maven:

mvn clean install

4.Run the application:

mvn spring-boot:run

Usage

Once the application is running, you can interact with the various endpoints to manage songs, users, and other resources. You can use tools like Postman or curl to test the endpoints.

Endpoints

Songs

-POST /songs/batch
Process and store a batch of songs.

-GET /songs/search
Search for songs based Title and Artist(s).

-GET /songs/top
Retrieve Top 50 USA songs based on Spotify playlist.

-GET /songs/{id}
Get detailed information about a specific song.

-GET /songs/fetch-persist-songs
Fetch and persist songs to DB. (DO NOT ABUSE THIS ENDPOINT. TESTING ONLY)

-GET /songs/lyrics
Retrieve lyrics for a specific song. (Testing purposes)

-GET /songs/sentiment
Analyze and return the sentiment of a song's lyrics. (Testing purposes)

Users

-GET /users/info
Retrieve information about the authenticated user.

-POST /users/login
Authenticate a user and return a JWT token.

-POST /users/signup
Register a new user.

-POST /users/{userId}/dislike
Dislike a song for a user.

-DELETE /users/{userId}/disliked/{songId}
Remove a song from the user's disliked list.

-POST /users/{userId}/like
Like a song for a user.

-DELETE /users/{userId}/liked/{songId}
Remove a song from the user's liked list.

-POST /users/{userId}/save
Save a song for a user.

-DELETE /users/{userId}/saved/{songId}
Remove a song from the user's saved list.

Admin

GET /admin/dashboard
Access the admin dashboard. (Not Implemented Yet)

Artists

-GET /artists/{artistId}
Retrieve information about a specific artist.

Authentication

-GET /auth/providers/spotify/callback
Handle Spotify OAuth callback.

-GET /auth/providers/spotify/login
Initiate Spotify OAuth login.

Recommendations

-GET /recommendations
Retrieve song recommendations for the user.

-POST /recommendations/refresh
Refresh and update song recommendations.

External API Integrations

-POSThttps://accounts.spotify.com/api/token
Obtain a token from Spotify for authentication.

-GEThttps://api.spotify.com/v1/playlists/{playlistId}/tracks
Fetch tracks from a Spotify playlist.

-POSThttps://api.openai.com/v1/chat/completions
Interact with OpenAI's API for various purposes.

-GEThttps://api.genius.com/artists/{artistId}
Retrieve artist information from Genius.

-GEThttps://api.genius.com/search?q={query}
Search for songs or artists on Genius.

-GEThttps://api.genius.com/songs/{songId}
Get details about a song from Genius.

Dependencies

Melodify relies on the following key dependencies:

Spring Boot Starters:
spring-boot-starter-data-mongodb
spring-boot-starter-oauth2-client
spring-boot-starter-web
spring-boot-starter-actuator
spring-boot-starter-test

Development Tools:
spring-boot-devtools (optional)

Security:
spring-security-test
jjwt-api
jjwt-impl
jjwt-jackson

Libraries:
org.json:json (for JSON processing)
org.mongodb:mongodb-driver-sync (for MongoDB interactions)
io.github.cdimascio:dotenv-java (for loading environment variables)

Testing:
de.flapdoodle.embed:de.flapdoodle.embed.mongo (embedded MongoDB for tests)

Utilities:
-org.projectlombok:lombok

Configuration

If needed, edit the application.properties:

spring.application.name=Melodify
spring.data.mongodb.uri=${MONGODB_URI}
spring.data.mongodb.database=${MONGODB_DATABASE_NAME}
rateLimiter.permitsPerSecond=10
server.port=80

Be Aware

API rate limits:
Be aware of the rate limits imposed by external APIs (Spotify, Genius, OpenAI, Lyricsovh)

License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published