This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Start both database and FastAPI application
docker-compose up -d
# View logs
docker-compose logs -f
# Rebuild application after code changes
docker-compose up --build -d app
# Stop all services
docker-compose down
# Access the application
# Web interface: http://localhost:8000/static/index3.html
# API docs: http://localhost:8000/docs# Start PostgreSQL database only
docker-compose up -d db
# Install dependencies (preferred method)
uv sync
# Alternative dependency installation
pip install -r requirements.txt
# Start the FastAPI server locally
uvicorn api.main:app --reload
# Access the application
# Web interface: http://localhost:8000/static/index3.html
# API docs: http://localhost:8000/docsThe application requires a .env file with the following variables:
AZURE_OPENAI_API_KEY,AZURE_OPENAI_ENDPOINT,AZURE_DEPLOYMENT_NAME- Azure OpenAI configurationSPOTIFY_CLIENT_ID,SPOTIFY_CLIENT_SECRET- Spotify OAuth credentialsSERPER_API_KEY- Web search functionalityPOSTGRES_URL- Database connection (auto-configured in Docker, defaults topostgresql://postgres:postgres@localhost:5432/postgresfor local development)
The core of the application is a multi-agent system built with the Agno framework:
- SpotifyMusicAssistant (
spotify_playlist/spotify_assistant.py): Main orchestrator that creates specialized AI agents - Three Expert Agents:
- Expert Text Analyzer: Analyzes user input for mood and preferences
- Expert Music Curator: Searches for songs based on analysis
- Spotify API Expert: Handles playlist creation and Spotify operations
FastAPI Application Structure:
api/main.py: Application entry point using Agno's FastAPIAppapi/routers/chat.py: Streaming chat endpoint with Server-Sent Eventsapi/routers/auth.py: Spotify OAuth2 authentication flowapi/core/config.py: Centralized configuration management
Spotify Integration:
spotify_playlist/spotify_toolkit.py: Custom Agno toolkit with Spotify API functions- Functions include:
search_songs_uris,create_playlist_by_uris,get_user_top_genres, etc.
Data Persistence:
- PostgreSQL database for conversation memory (managed by Agno framework)
- Agent storage table:
spotify_playlist_assistant - Database runs in Docker container with default dev credentials
- User authenticates via Spotify OAuth (
/auth/login) - Frontend sends chat request to
/chat/with session_id and user_id - Chat router creates new
SpotifyMusicAssistantinstance per request - Assistant creates a team of specialized agents with user's access token
- Team processes request using multi-agent collaboration
- Response streams back via Server-Sent Events
- Stateless request handling with PostgreSQL-backed session persistence
- Each request creates fresh assistant instance but retrieves conversation history via session_id
- Access tokens are managed per request, not persisted in application state
The main application creates a "template team" with dummy credentials for FastAPIApp initialization. This template is NOT used for actual request processing - each request creates its own properly authenticated team.
The Settings class in api/core/config.py handles all environment variable loading with sensible defaults for development.
The PostgresAgentStorage is configured with auto_upgrade_schema=True to handle database migrations automatically.