From 4e2e0605ed865ab95c2601c3d41c93218923a9d5 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Fri, 27 Mar 2026 23:18:23 +0000 Subject: [PATCH] Update architecture docs for ListeningStats refactor --- docs/architecture.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index 32538afb..665db4f6 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -39,9 +39,7 @@ MusicLibrary.Application (one_for_one) ├── Ecto.Migrator # Auto-migration on boot ├── Task.Supervisor (MusicLibrary.TaskSupervisor) ├── Phoenix.PubSub (:music_library) -├── LastFm.Supervisor (one_for_one) -│ ├── Phoenix.PubSub (:last_fm) # Last.fm-specific PubSub -│ └── LastFm.Refresh # GenServer, periodic scrobble fetch +├── MusicLibrary.ListeningStats.Refresh # GenServer, periodic scrobble fetch └── MusicLibraryWeb.Endpoint ``` @@ -84,7 +82,7 @@ write to it directly; insert/update the `records` table instead. | `Chats.Message` | `chat_messages` | `id` (binary_id) | role, content, position, belongs_to :chat | Last.fm schemas (separate, not Ecto-persisted to main DB): -- `LastFm.Track` — scrobbled tracks stored in Last.fm's own tables via `LastFm.Feed` +- `LastFm.Track` — scrobbled tracks from Last.fm API responses - `LastFm.Album`, `LastFm.Artist` — parsed API responses --- @@ -103,7 +101,7 @@ Last.fm schemas (separate, not Ecto-persisted to main DB): | `RecordSets` | RecordSet, RecordSetItem | User-curated record groupings with ordering | | `ScrobbleRules` | ScrobbleRule | Rules to remap Last.fm scrobble data to correct MusicBrainz IDs; searchable by match_value/target/description, orderable by alphabetical or inserted_at | | `ScrobbleActivity` | — | Scrobbling releases/media/tracks to Last.fm | -| `ListeningStats` | (LastFm.Track, ArtistRecord, ArtistInfo) | Listening analytics, track CRUD, search, listing: scrobble counts, artist play counts (from DB), recent activity, top albums/artists by period | +| `ListeningStats` | (LastFm.Track, ArtistRecord, ArtistInfo) | Scrobble persistence, refresh scheduling, listening analytics, track CRUD, search, listing: scrobble counts, artist play counts (from DB), recent activity, top albums/artists by period | | `OnlineStoreTemplates` | OnlineStoreTemplate | URL templates for buying records online; searchable by name/description | | `Search` | (cross-context) | Universal search dispatcher across collection, wishlist, artists, record sets (delegates to domain contexts) | | `Secrets` | Secret | Encrypted key-value storage | @@ -226,7 +224,7 @@ stubbed via `Req.Test` (configured in `config/test.exs`). | PubSub | Topic Pattern | Message | Used By | |--------|---------------|---------|---------| | `:music_library` | `"records:#{id}"` | `{:update, record}` | CollectionLive.Show, WishlistLive.Show — real-time record updates | -| `:last_fm` | `"feed:update"` | `%{track_count: n}` | StatsLive.Index, ScrobbledTracksLive.Index — new scrobbles arrived | +| `:music_library` | `"listening_stats:update"` | `%{track_count: n}` | StatsLive.Index, ScrobbledTracksLive.Index — new scrobbles arrived | ---