This is the backend API server for the Spotify Dashboard project. It is built using FastAPI and handles data upload, processing, and serving aggregated metrics for the frontend dashboard.
SPOTIFY_DASHBOARD_BACKEND
├── app
│ ├── __init__.py
│ ├── main.py # FastAPI app entry point
│ ├── routes
│ │ ├── __init__.py
│ │ ├── metrics.py # API endpoints for metrics
│ │ └── upload.py # API endpoints for uploading data
│ └── services
│ ├── __init__.py
│ └── preprocessing.py # Data loading and preprocessing logic
├── requirements.txt # Python dependencies
├── README.md # This file
└── test_spotify_frontend.html # (Optional) simple frontend test file
- Python 3.13 installed
- Recommended: Create and activate a virtual environment to isolate dependencies
- Clone the repository:
git clone
cd SPOTIFY_DASHBOARD_BACKEND- Create and activate virtual environment (Unix/macOS):
python3 -m venv .venv
source .venv/bin/activate(Windows PowerShell)
python -m venv .venv
.\.venv\Scripts\Activate.ps1- Install dependencies:
pip install -r requirements.txtRun the FastAPI server with uvicorn (already included in requirements):
uvicorn app.main:app --reload- The API will be available at http://localhost:8000
- The
--reloadflag restarts server upon code changes (development convenience)
- POST
/upload/: Upload Spotify JSON files for processing. Accepts multiple files + date range. - Stores preprocessed data in memory with unique dataset IDs.
- GET
/metrics/{dataset_id}: Fetch aggregated metrics for dataset within optional date range. - Provides JSON of listening behavior, time-based stats, platform breakdown, session info, and more.
- Data preprocessing is in
app/services/preprocessing.py - API routes are defined in
app/routes/upload.pyandapp/routes/metrics.py - In-memory dataset storage (simple dict) for prototyping; consider DB for production.
- Test frontend is available as
test_spotify_frontend.htmlfor basic checks.
- Add persistent storage support (e.g., PostgreSQL, Redis)
- Implement authentication for upload endpoints
- Expand metrics with additional Spotify data fields or visualizations
MIT License
If you have any questions or want to contribute, feel free to open issues or pull requests!