feat: implement AI-curated playlist service and dashboard integration

- Added hierarchical AGENTS.md knowledge base
- Implemented PlaylistService with 6h themed and 24h devotion mix logic
- Integrated AI theme generation for 6h playlists via Gemini/OpenAI
- Added /playlists/refresh and metadata endpoints to API
- Updated background worker with scheduled playlist curation
- Created frontend PlaylistsSection, Tooltip components and integrated into Dashboard
- Added Alembic migration for playlist tracking columns
- Fixed Docker healthcheck with curl installation
This commit is contained in:
bnair123
2025-12-30 09:45:19 +04:00
parent fa28b98c1a
commit 93e7c13f3d
18 changed files with 1037 additions and 295 deletions

56
TODO.md
View File

@@ -1,37 +1,21 @@
# Future Roadmap & TODOs
🎵 Playlist Service Feature - Complete Task List
What's Been Done ✅
| # | Task | Status | Notes |
|---|-------|--------|-------|
| 1 | Database | ✅ Completed | Added playlist_theme, playlist_theme_reasoning, six_hour_playlist_id, daily_playlist_id columns to AnalysisSnapshot model |
| 2 | AI Service | ✅ Completed | Added generate_playlist_theme(), _build_theme_prompt(), _call_openai_for_theme(), updated _build_prompt() to remove HHI/Gini/part_of_day |
| 3 | PlaylistService | ✅ Completed | Implemented full curation logic with ensure_playlists_exist(), curate_six_hour_playlist(), curate_daily_playlist(), _get_top_all_time_tracks() |
| 4 | Migration | ✅ Completed | Created 5ed73db9bab9_add_playlist_columns.py and applied to DB |
| 5 | API Endpoints | ✅ Completed | Added /playlists/refresh/* and /playlists GET endpoints in main.py |
| 6 | Worker Scheduler | ✅ Completed | Added 6h and 24h refresh logic to run_worker.py via ingest.py |
| 7 | Frontend Tooltip | ✅ Completed | Created Tooltip.jsx component |
| 8 | Playlists Section | ✅ Completed | Created PlaylistsSection.jsx with refresh and Spotify links |
| 9 | Integration | ✅ Completed | Integrated PlaylistsSection into Dashboard.jsx and added tooltips to StatsGrid.jsx |
| 10 | Docker Config | ✅ Completed | Updated docker-compose.yml and Dockerfile (curl for healthcheck) |
## Phase 3: AI Analysis & Insights
### 1. Data Analysis Enhancements
- [ ] **Timeframe Selection**:
- [ ] Update Backend API to accept timeframe parameters (e.g., `?range=30d`, `?range=year`, `?range=all`).
- [ ] Update Frontend to include a dropdown/toggle for these timeframes.
- [ ] **Advanced Stats**:
- [ ] Top Artists / Tracks calculation for the selected period.
- [ ] Genre distribution charts (Pie/Bar chart).
### 2. AI Integration (Gemini)
- [ ] **Trigger Mechanism**:
- [ ] Add "Generate AI Report" button on the UI.
- [ ] (Optional) Schedule daily auto-generation.
- [ ] **Prompt Engineering**:
- [ ] Design prompts to analyze:
- "Past 30 Days" (Monthly Vibe Check).
- "Overall" (Yearly/All-time evolution).
- [ ] Provide raw data (list of tracks + audio features) to Gemini.
- [ ] **Storage**:
- [ ] Create `AnalysisReport` table to store generated HTML/Markdown reports.
- [ ] View past reports in a new "Insights" tab.
### 3. Playlist Generation
- [ ] **Concept**: "Daily Vibe Playlist" or "AI Recommended".
- [ ] **Implementation**:
- [ ] Use ReccoBeats or Spotify Recommendations API.
- [ ] Seed with top 5 recent tracks.
- [ ] Filter by audio features (e.g., "High Energy" playlist).
- [ ] **Action**:
- [ ] Add "Save to Spotify" button in the UI (Requires `playlist-modify-public` scope).
### 4. Polish
- [ ] **Mobile Responsiveness**: Ensure Ant Design tables and charts stack correctly on mobile.
- [ ] **Error Handling**: Better UI feedback for API failures (e.g., expired tokens).
All feature tasks are COMPLETE and VERIFIED.
End-to-end testing with Playwright confirms:
- 6-hour refresh correctly calls AI and Spotify, saves snapshot.
- Daily refresh correctly curates mix and saves snapshot.
- Dashboard displays themed playlists and refresh status.
- Tooltips provide context for technical metrics.