# unkreativimweb/waitlist architecture

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

- Interactive diagram: https://gitdiagram.com/unkreativimweb/waitlist
- Repository: https://github.com/unkreativimweb/waitlist

## Overview

1. **What this repo is**
   MOOD is a local, Python-based CLI for exploring Spotify music and generating recommendations. There is no hosted backend: the application runs on the user’s machine and talks directly to third-party APIs.

2. **Runtime and entry point**
   `src/main.py` is the top-level orchestrator. It initializes environment/config, logging, cached state, and service clients, then drives the interactive command-line menu. The app is built around user prompts rather than HTTP requests or a server loop.

3. **Core orchestration boundary**
   The main control layer sits above the service modules and decides which path to execute: recommendation generation, queue insertion, playlist management, or settings/cache actions. This makes the app behave like a small workflow engine coordinating API calls and local state updates.

4. **Spotify integration layer**
   `src/spotify.py` is the main boundary to Spotify. It handles authentication, search, playback-related actions, playlist creation/updates, reading liked songs and library items, and adding tracks to a queue. The `.spotify_cache` file in `data/prod` persists Spotify auth tokens locally so the user usually only authorizes once.

5. **Recommendation / AI pipeline**
   `src/ai.py` is the recommendation engine interface. The flow is: choose a seed track/artist/album/playlist/liked song in Spotify, enrich that seed with track attributes, send a structured prompt to Gemini, then turn the model output into song-artist recommendations. `src/audio_db.py` and `src/genius.py` appear to supply enrichment data used by the prompt.

6. **External data enrichment**
   The app is not relying on Spotify alone. It enriches seed tracks with additional metadata from external music data sources before calling Gemini. Based on the repo and README, this includes at least Genius-related auth/data and an audio/genre attribute source such as TheAudioDB or a similar service configured through environment variables.

7. **Local cache and app state**
   `src/cache_manager.py` manages persistent application state in `data/prod/cache.json`. This cache stores user-level configuration such as default playlist settings, limits, and other UI/stateful preferences that should survive restarts.

8. **Database subsystem**
   `src/database/db.py`, `src/database/factory.py`, and `src/database/track_attributes.py` form a separate persistence/import subsystem centered on a local SQLite database. The repo includes `data/songs.db` as generated storage, and the README shows CLI commands for importing artists and seeding the database. This subsystem is distinct from the lightweight JSON cache.

9. **Configuration and secrets**
   `src/env.py` loads environment variables for Spotify, Gemini, Genius, and other external providers. This is where API credentials and redirect URIs are expected to come from, so the app’s external dependencies are configured entirely at the edge rather than hardcoded.

10. **CLI user flows**
   The user-facing flows are:
   - pick a discovery source and generate recommendations,
   - create a new playlist or fill an existing/default playlist,
   - add recommendations to the Spotify queue,
   - adjust settings like default playlist name, description, limits, and cache/auth resets.
   The flowcharts in `waitlist.mermaid` and `genius_auth.mermaid` document these paths, though the README notes the main flowchart is outdated.

11. **Data files and generated artifacts**
   `data/prod/lyric_attributes.json` looks like a generated lookup/attribute file used by the recommendation pipeline or database import. The `data/prod` folder is the main persistence area for runtime artifacts, while source code stays under `src/`.

12. **Important architectural boundaries**
   The key boundaries to diagram are:
   - CLI/orchestrator vs. service modules,
   - service modules vs. external APIs,
   - transient config/cache vs. durable SQLite database,
   - Spotify auth/session state vs. application preferences.
   Most of the repo’s behavior is shaped by these boundaries and the data moving between them.

