Giter Site home page Giter Site logo

mariia-iureva / moodmelody_backend Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 92 KB

MoodMelody is a Flask-based web application that uses OpenAI's GPT-4o-mini model to provide personalized music recommendations. The application also integrates with the Spotify API to create playlists based on the recommendations.

Python 98.77% Mako 1.11% Procfile 0.12%

moodmelody_backend's Introduction

MoodMelody - AI-Powered Music Recommendation App

MoodMelody is a Flask-based web application that uses OpenAI's GPT-4o-mini model to provide personalized music recommendations. The application also integrates with the Spotify API to create playlists based on the recommendations.

Project Overview

MoodMelody allows users to receive song recommendations based on their mood or specific criteria. Users can then create a Spotify playlist with the recommended songs and listen to it immediately.

Features

  • AI-powered song recommendations using OpenAI's GPT-4o-mini model.
  • Integration with Spotify API to create and manage playlists.
  • Session management for tracking user interactions.

Prerequisites

  • Python 3.12 or higher
  • PostgreSQL
  • Git

Setup Instructions

Fork and Clone the Repository

  1. Fork the repository on GitHub.
  2. Clone the repository to your local machine.
git clone https://github.com/your-username/mood_melody_backend.git
cd mood_melody_backend

Create and Activate Virtual Environment

  1. Create a virtual environment:
python3 -m venv venv
  1. Activate the virtual environment:
  • On macOS and Linux:
source venv/bin/activate
  • On Windows:
venv\Scripts\activate

Install Dependencies

  1. Install the required packages:
pip install -r requirements.txt

Set Up the Database

  1. Install PostgreSQL (if not already installed).

  2. Create the development and test databases:

psql -U postgres - #To open the Postgres interactive terminal with a Postgres user named postgres
CREATE DATABASE mood_m;
CREATE DATABASE mood_m_test;
\q

Configure Environment Variables

  1. Create a .env file in the root directory with the following content:
SQLALCHEMY_DATABASE_URI=postgresql://postgres:password@localhost/mood_m
SQLALCHEMY_TEST_DATABASE_URI=postgresql://postgres:password@localhost/mood_m_test
OPENAI_API_KEY=your_openai_api_key
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
SPOTIFY_REDIRECT_URI=your_spotify_redirect_uri

Apply Database Migrations

  1. Initialize and apply migrations:
flask db init
flask db migrate -m "Initial migration"
flask db upgrade

Running the Application

  1. Run the Flask application:
flask run

The application should now be running at http://127.0.0.1:5000/ or http://localhost:5000/

Checking the Application with Postman

  1. Open Postman.

  2. Create a new POST request:

  • URL: http://127.0.0.1:5000/recommend or http://localhost:5000/recommend
  • Headers: Add a Session-Id header with a unique value (optional).
  • Body: Set to JSON and include a description field, for example:
{
  "description": "upbeat pop song with a happy vibe"
}
  1. Send the request and you should receive a JSON response with a song recommendation.

License

This project is licensed under the MIT License.

moodmelody_backend's People

Contributors

mariia-iureva avatar

Watchers

Kostas Georgiou avatar  avatar

Forkers

abecerrilsalas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.