mirror of
https://github.com/Acquarts/spotify-underground-analytics-pro.git
synced 2026-04-26 14:05:59 +03:00
Interactive web application for musical genre analysis and artist comparison using the Spotify API.
- Requisitos de negocio y funcionales detallados (11 RF) - Arquitectura técnica y stack tecnológico completo - Catálogo de 11 APIs con request/response - Análisis de seguridad y autenticación OAuth - 14 casos de prueba E2E con pasos detallados - Selectores UI (XPath) para automatización - Matriz de trazabilidad completa - Análisis de calidad con scoring 95/100 |
||
|---|---|---|
| .streamlit | ||
| backend | ||
| docs | ||
| .gitignore | ||
| app.py | ||
| docker-compose.yml | ||
| LICENSE | ||
| README.md | ||
| requirements.txt | ||
🎵 Spotify Analytics - Streamlit Frontend
Interactive web application for music genre analysis and artist comparison using the Spotify API.
🚀 Features
🎯 Genre Analysis
- Individual Analysis: Analyze specific genres with detailed metrics
- Multiple Comparison: Compare up to several genres simultaneously
- Trends: Analysis of mainstream vs underground genres
- Visualizations: Radar charts, bar graphs, and comparative tables
🥊 Artist Comparison
- Search and Analysis: Search artists and get complete analysis
- Multiple Comparison: Compare up to 5 artists simultaneously
- BreakBeat Battle: Compare iconic BreakBeat genre artists
- 1v1 Battle: Direct comparison between two artists
💎 Underground Gems
- Automatic underground genre detector
- Niche genre potential analysis
- Specialized metrics for alternative music
📋 Requirements
- Python 3.8+
- FastAPI backend running (see instructions below)
- Spotify API credentials
🔧 Installation
1. Clone the repository (if you haven't already)
cd spotify-analytics
2. Install dependencies
pip install -r requirements.txt
3. Configure environment variables
Create a .env file in the project root (if it doesn't exist):
SPOTIFY_CLIENT_ID=your_client_id
SPOTIFY_CLIENT_SECRET=your_client_secret
API_BASE_URL=http://localhost:8000
4. Start the backend (FastAPI)
In a separate terminal:
cd backend
uvicorn app.main:app --reload
The backend will be available at http://localhost:8000
5. Start the frontend (Streamlit)
In another terminal:
streamlit run app.py
The application will automatically open in your browser at http://localhost:8501
📱 Using the Application
Main Navigation
The application has 5 main sections accessible from the sidebar:
- 🏠 Home: General information and quick statistics
- 🎯 Genre Analysis: Individual analysis, comparisons, and trends
- 🥊 Artist Comparison: Search, analysis, and comparisons
- 💎 Underground Gems: Discover underground genres
- ⚔️ 1v1 Battle: Direct comparison between artists
Genre Analysis
Individual Analysis
- Enter the name of a genre (e.g., "breakbeat", "electronic", "pop")
- Click "Analyze Genre"
- View metrics such as popularity, energy, danceability
- Explore the radar chart with genre characteristics
Multiple Comparison
- Enter several genres separated by comma
- Compare metrics among all genres
- Visualize rankings of popularity, energy, and danceability
- Automatically detect underground genres
Trend Analysis
- Click "Analyze Trends"
- Compare mainstream vs underground genres
- Visualize differences in popularity and energy
Artist Comparison
Search and Analysis
- Enter an artist's name
- "Search": Basic information
- "Complete Analysis": Detailed metrics, top tracks, genres
Multiple Comparison
- Enter up to 5 artists separated by comma
- Compare popularity, followers, and audio metrics
- Visualize winners by category
- Read automatically generated insights
BreakBeat Battle
- Click "Start Battle"
- Compare The Prodigy, Pendulum, and The Chemical Brothers
- Visualize comparative radar chart
- Discover winners in each category
1v1 Battle
- Enter two artists in the corresponding fields
- Click "Start Battle"
- Side-by-side comparison with key metrics
- Visualize winners by category
Underground Gems
- Click "Search Underground Gems"
- Discover underground genres automatically
- Visualize metrics for each found genre
- Read the reasons why they're considered underground
🎨 Interface Features
- Responsive design: Adapts to different screen sizes
- Spotify theme: Colors inspired by Spotify brand (#1DB954)
- Interactive charts: Using Plotly for dynamic visualizations
- Organized tabs: Intuitive tab navigation
- Featured metrics: Cards with key information
- Loading spinner: Visual feedback during API requests
🛠️ Advanced Configuration
Change API URL
You can change the backend URL from the sidebar in "Configuration".
Verify API Status
Use the "🔍 Verify API" button in the sidebar to check:
- Database connection status
- Spotify API connection status
- Available features
🐛 Troubleshooting
Frontend doesn't connect to backend
- Verify that the backend is running at
http://localhost:8000 - Check the URL configured in the sidebar
- Check that there are no errors in the backend console
Can't find artists or genres
- Verify that Spotify API credentials are configured
- Check API status with the "Verify API" button
- Check that the database is connected
Visualization errors
- Make sure all dependencies are installed (
pip install -r requirements.txt) - Clear Streamlit cache:
Ctrl + RorCmd + R
📊 Available Metrics
Genres
- Popularity: Average popularity level (0-100)
- Energy: Perceived intensity and activity (0-1)
- Danceability: How suitable for dancing (0-1)
- Valence: Musical positivity (0-1)
- Acousticness: Presence of acoustic instruments (0-1)
- Instrumentalness: Amount of instrumental content (0-1)
Artists
- Popularity: Artist popularity (0-100)
- Followers: Total number of followers
- Top Tracks: Artist's best songs
- Genres: Genres associated with the artist
- Audio Features: Average metrics from their songs
🔗 API Endpoints Used
GET /: API informationGET /health: System statusGET /api/genres/analyze/{genre}: Genre analysisGET /api/genres/analyze/multiple: Genre comparisonGET /api/genres/underground: Underground genresGET /api/genres/compare: Compare two genresGET /api/genres/trending: Trend analysisGET /api/artists/search: Search artistGET /api/artists/analyze/{artist_name}: Artist analysisGET /api/artists/compare: Compare artistsGET /api/artists/vs: 1v1 battleGET /api/artists/compare/breakbeat: BreakBeat battle
🚀 Deployment
Using Docker Compose
If using Docker Compose (includes backend and frontend):
docker-compose up
Deploy on Streamlit Cloud
- Upload your code to GitHub
- Go to share.streamlit.io
- Connect your repository
- Configure environment variables
- Deploy
📝 Notes
- The backend must be running before using the frontend
- Spotify API credentials are necessary for full functionality
- PostgreSQL database must be configured and accessible
- For best results, use artist and genre names in English
👨💻 Built With
- Streamlit: Frontend framework
- Plotly: Interactive visualizations
- Pandas: Data manipulation
- Requests: API communication
- FastAPI: Backend API
- Spotipy: Spotify API client
📄 License
This project is open source and available under the MIT License.
🎵 Enjoy exploring music!
If you have questions or suggestions, feel free to open an issue in the repository.