Main entry points: [`src/main.py`](https://github.com/unkreativimweb/waitlist/blob/main/src/main.py) (Main), [`src/ai.py`](https://github.com/unkreativimweb/waitlist/blob/main/src/ai.py) (Recommender), [`src/env.py`](https://github.com/unkreativimweb/waitlist/blob/main/src/env.py) (Env), [`src/database/db.py`](https://github.com/unkreativimweb/waitlist/blob/main/src/database/db.py) (SQLite DB)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_cli["CLI orchestration"]
  node_node_main["Main<br/>CLI orchestrator<br/>[main.py]"]
  node_node_env["Env<br/>config loader<br/>[env.py]"]
  node_node_logger["Logger<br/>logging setup<br/>[logger_config.py]"]
  node_node_utils["Utils<br/>shared helpers<br/>[utils.py]"]
end

subgraph group_group_services["Service layer"]
  node_node_spotify["Spotify<br/>api client<br/>[spotify.py]"]
  node_node_ai["Recommender<br/>pipeline<br/>[ai.py]"]
  node_node_audio_db[("Audio DB<br/>enrichment source<br/>[audio_db.py]")]
  node_node_genius["Genius<br/>lyrics enrichment<br/>[genius.py]"]
  node_node_genius_auth["Genius Auth<br/>auth flow<br/>[genius_auth.py]"]
end

subgraph group_group_data["Persistence"]
  node_node_cache["Cache<br/>json state<br/>[cache_manager.py]"]
  node_node_db_factory["DB Factory<br/>db bootstrap<br/>[factory.py]"]
  node_node_db_core[("SQLite DB<br/>sqlite store<br/>[db.py]")]
  node_node_track_attrs["Track Attrs<br/>import model"]
  node_node_lyric_attrs["Lyric Data<br/>generated artifact"]
end

subgraph group_group_ext["External APIs"]
  node_node_spotify_api(("Spotify API<br/>external service"))
  node_node_gemini_api(("Gemini API<br/>external service"))
  node_node_genius_api(("Genius API<br/>external service"))
end

node_node_main -->|"loads"| node_node_env
node_node_main -->|"configures"| node_node_logger
node_node_main -->|"hydrates"| node_node_cache
node_node_main -->|"drives"| node_node_spotify
node_node_main -->|"calls"| node_node_ai
node_node_main -->|"initializes"| node_node_db_factory
node_node_main -->|"uses"| node_node_utils
node_node_spotify -->|"auths with"| node_node_spotify_api
node_node_ai -->|"seeds from"| node_node_spotify
node_node_ai -->|"enriches with"| node_node_audio_db
node_node_ai -->|"enriches with"| node_node_genius
node_node_ai -->|"prompts"| node_node_gemini_api
node_node_audio_db -->|"imports to"| node_node_db_core
node_node_db_factory -->|"creates"| node_node_db_core
node_node_db_core -->|"stores"| node_node_track_attrs
node_node_db_core -->|"references"| node_node_lyric_attrs
node_node_genius -->|"auths with"| node_node_genius_api
node_node_genius_auth -->|"authorizes"| node_node_genius_api
node_node_cache -->|"persists session"| node_node_spotify
node_node_cache -->|"restores prefs"| node_node_main
node_node_env -->|"credentials"| node_node_spotify_api
node_node_env -->|"credentials"| node_node_gemini_api
node_node_env -->|"credentials"| node_node_genius_api

click node_node_main "https://github.com/unkreativimweb/waitlist/blob/main/src/main.py"
click node_node_env "https://github.com/unkreativimweb/waitlist/blob/main/src/env.py"
click node_node_logger "https://github.com/unkreativimweb/waitlist/blob/main/src/logger_config.py"
click node_node_utils "https://github.com/unkreativimweb/waitlist/blob/main/src/utils.py"
click node_node_spotify "https://github.com/unkreativimweb/waitlist/blob/main/src/spotify.py"
click node_node_ai "https://github.com/unkreativimweb/waitlist/blob/main/src/ai.py"
click node_node_audio_db "https://github.com/unkreativimweb/waitlist/blob/main/src/audio_db.py"
click node_node_genius "https://github.com/unkreativimweb/waitlist/blob/main/src/genius.py"
click node_node_genius_auth "https://github.com/unkreativimweb/waitlist/blob/main/src/genius_auth.py"
click node_node_cache "https://github.com/unkreativimweb/waitlist/blob/main/src/cache_manager.py"
click node_node_db_factory "https://github.com/unkreativimweb/waitlist/blob/main/src/database/factory.py"
click node_node_db_core "https://github.com/unkreativimweb/waitlist/blob/main/src/database/db.py"
click node_node_track_attrs "https://github.com/unkreativimweb/waitlist/blob/main/src/database/track_attributes.py"
click node_node_lyric_attrs "https://github.com/unkreativimweb/waitlist/blob/main/data/prod/lyric_attributes.json"

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_node_main,node_node_env,node_node_logger,node_node_utils toneBlue
class node_node_spotify,node_node_ai,node_node_audio_db,node_node_genius,node_node_genius_auth toneAmber
class node_node_cache,node_node_db_factory,node_node_db_core,node_node_track_attrs,node_node_lyric_attrs toneMint
class node_node_spotify_api,node_node_gemini_api,node_node_genius_api toneRose
```

## Components

### CLI orchestration

Interactive command-line flows and top-level control.

- [Main](https://github.com/unkreativimweb/waitlist/blob/main/src/main.py): CLI orchestrator · Top-level entry point that initializes config, logging, state, and drives interactive flows. · `src/main.py`
- [Env](https://github.com/unkreativimweb/waitlist/blob/main/src/env.py): config loader · Loads environment variables and secrets for external providers. · `src/env.py`
- [Logger](https://github.com/unkreativimweb/waitlist/blob/main/src/logger_config.py): logging setup · Configures application logging. · `src/logger_config.py`
- [Utils](https://github.com/unkreativimweb/waitlist/blob/main/src/utils.py): shared helpers · Common utility functions used across the CLI and services. · `src/utils.py`

### Service layer

Spotify, recommendation, and enrichment modules.

- [Spotify](https://github.com/unkreativimweb/waitlist/blob/main/src/spotify.py): api client · Primary boundary for Spotify auth, search, playback, playlists, library reads, and queueing. · `src/spotify.py`
- [Recommender](https://github.com/unkreativimweb/waitlist/blob/main/src/ai.py): pipeline · Builds prompts from seed music and turns model output into recommendations. · `src/ai.py`
- [Audio DB](https://github.com/unkreativimweb/waitlist/blob/main/src/audio_db.py): enrichment source · Supplies track attributes and metadata used to enrich recommendation seeds. · `src/audio_db.py`
- [Genius](https://github.com/unkreativimweb/waitlist/blob/main/src/genius.py): lyrics enrichment · Provides Genius-related auth or metadata for enrichment workflows. · `src/genius.py`
- [Genius Auth](https://github.com/unkreativimweb/waitlist/blob/main/src/genius_auth.py): auth flow · Interactive Genius authorization flow documented as a separate path. · `src/genius_auth.py`

### Persistence

Local cache, SQLite database, and generated runtime artifacts.

- [Cache](https://github.com/unkreativimweb/waitlist/blob/main/src/cache_manager.py): json state · Persistent app preferences and lightweight runtime state in a local JSON cache. · `src/cache_manager.py`
- [DB Factory](https://github.com/unkreativimweb/waitlist/blob/main/src/database/factory.py): db bootstrap · Creates or wires the local SQLite database connection. · `src/database/factory.py`
- [SQLite DB](https://github.com/unkreativimweb/waitlist/blob/main/src/database/db.py): sqlite store · Local durable database used for imported track and artist data. · `src/database/db.py`
- [Track Attrs](https://github.com/unkreativimweb/waitlist/blob/main/src/database/track_attributes.py): import model · Database-side track attribute schema and import logic. · `src/database/track_attributes.py`
- [Lyric Data](https://github.com/unkreativimweb/waitlist/blob/main/data/prod/lyric_attributes.json): generated artifact · Generated JSON lookup data used by enrichment or import workflows. · `data/prod/lyric_attributes.json`

### External APIs

Third-party services the app talks to directly.

- **Spotify API**: external service · Third-party Spotify platform used for user authentication and music actions.
- **Gemini API**: external service · Third-party model service used to generate recommendations.
- **Genius API**: external service · Third-party lyrics and music metadata service.

## Connections

- Main → Env: loads · Reads configuration and secrets before starting the menu loop.
- Main → Logger: configures · Initializes logging early in startup.
- Main → Cache: hydrates · Loads persisted app preferences and runtime state.
- Main → Spotify: drives · Routes menu actions into Spotify operations.
- Main → Recommender: calls · Triggers recommendation generation workflows.
- Main → DB Factory: initializes · Bootstraps the SQLite-backed database subsystem when needed.
- Main → Utils: uses · Shares common helper behavior across flows.
- Spotify → Spotify API: auths with · Talks directly to Spotify for auth and user/music actions.
- Recommender → Spotify: seeds from · Pulls selected tracks, artists, albums, playlists, or liked songs as recommendation seeds.
- Recommender → Audio DB: enriches with · Adds track attributes and metadata before prompting the model.
- Recommender → Genius: enriches with · Uses Genius-derived information as part of seed enrichment.
- Recommender → Gemini API: prompts · Sends structured prompts to Gemini and parses the output.
- Audio DB → SQLite DB: imports to · Supports persisting enriched metadata into the local database.
- DB Factory → SQLite DB: creates · Builds or connects to the SQLite database.
- SQLite DB → Track Attrs: stores · Holds imported track attribute records and related entities.
- SQLite DB → Lyric Data: references · Consumes generated attribute data during import or lookup workflows.
- Genius → Genius API: auths with · Communicates with Genius for metadata and authorization.
- Genius Auth → Genius API: authorizes · Documents the standalone Genius authorization flow.
- Cache → Spotify: persists session · Stores local Spotify auth/session state separately from app preferences.
- Cache → Main: restores prefs · Feeds saved defaults and limits back into the interactive flows.
- Env → Spotify API: credentials · Supplies Spotify client settings and redirect configuration.
- Env → Gemini API: credentials · Supplies model API keys and configuration.
- Env → Genius API: credentials · Supplies Genius API settings and secrets.
