# itspetros/moodlist architecture

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

- Interactive diagram: https://gitdiagram.com/itspetros/moodlist
- Repository: https://github.com/itspetros/moodlist

## Overview

MoodList turns mood, time, weather, and genre choices into an in-page song playlist: the browser loads available choices, requests a playlist, and displays playable YouTube links. The server filters and weights a locally seeded catalog, while a separate catalog-building workflow finds and validates YouTube videos. The repository also includes Google sign-in, profile pictures, and saved playlists, plus an installable offline app shell. The README documents background catalog lookups and playback-report handling; those links are shown as unverified because the relevant route excerpts are incomplete.

Main entry points: [`main.py`](https://github.com/itspetros/moodlist/blob/main/main.py) (Web API), [`catalog.py`](https://github.com/itspetros/moodlist/blob/main/catalog.py) (Catalog sync and picker), [`static/app.js`](https://github.com/itspetros/moodlist/blob/main/static/app.js) (Playlist interface), [`youtube.py`](https://github.com/itspetros/moodlist/blob/main/youtube.py) (Video matching)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Playlist experience"]
  node_browser["Playlist interface<br/>[app.js]"]
  node_offline["Offline app shell<br/>[sw.js]"]
  node_api["Web API<br/>[main.py]"]
end

subgraph group_catalog["Song catalog"]
  node_choices["Playlist options<br/>[options.py]"]
  node_seed["Seed song catalog<br/>[seed_songs.csv]"]
  node_picker["Catalog sync and picker<br/>[catalog.py]"]
  node_catalogdb[("Song catalog database<br/>[catalog.py]")]
end

subgraph group_video["Video resolution"]
  node_builder["Catalog builder<br/>[build_catalog.py]"]
  node_resolver["Video matching<br/>[youtube.py]"]
  node_youtubeapi["YouTube Data API"]
end

subgraph group_accounts["Accounts and saved playlists"]
  node_auth["Token authentication<br/>[auth.py]"]
  node_userdata["Account and playlist models<br/>[models.py]"]
  node_schemas["Account and playlist schemas<br/>[schemas.py]"]
end

subgraph group_persistence["Persistence"]
  node_dbsession["Relational DB sessions<br/>[database.py]"]
  node_accountdb[("Account and playlist store<br/>[models.py]")]
end

node_visitor(("Listener"))

node_visitor -->|"chooses filters"| node_browser
node_browser -->|"requests options"| node_api
node_browser -->|"requests playlist"| node_api
node_api -->|"returns choices"| node_choices
node_api -->|"selects songs"| node_picker
node_picker -->|"validates tags"| node_choices
node_picker -->|"syncs songs"| node_seed
node_picker -->|"reads and writes"| node_catalogdb
node_api -->|"returns playlist"| node_browser
node_browser -.->|"uses app shell"| node_offline
node_visitor -->|"runs catalog build"| node_builder
node_builder -->|"syncs and queues"| node_picker
node_builder -->|"resolves videos"| node_resolver
node_resolver -->|"searches and checks"| node_youtubeapi
node_resolver -->|"records video results"| node_picker
node_api -.->|"fills missing videos"| node_resolver
node_visitor -->|"signs in or saves"| node_api
node_api -->|"checks user token"| node_auth
node_auth -->|"loads user"| node_userdata
node_auth -->|"opens session"| node_dbsession
node_api -->|"manages accounts"| node_userdata
node_api -->|"validates responses"| node_schemas
node_userdata -->|"maps records"| node_accountdb
node_api -->|"uses sessions"| node_dbsession
node_dbsession -->|"persists records"| node_accountdb
node_browser -->|"opens video links"| node_youtubeapi
node_api -.->|"records playback reports"| node_picker

click node_browser "https://github.com/itspetros/moodlist/blob/main/static/app.js"
click node_offline "https://github.com/itspetros/moodlist/blob/main/static/sw.js"
click node_api "https://github.com/itspetros/moodlist/blob/main/main.py"
click node_choices "https://github.com/itspetros/moodlist/blob/main/options.py"
click node_seed "https://github.com/itspetros/moodlist/blob/main/data/seed_songs.csv"
click node_picker "https://github.com/itspetros/moodlist/blob/main/catalog.py"
click node_catalogdb "https://github.com/itspetros/moodlist/blob/main/catalog.py"
click node_builder "https://github.com/itspetros/moodlist/blob/main/build_catalog.py"
click node_resolver "https://github.com/itspetros/moodlist/blob/main/youtube.py"
click node_auth "https://github.com/itspetros/moodlist/blob/main/auth.py"
click node_userdata "https://github.com/itspetros/moodlist/blob/main/models.py"
click node_schemas "https://github.com/itspetros/moodlist/blob/main/schemas.py"
click node_dbsession "https://github.com/itspetros/moodlist/blob/main/database.py"
click node_accountdb "https://github.com/itspetros/moodlist/blob/main/models.py"

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_browser,node_offline,node_api toneBlue
class node_choices,node_seed,node_picker,node_catalogdb toneAmber
class node_builder,node_resolver,node_youtubeapi toneMint
class node_auth,node_userdata,node_schemas toneRose
class node_dbsession,node_accountdb,node_visitor toneIndigo
```

## Components

### Playlist experience

- [Playlist interface](https://github.com/itspetros/moodlist/blob/main/static/app.js): `static/app.js`
- [Offline app shell](https://github.com/itspetros/moodlist/blob/main/static/sw.js): `static/sw.js`
- [Web API](https://github.com/itspetros/moodlist/blob/main/main.py): `main.py`

### Song catalog

- [Playlist options](https://github.com/itspetros/moodlist/blob/main/options.py): `options.py`
- [Seed song catalog](https://github.com/itspetros/moodlist/blob/main/data/seed_songs.csv): `data/seed_songs.csv`
- [Catalog sync and picker](https://github.com/itspetros/moodlist/blob/main/catalog.py): `catalog.py`
- [Song catalog database](https://github.com/itspetros/moodlist/blob/main/catalog.py): `catalog.py`

### Video resolution

- [Catalog builder](https://github.com/itspetros/moodlist/blob/main/build_catalog.py): `build_catalog.py`
- [Video matching](https://github.com/itspetros/moodlist/blob/main/youtube.py): `youtube.py`
- **YouTube Data API**

### Accounts and saved playlists

- [Token authentication](https://github.com/itspetros/moodlist/blob/main/auth.py): `auth.py`
- [Account and playlist models](https://github.com/itspetros/moodlist/blob/main/models.py): `models.py`
- [Account and playlist schemas](https://github.com/itspetros/moodlist/blob/main/schemas.py): `schemas.py`

### Persistence

- [Relational DB sessions](https://github.com/itspetros/moodlist/blob/main/database.py): `database.py`
- [Account and playlist store](https://github.com/itspetros/moodlist/blob/main/models.py): `models.py`

### Other components

- **Listener**

## Connections

- Listener → Playlist interface: chooses filters (evidence: `README.md`)
- Playlist interface → Web API: requests options (evidence: `static/app.js`)
- Playlist interface → Web API: requests playlist (evidence: `static/app.js`)
- Web API → Playlist options: returns choices (evidence: `main.py`)
- Web API → Catalog sync and picker: selects songs (evidence: `main.py`)
- Catalog sync and picker → Playlist options: validates tags (evidence: `catalog.py`)
- Catalog sync and picker → Seed song catalog: syncs songs (evidence: `README.md`)
- Catalog sync and picker → Song catalog database: reads and writes (evidence: `catalog.py`)
- Web API → Playlist interface: returns playlist (evidence: `static/app.js`)
- Playlist interface → Offline app shell: uses app shell
- Listener → Catalog builder: runs catalog build (evidence: `README.md`)
- Catalog builder → Catalog sync and picker: syncs and queues (evidence: `build_catalog.py`)
- Catalog builder → Video matching: resolves videos (evidence: `build_catalog.py`)
- Video matching → YouTube Data API: searches and checks (evidence: `youtube.py`)
- Video matching → Catalog sync and picker: records video results (evidence: `youtube.py`)
- Web API → Video matching: fills missing videos (evidence: `README.md`)
- Listener → Web API: signs in or saves
- Web API → Token authentication: checks user token (evidence: `main.py`)
- Token authentication → Account and playlist models: loads user (evidence: `auth.py`)
- Token authentication → Relational DB sessions: opens session (evidence: `auth.py`)
- Web API → Account and playlist models: manages accounts (evidence: `main.py`)
- Web API → Account and playlist schemas: validates responses (evidence: `main.py`)
- Account and playlist models → Account and playlist store: maps records (evidence: `models.py`)
- Web API → Relational DB sessions: uses sessions (evidence: `main.py`)
- Relational DB sessions → Account and playlist store: persists records (evidence: `database.py`)
- Playlist interface → YouTube Data API: opens video links (evidence: `README.md`)
- Web API → Catalog sync and picker: records playback reports (evidence: `README.md`)
