How fpkhan/spotify-ai-fetcher-app works
1. Overall shape
This repo is a three-tier system: a React browser client, a Python FastAPI backend, and a set of external services for AI, embeddings, database search, and Spotify integration. The repository contains the app code and container definitions, but the durable data store and model endpoints live outside the repo.
2. Frontend boundary
The client/ directory is a Vite React single-page app. The main runtime entry points are client/src/main.jsx and client/src/App.jsx. Architecturally, this layer is responsible for user interaction, text entry, microphone capture in the browser, and rendering retrieved track recommendations and any generated explanations.
3. Backend API boundary
The server/ directory is a Python FastAPI service. server/main.py is the API entrypoint, while Upload.py and Retreive.py appear to split the backend into two responsibilities: one for accepting/transcribing input and one for semantic retrieval/recommendation. Credentials.py isolates secret/config access from the request handlers.
4. Voice-to-text ingestion path
The main non-trivial input flow is: browser audio capture → backend upload endpoint → speech-to-text service → text query. The README says transcription is routed to Groq Whisper large-v3. This means the backend acts as the broker for raw audio, and the transcription service is an external dependency rather than an in-repo model.
5. Semantic search path
After transcription or direct typed input, the backend creates a semantic representation of the query using a local Ollama container running nomic-embed-text. The resulting embedding is used to search the track corpus by similarity rather than by keyword, which is the core “RAG/discovery” behavior of the system.
6. Data tier
The track catalog is stored in Azure SQL Serverless according to the README. The important architectural point is that similarity search happens against a large cloud data tier, not a local file or in-memory index. The repo’s seed_embeddings.py likely supports the offline ingestion pipeline that chunks tracks and populates embeddings into that database.
7. LLM orchestration
The system also uses Groq Llama-3.3-70b-versatile as an orchestration layer for intent extraction and response synthesis. In architectural terms, this model is not just generating prose; it helps infer query constraints such as result count or ordering and then produces natural-language explanations for returned tracks.
8. Spotify integration
The README describes Spotify OAuth 2.0 and playlist creation. That makes Spotify another external system boundary: the app authenticates the user against Spotify, then can create playlists in the user’s account from the recommendations returned by the backend.
9. Containerization and runtime separation
client/Dockerfile, server/Dockerfile, and docker-compose.yml indicate the app is intended to run as separate containers for frontend and backend. This keeps the browser app, API server, and external dependencies decoupled, and makes it easier to diagram the system as independently deployable services.
10. What is not in the repo
There is no local database engine, local model checkpoint, or Spotify API implementation in-tree. Those are all accessed through network boundaries or environment-based credentials, so the repo is best diagrammed as an orchestrator plus UI, not as a self-contained ML or data platform.
11. Primary end-to-end flow
The typical request path is: user speaks/types in the client → FastAPI receives input → backend transcribes if needed → backend embeds the query → backend searches Azure SQL by vector similarity → backend optionally uses the LLM to refine/explain → client displays results → user may push selected tracks into Spotify.
12. Key architectural takeaway
The strongest boundary in this system is between the interactive UI/API layer and the AI/data services layer. The repository’s code is mainly glue: it connects browser input, cloud LLMs, embedding generation, vector search, and Spotify actions into one discovery workflow.
Main entry points: App.jsx App · Retreive.py Retrieve · main.py API · Upload.py Upload
Components 17
Client
React browser app for input, capture, and results display
Server
FastAPI backend for upload, retrieval, and orchestration
- API · Backend application entrypoint and route wiring
server/main.py - Upload · Handles browser audio and transcription intake
server/Upload.py - Retrieve · Turns input into retrieval and recommendations
server/Retreive.py - Config · Isolates credentials and environment configuration
server/Credentials.py - Seed data · Offline embedding and population workflow
seed_embeddings.py
External services
Cloud and third-party systems used through network boundaries
- Whisper · External speech-to-text service for uploaded audio
- LLM · External model used for intent and response synthesis
- Embeddings · Local embedding runtime used to vectorize queries
- Track DB · Cloud SQL-backed track catalog and similarity search tier
- Spotify · External account and playlist destination
- User · Speaks, types, reviews recommendations, and exports playlists
Runtime wiring
Container and compose definitions for local deployment
- Compose · Local multi-container service definition
docker-compose.yml - Client image · Container build for the React frontend
client/Dockerfile - Server image · Container build for the FastAPI backend
server/Dockerfile
Connections 19
- User → App: speak/type · User enters a query or records audio
- Entry → App: mounts · Bootstrap loads the SPA
- App → API: API calls · UI sends uploads and retrieval requests
- App → Upload: audio upload · Browser microphone capture is posted for transcription
- API → Upload: routes · Backend exposes ingestion path
- API → Retrieve: routes · Backend exposes recommendation path
- Upload → Whisper: transcribe · Uploaded audio is converted to text externally
- Retrieve → Embeddings: embed query · Query text is vectorized before search
- Retrieve → Track DB: search tracks · Similarity lookup is performed against the catalog
- Retrieve → LLM: explain intent · Model helps infer constraints and synthesize responses
- Retrieve → Spotify: playlist actions · Selected recommendations can be sent to Spotify
- Config → API: config · API keys and service settings are read by handlers
- Seed data → Embeddings: build vectors · Offline ingestion uses the embedding model
- Seed data → Track DB: populate · Embeddings and track data are written to the catalog
- Compose → Client image: build client · Compose defines the frontend service image
- Compose → Server image: build server · Compose defines the backend service image
- Client image → App: packages · Containerizes the SPA
- Server image → API: packages · Containerizes the API service
- App → Spotify: oauth/export · User may authenticate and create playlists through the UI