# fpkhan/spotify-ai-fetcher-app architecture

> Architecture diagram of the GitHub repository fpkhan/spotify-ai-fetcher-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fpkhan/spotify-ai-fetcher-app
- Repository: https://github.com/fpkhan/spotify-ai-fetcher-app

## Overview

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: [`client/src/App.jsx`](https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/client/src/App.jsx) (App), [`server/Retreive.py`](https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/server/Retreive.py) (Retrieve), [`server/main.py`](https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/server/main.py) (API), [`server/Upload.py`](https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/server/Upload.py) (Upload)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_client_app["App<br/>react shell<br/>[App.jsx]"]
  node_client_main["Entry<br/>react bootstrap<br/>[main.jsx]"]
  node_client_assets["Styles<br/>ui styling<br/>[App.css]"]
end

subgraph group_server["Server"]
  node_server_main["API<br/>[main.py]"]
  node_server_upload["Upload<br/>ingest endpoint<br/>[Upload.py]"]
  node_server_retrieve["Retrieve<br/>search endpoint<br/>[Retreive.py]"]
  node_server_creds["Config<br/>secret access<br/>[Credentials.py]"]
  node_seed_embeddings["Seed data<br/>ingestion script<br/>[seed_embeddings.py]"]
end

subgraph group_external["External services"]
  node_groq_whisper(("Whisper<br/>speech api"))
  node_groq_llm(("LLM<br/>reasoning api"))
  node_ollama_embed(("Embeddings<br/>embed service"))
  node_azure_sql[("Track DB<br/>vector store")]
  node_spotify(("Spotify<br/>music api"))
  node_user(("User<br/>browser actor"))
end

subgraph group_ops["Runtime wiring"]
  node_compose["Compose<br/>deployment wiring<br/>[docker-compose.yml]"]
  node_client_docker["Client image<br/>container build"]
  node_server_docker["Server image<br/>container build"]
end

node_user -->|"speak/type"| node_client_app
node_client_main -->|"mounts"| node_client_app
node_client_app -->|"API calls"| node_server_main
node_client_app -->|"audio upload"| node_server_upload
node_server_main -->|"routes"| node_server_upload
node_server_main -->|"routes"| node_server_retrieve
node_server_upload -->|"transcribe"| node_groq_whisper
node_server_retrieve -->|"embed query"| node_ollama_embed
node_server_retrieve -->|"search tracks"| node_azure_sql
node_server_retrieve -->|"explain intent"| node_groq_llm
node_server_retrieve -->|"playlist actions"| node_spotify
node_server_creds -->|"config"| node_server_main
node_seed_embeddings -->|"build vectors"| node_ollama_embed
node_seed_embeddings -->|"populate"| node_azure_sql
node_compose -->|"build client"| node_client_docker
node_compose -->|"build server"| node_server_docker
node_client_docker -->|"packages"| node_client_app
node_server_docker -->|"packages"| node_server_main
node_client_app -->|"oauth/export"| node_spotify

click node_client_app "https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/client/src/App.jsx"
click node_client_main "https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/client/src/main.jsx"
click node_client_assets "https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/client/src/App.css"
click node_server_main "https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/server/main.py"
click node_server_upload "https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/server/Upload.py"
click node_server_retrieve "https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/server/Retreive.py"
click node_server_creds "https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/server/Credentials.py"
click node_seed_embeddings "https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/seed_embeddings.py"
click node_compose "https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/docker-compose.yml"
click node_client_docker "https://github.com/fpkhan/spotify-ai-fetcher-app/tree/main/client/Dockerfile"
click node_server_docker "https://github.com/fpkhan/spotify-ai-fetcher-app/tree/main/server/Dockerfile"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_app,node_client_main,node_client_assets toneBlue
class node_server_main,node_server_upload,node_server_retrieve,node_server_creds,node_seed_embeddings toneAmber
class node_groq_whisper,node_groq_llm,node_ollama_embed,node_azure_sql,node_spotify,node_user toneMint
class node_compose,node_client_docker,node_server_docker toneRose
```

## Components

### Client

React browser app for input, capture, and results display

- [App](https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/client/src/App.jsx): react shell · Top-level SPA composition and UI flow · `client/src/App.jsx`
- [Entry](https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/client/src/main.jsx): react bootstrap · Vite entrypoint that mounts the app · `client/src/main.jsx`
- [Styles](https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/client/src/App.css): ui styling · Shared client styling and visual assets · `client/src/App.css`

### Server

FastAPI backend for upload, retrieval, and orchestration

- [API](https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/server/main.py): fastapi entry · Backend application entrypoint and route wiring · `server/main.py`
- [Upload](https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/server/Upload.py): ingest endpoint · Handles browser audio and transcription intake · `server/Upload.py`
- [Retrieve](https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/server/Retreive.py): search endpoint · Turns input into retrieval and recommendations · `server/Retreive.py`
- [Config](https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/server/Credentials.py): secret access · Isolates credentials and environment configuration · `server/Credentials.py`
- [Seed data](https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/seed_embeddings.py): ingestion script · Offline embedding and population workflow · `seed_embeddings.py`

### External services

Cloud and third-party systems used through network boundaries

- **Whisper**: speech api · External speech-to-text service for uploaded audio
- **LLM**: reasoning api · External model used for intent and response synthesis
- **Embeddings**: embed service · Local embedding runtime used to vectorize queries
- **Track DB**: vector store · Cloud SQL-backed track catalog and similarity search tier
- **Spotify**: music api · External account and playlist destination
- **User**: browser actor · Speaks, types, reviews recommendations, and exports playlists

### Runtime wiring

Container and compose definitions for local deployment

- [Compose](https://github.com/fpkhan/spotify-ai-fetcher-app/blob/main/docker-compose.yml): deployment wiring · Local multi-container service definition · `docker-compose.yml`
- [Client image](https://github.com/fpkhan/spotify-ai-fetcher-app/tree/main/client/Dockerfile): container build · Container build for the React frontend · `client/Dockerfile`
- [Server image](https://github.com/fpkhan/spotify-ai-fetcher-app/tree/main/server/Dockerfile): container build · Container build for the FastAPI backend · `server/Dockerfile`

## Connections

- 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
