mirror of
https://github.com/bnair123/MusicAnalyser.git
synced 2026-02-25 11:46:07 +00:00
f4432154b61abdd15ab29add25242740a1821923
- Refactor Database: Add `Artist` model, M2M relationship, and `AnalysisSnapshot` model. - Backend Services: Implement `StatsService` for computable metrics and `NarrativeService` for Gemini LLM integration. - Fix Ingestion: Correctly handle multiple artists per track and backfill existing data. - Testing: Add unit tests for statistics logic and live verification scripts. - Documentation: Add `PHASE_4_FRONTEND_GUIDE.md`.
Music Analyser
A personal analytics dashboard for your music listening habits, powered by Python, FastAPI, React, and Google Gemini AI.
Features
- Continuous Ingestion: Polls Spotify every 60 seconds to record your listening history.
- Data Enrichment: Automatically fetches Genres (via Spotify) and Audio Features (Energy, BPM, Mood via ReccoBeats).
- Dashboard: A responsive UI (Ant Design) to view your history, stats, and "Vibes".
- AI Ready: Database schema and environment prepared for Gemini AI integration.
Hosting Guide
You can run this application using Docker Compose. You have two options: using the pre-built image from GitHub Container Registry or building from source.
1. Prerequisites
- Docker & Docker Compose installed.
- Spotify Developer Credentials (Client ID & Secret).
- Spotify Refresh Token (Run
backend/scripts/get_refresh_token.pylocally to generate this). - Google Gemini API Key.
2. Configuration (.env)
Create a .env file in the root directory (same level as docker-compose.yml). This file is used by Docker Compose to populate environment variables.
SPOTIFY_CLIENT_ID="your_client_id"
SPOTIFY_CLIENT_SECRET="your_client_secret"
SPOTIFY_REFRESH_TOKEN="your_refresh_token"
GEMINI_API_KEY="your_gemini_key"
3. Run with Docker Compose
Option A: Build from Source (Recommended for Dev/Modifications)
Use this if you want to modify the code or ensure you are running the exact local version.
- Clone the repository.
- Ensure your
.envfile is set up. - Run:
docker-compose up -d --build
Option B: Use Pre-built Image
Use this if you just want to run the app without building locally.
- Open
docker-compose.yml. - Ensure the
backendservice uses the image:ghcr.io/bnair123/musicanalyser:latest.- Note: If you want to force usage of the image and ignore local build context, you can comment out
build: context: ./backendin the yaml, though Compose usually prefers build context if present.
- Note: If you want to force usage of the image and ignore local build context, you can comment out
- Ensure your
.envfile is set up. - Run:
docker pull ghcr.io/bnair123/musicanalyser:latest docker-compose up -d
4. Access the Dashboard
Open your browser to:
http://localhost:8991
5. Data Persistence
- Database: Stored in a named volume or host path mapped to
/app/music.db. - Migrations: The backend uses Alembic. Schema changes are applied automatically on startup.
Local Development (Non-Docker)
-
Backend:
cd backend pip install -r requirements.txt python run_worker.py # Starts ingestion uvicorn app.main:app --reload # Starts API -
Frontend:
cd frontend npm install npm run devAccess at
http://localhost:5173.
Description
Languages
Python
66.9%
JavaScript
30.8%
CSS
1%
Dockerfile
0.4%
HTML
0.4%
Other
0.5%