mirror of
https://github.com/bnair123/MusicAnalyser.git
synced 2026-02-25 19:56:06 +00:00
- Created FastAPI backend structure. - Implemented Spotify Recently Played ingestion logic. - Set up SQLite database with SQLAlchemy models. - Added AI Service using Google Gemini. - Created helper scripts for auth and background worker. - Added Dockerfile and GitHub Actions workflow.
73 lines
1.5 KiB
Markdown
73 lines
1.5 KiB
Markdown
# Music Analyser
|
|
|
|
A personal analytics dashboard for your music listening habits, powered by Python, FastAPI, and Google Gemini AI.
|
|
|
|
## Project Structure
|
|
|
|
- `backend/`: FastAPI backend for data ingestion and API.
|
|
- `app/ingest.py`: Background worker that polls Spotify.
|
|
- `app/services/`: Logic for Spotify and Gemini APIs.
|
|
- `app/models.py`: Database schema (Tracks, PlayHistory).
|
|
- `frontend/`: (Coming Soon) React/Vite frontend.
|
|
|
|
## Getting Started
|
|
|
|
### Prerequisites
|
|
|
|
- Docker & Docker Compose (optional, for containerization)
|
|
- Python 3.11+ (for local dev)
|
|
- A Spotify Developer App (Client ID & Secret)
|
|
- A Google Gemini API Key
|
|
|
|
### 1. Setup Environment Variables
|
|
|
|
Create a `.env` file in the `backend/` directory:
|
|
|
|
```bash
|
|
SPOTIFY_CLIENT_ID="your_client_id"
|
|
SPOTIFY_CLIENT_SECRET="your_client_secret"
|
|
SPOTIFY_REFRESH_TOKEN="your_refresh_token"
|
|
GEMINI_API_KEY="your_gemini_key"
|
|
```
|
|
|
|
To get the `SPOTIFY_REFRESH_TOKEN`, run the helper script:
|
|
|
|
```bash
|
|
python backend/scripts/get_refresh_token.py
|
|
```
|
|
|
|
### 2. Run Locally
|
|
|
|
Install dependencies:
|
|
|
|
```bash
|
|
cd backend
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
Run the server:
|
|
|
|
```bash
|
|
uvicorn app.main:app --reload
|
|
```
|
|
|
|
The API will be available at `http://localhost:8000`.
|
|
|
|
### 3. Run Ingestion (Manually)
|
|
|
|
You can trigger the ingestion process via the API:
|
|
|
|
```bash
|
|
curl -X POST http://localhost:8000/trigger-ingest
|
|
```
|
|
|
|
Or run the ingestion logic directly via python shell (see `app/ingest.py`).
|
|
|
|
### 4. Docker Build
|
|
|
|
To build the image locally:
|
|
|
|
```bash
|
|
docker build -t music-analyser-backend ./backend
|
|
```
|