A machine learning-powered music recommendation system built with FastAPI and Streamlit, utilizing the Spotify API for music data and recommendations.
This project demonstrates a complete music recommendation system that leverages the Spotify Web API and machine learning techniques to provide personalized music recommendations to users.
By analyzing audio features of tracks and user preferences, the system can suggest new music that aligns with the user's taste while introducing them to tracks they might not discover otherwise.
Demo of the Spotify Recommendation System in action
FastAPI: Modern, high-performance web framework for building APIs with Python
SQLAlchemy: SQL toolkit and Object-Relational Mapping (ORM) library
Pydantic: Data validation and settings management using Python type annotations
Streamlit: Open-source app framework for Machine Learning and Data Science
Pandas/NumPy: Data manipulation and analysis tools
Plotly: Interactive data visualization library
SQLite: Lightweight disk-based database
JWT: JSON Web Tokens for secure authentication
Spotify Web API: Access to Spotify's music catalog and user data
Get the code from GitHub and navigate to the project directory.
git clone https://github.com/yourusername/spotify-recommendation-system.git
cd spotify-recommendation-system
Create and activate a virtual environment for the project.
conda create -n env python=3.8+
conda activate env
Install all required packages using pip.
pip install -r requirements.txt
Create a .env file in the root directory with your Spotify API credentials.
SPOTIFY_CLIENT_ID=your_client_id_here
SPOTIFY_CLIENT_SECRET=your_client_secret_here
DATABASE_URL=sqlite:///./spotify_recommender.db
SECRET_KEY=your_secret_key_here
Start the FastAPI backend server with the following command:
uvicorn app.main:app --reload
Access the API documentation at http://localhost:8000/docs
In a new terminal, start the Streamlit frontend:
streamlit run streamlit_app.py
Access the web interface at http://localhost:8501
Register a new account using the registration form. Provide a username, email, and secure password.
Log in with your credentials to access the recommendation system features.
You can get track IDs from Spotify by right-clicking a song and selecting "Share > Copy Spotify URI". The track ID is the string after "spotify:track:".
Enter a Spotify track ID to get personalized recommendations based on that seed track.
View the recommended tracks and provide feedback to improve future recommendations.