An intelligent music recommendation system combining Spotify's API with machine learning insights, featuring a modern Streamlit interface for seamless user interaction.
- Artist-Centric Search: Intuitive input for artist discovery
- Rich Media Display:
- High-resolution album art
- Track metadata visualization
- Responsive grid layout
- Dynamic Theme System:
- Dark/Light mode support
- Custom CSS styling
- Real-Time API Connectivity:
- Track preview streaming
- Album art retrieval
- Artist metadata parsing
- Search Optimization:
- Fuzzy name matching
- Error-tolerant queries
- Rate limiting handling
- OAuth 2.0 authentication flow
- Encrypted secret management
- GDPR-compliant data handling
- Rate limit monitoring
The pre-trained collaborative filtering model (cf_model.keras) is available for download via the latest release.
- File:
cf_model.keras - Format: Keras SavedModel
- Trained on: 170,089 songs from the Spotify Million Playlist Dataset
- Purpose: Recommends a track based on co-occurrence patterns with the userβs input song
- Python 3.8+
- Spotify Developer Account
- GitHub Account (for deployment)
- Basic terminal/command line knowledge
https://github.com/rajathpatilkulkarni-06/music-recommendation-api.git
cd music-recommendation-apipython -m venv venv
source venv/bin/activate # Linux/MacOS
venv\Scripts\activate # Windowspip install -r requirements.txt- Navigate to Spotify Developer Dashboard
- Create new application
- Note
Client IDandClient Secret - Set redirect URI to
http://localhost:8501
Create .streamlit/secrets.toml:
[spotify]
client_id = "your_client_id_here"
client_secret = "your_client_secret_here"
redirect_uri = "http://localhost:8501"
[api]
base_url = "http://127.0.0.1:8000"
endpoint = "/recommend/"export SPOTIPY_CACHE_PATH="./.spotipy_cache"
export DEBUG_MODE="false" # Set to "true" for developmentstreamlit run app.py# Run with debug mode
streamlit run app.py --server.enableCORS=false --server.enableXsrfProtection=false
# Custom port configuration
streamlit run app.py --server.port 8080- Connect GitHub repository
- Configure secrets through web interface
- Set resource allocation
- Deploy production version
# Procfile
web: streamlit run app.py --server.port $PORT- Use Web Service deployment
- Set environment variables
- Specify Python 3.8+ runtime
graph TD
A[User Interface] --> B(Streamlit Frontend)
B --> C{API Gateway}
C --> D[Recommendation Engine]
D --> E[Spotify API]
E --> F[(Cache Layer)]
F --> D
D --> C
C --> B
- Machine Learning: Collaborative filtering models
- API Layer: FastAPI backend service
- Caching: Redis for Spotify metadata
- Monitoring: Prometheus + Grafana dashboard
- Create feature branch from
develop - Implement changes with tests
- Submit pull request with:
- Updated documentation
- Unit test coverage
- Performance metrics
- Google-style docstrings
- Type hinting enforcement
- Black code formatting
- PEP8 compliance
| Error Message | Possible Cause | Solution |
|---|---|---|
| 401 Unauthorized | Invalid Spotify credentials | Regenerate client secret |
| 429 Too Many Requests | API rate limit exceeded | Implement exponential backoff |
| 503 Service Unavailable | Recommendation API down | Check backend service status |
- Phase 1: Core recommendation engine
- Phase 2: User preference profiling
- Phase 3: Social sharing features
- Phase 4: AI-powered playlist generation
Distributed under MIT License. See MIT License for full text.
- Spotify API team
- Streamlit community
- OpenAI for NLP models
Disclaimer: This project is not affiliated with or endorsed by Spotify AB. All trademarks remain property of their respective owners.