mirror of
https://github.com/bnair123/MusicAnalyser.git
synced 2026-02-25 11:46:07 +00:00
feat: Initial backend setup for Music Analyser
- 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.
This commit is contained in:
39
backend/app/models.py
Normal file
39
backend/app/models.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from sqlalchemy import Column, Integer, String, DateTime, JSON, ForeignKey, Boolean
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
from .database import Base
|
||||
|
||||
class Track(Base):
|
||||
__tablename__ = "tracks"
|
||||
|
||||
id = Column(String, primary_key=True, index=True) # Spotify ID
|
||||
name = Column(String)
|
||||
artist = Column(String)
|
||||
album = Column(String)
|
||||
duration_ms = Column(Integer)
|
||||
popularity = Column(Integer, nullable=True)
|
||||
|
||||
# Store raw full JSON response for future-proofing analysis
|
||||
raw_data = Column(JSON, nullable=True)
|
||||
|
||||
# AI Analysis fields
|
||||
lyrics_summary = Column(String, nullable=True)
|
||||
genre_tags = Column(String, nullable=True) # JSON list stored as string or just raw JSON
|
||||
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
plays = relationship("PlayHistory", back_populates="track")
|
||||
|
||||
|
||||
class PlayHistory(Base):
|
||||
__tablename__ = "play_history"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
track_id = Column(String, ForeignKey("tracks.id"))
|
||||
played_at = Column(DateTime, index=True) # The timestamp from Spotify
|
||||
|
||||
# Context (album, playlist, etc.)
|
||||
context_uri = Column(String, nullable=True)
|
||||
|
||||
track = relationship("Track", back_populates="plays")
|
||||
Reference in New Issue
Block a user