Recommendation delivery
Recommendation delivery turns the library catalog into two useful discovery surfaces: games similar to the current game and a personal feed for the signed-in user. It builds a shared similarity view from catalog data and usage signals, ranks personal results from live user activity, stores the durable work for reuse, and returns only games that the viewer can see.
Recommendation surfaces
The system serves one catalog-wide similarity surface and one user-specific feed. Both surfaces use the same stored relationships and return a game, its relevance score, and plain reasons that the client can show to the user.
Similar game shelves
The similar-games shelf answers “what in this library resembles this game?” It reads the best stored neighbours for one ROM, removes hidden or unavailable games, limits repetition from one series, and returns the remaining games in score order. The source game and alternate copies of the same title are not suggestions for themselves (backend/…/__init__.py• L1406-1439, backend/…/serving.py• L29-45).
This shelf appears in the game overview. A shared UI preference can hide it together with the personal home feed, while other related-game groups such as expansions and remakes remain separate (frontend/…/OverviewTab.vue• L69-75, frontend/…/OverviewTab.vue• L295-344).
References: backend/…/__init__.py• L1406-1439 backend/…/serving.py• L29-45 frontend/…/OverviewTab.vue• L69-75 frontend/…/OverviewTab.vue• L295-344
Personal recommendation feed
The personal feed answers “what should this user play next?” It uses games the user has played, rated, or marked with a play state as seeds. A seed is a user-associated game that can pull related candidates into the feed. The feed combines contributions from many seeds, gives the strongest seed as the “Because you played” explanation, and excludes hidden games and the seeds themselves (backend/…/feed.py• L141-222).
The home page requests this feed when recommendations are enabled. It shows a card row only when results exist or while the request is in progress, so an empty or unavailable feed does not make the rest of the home page fail (frontend/…/Home.vue• L65-85, frontend/…/Home.vue• L410-449). See Game library catalog for the wider catalog model.
References: backend/…/feed.py• L141-222 frontend/…/Home.vue• L65-85 frontend/…/Home.vue• L410-449
Candidate relationships
The durable recommendation index links pairs of library games. It uses catalog metadata to find plausible pairs, then adds trusted relationships from provider data, shared play history, and shared collections so a useful link can exist even when metadata overlap is weak.
Candidate signals
Candidate generation starts with metadata facets such as genre, franchise, collection, company, creator, theme, player perspective, platform, and release decade. Rare facets help find candidates, while common facets do not expand into most of the library. The build also includes owned games named by provider-related data and games that users play together or place in the same collection (backend/…/scoring.py• L44-84, backend/…/builder.py• L207-247, backend/…/builder.py• L282-325).
The builder keeps the index focused on real choices in the catalog. It skips games with no useful taste data and ignores pairs that represent the same title through regions, revisions, storefront copies, or other matched identities (backend/…/builder.py• L249-280, backend/…/builder.py• L355-362).
References: backend/…/scoring.py• L44-84 backend/…/builder.py• L207-247 backend/…/builder.py• L249-280 backend/…/builder.py• L282-325 backend/…/builder.py• L355-362
Relevance scores
Each candidate pair receives one score that combines metadata similarity with provider, co-play, and co-collection signals. Library-relative weighting makes a rare shared facet more useful than a facet present on most games. A small quality bonus can favor a well-reviewed game without replacing a strong similarity match (backend/…/scoring.py• L216-235, backend/…/scoring.py• L276-341, backend/…/scoring.py• L344-367).
The index stores the strongest relationships for each game and stores the main facets that caused each relationship. These reasons are part of the product contract: they let the UI explain a match without scoring it again (backend/…/recommendation.py• L15-46, backend/…/builder.py• L495-557).
References: backend/…/scoring.py• L216-235 backend/…/scoring.py• L276-341 backend/…/scoring.py• L344-367 backend/…/recommendation.py• L15-46 backend/…/builder.py• L495-557
Duplicate suppression
Duplicate suppression keeps the catalog from recommending another file for the same game. The builder also avoids repeated title keys and limits stored results from one series, so the serving layer has room to show related but different games (backend/…/builder.py• L495-557).
References: backend/…/builder.py• L355-362 backend/…/builder.py• L495-557
Feed ranking
Personal ranking happens when the feed is requested rather than being precomputed for every user. This keeps recent play and user choices relevant while reusing the shared similarity index for the expensive library-wide work.
User affinity
User affinity is the strength and direction with which a game should influence the feed. It uses play time, rating, play status, current play state, and recency. A low rating pushes related games away, while recent activity has more weight than old activity without removing old preferences completely (backend/…/feed.py• L26-63, backend/…/feed.py• L86-138).
The feed fans out from the strongest seeds and sums their weighted pair scores. It reduces the weight of games the user already played instead of removing them, because a sequel or related new game can still be useful (backend/…/feed.py• L193-222, backend/…/feed.py• L224-264).
References: backend/…/feed.py• L26-63 backend/…/feed.py• L86-138 backend/…/feed.py• L193-222 backend/…/feed.py• L224-264
Diversity controls
Diversity is applied at delivery time so the policy can change without rebuilding the index. The service overfetches ranked candidates, then limits repeated series and can limit one platform in the personal feed. It backfills capped entries when needed and keeps their original score order (backend/…/diversity.py• L15-21, backend/…/diversity.py• L44-100, backend/…/feed.py• L224-264).
The similar-games shelf ranks beyond the requested limit for series diversity and adds extra depth for viewers with restricted ROM visibility. The personal feed also ranks and caches a deeper list for restricted viewers, then applies the current visibility check after reading or building that cache. Unrestricted requests use the requested feed limit. These steps help both paths return a full row without exposing games that the viewer cannot see (backend/…/serving.py• L24-45, backend/…/serving.py• L48-82).
References: backend/…/diversity.py• L15-21 backend/…/diversity.py• L44-100 backend/…/feed.py• L224-264 backend/…/serving.py• L24-45 backend/…/serving.py• L48-82
Cold-start results
When a user has no useful activity or no related candidates, the feed falls back to highly rated games in the visible library. The fallback uses a vote-aware average so a small number of ratings does not outweigh broad support, and it marks each result as highly rated rather than pretending it came from a played seed (backend/…/recommendations_handler.py• L417-458, backend/…/feed.py• L266-283).
References: backend/…/recommendations_handler.py• L417-458 backend/…/feed.py• L266-283
Index persistence
The system persists library-wide similarity edges and treats personal rankings as short-lived derived data. This split lets scheduled work refresh relationships for the whole catalog while requests adapt to current user behavior.
Similarity index
The similarity index stores directed edges from each game to its best related games. A full build reads one library snapshot and replaces each game's edge set in batches. A targeted top-up refreshes scanned games and updates affected neighbours without waiting for the next full build (backend/…/builder.py• L146-203, backend/…/recommendations_handler.py• L230-253).
The scheduled task can run on its cron schedule or by manual request. After a rebuild, the service invalidates all personal feed versions because every ranking depends on the graph. A scan uses the smaller top-up path for ordinary changes and queues a full build when the changed set is too large (backend/…/build_recommendations.py• L19-59, backend/…/builder.py• L573-600, backend/…/scan.py• L1310-1315). See Library scanning and filesystem handling for the scan lifecycle.
References: backend/…/builder.py• L146-203 backend/…/recommendations_handler.py• L230-253 backend/…/build_recommendations.py• L19-59 backend/…/builder.py• L573-600 backend/…/scan.py• L1310-1315
Feed cache
The personal feed cache stores the ranking and its explanation rather than full ROM records. It uses a short expiry plus separate user and graph versions, so a user change or graph rebuild makes old rankings unreadable without scanning the whole cache (backend/…/feed.py• L299-369).
The serving layer chooses a deeper feed size for restricted viewers before it reads or writes the cache. It rehydrates current ROM records on cache reads and applies visibility after the cache. This keeps permissions, missing files, and other current catalog state effective even when the ranking itself is reused (backend/…/feed.py• L286-322, backend/…/feed.py• L299-369, backend/…/serving.py• L48-76).
References: backend/…/feed.py• L286-322 backend/…/feed.py• L299-369 backend/…/serving.py• L48-76
Catalog interfaces
Recommendation results leave the service through protected catalog APIs and then appear in the game overview and home dashboard. The API carries both the catalog card data and the explanation data needed by the UI.
API responses
The similar-games route is scoped to one visible ROM. The recommendation route is scoped to the signed-in user. Both accept a bounded result limit and return a lightweight ROM record, score, and reason list; personal results may also include the seed game ID and name (backend/…/__init__.py• L1406-1439, backend/…/recommendations.py• L18-54, backend/…/recommendation.py• L9-30).
The frontend API client maps these routes to separate calls. It uses a small limit for the detail shelf and a larger limit for the home row, while allowing an explicit refresh of the personal feed (frontend/…/rom.ts• L440-474). See Catalog data and API operations for the wider route and response model.
References: backend/…/__init__.py• L1406-1439 backend/…/recommendations.py• L18-54 backend/…/recommendation.py• L9-30 frontend/…/rom.ts• L440-474
Explanation surfaces
The UI turns each reason facet into an icon or label. Provider and fallback reasons use translated phrases, while named facets such as a franchise can show their value directly. The backend facet type and frontend reason map must stay aligned (frontend/…/similarityReasons.ts• L1-53, frontend/…/recommendations.json• L1-8).
The home row shows the strongest seed as “Because you played” and the game overview shows the same reason data under “Similar games.” If the feed is empty or fails because the index is not ready, the home page hides only that row and keeps the rest of the catalog usable (frontend/…/Home.vue• L410-449, frontend/…/Home.test.ts• L228-269).
References: frontend/…/similarityReasons.ts• L1-53 frontend/…/recommendations.json• L1-8 frontend/…/Home.vue• L410-449 frontend/…/Home.test.ts• L228-269
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to catalog facets or provider identity must keep candidate generation, duplicate suppression, score reasons, and diversity keys aligned.
- Changes to the similarity graph must invalidate personal feed versions and preserve the targeted scan top-up path.
- Changes to user play state, ratings, hidden status, or visibility must invalidate or bypass the affected personal ranking so the feed does not wait for its normal expiry.
- Changes to result limits or visibility rules must preserve overfetching before series, platform, and permission filtering.
- Changes to the
Facetvalues must update the generated frontend type, reason icon map, translated labels, and any API examples. - Changes to the ROM response or visibility contract must keep cache rehydration and both recommendation surfaces on the shared visible-ROM path.
- Changes to the home preference must keep the recommendation row and game-detail similar shelf consistent.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The similarity index has not been built or the library has too little useful metadata. | Similar-game shelves can be empty and the home recommendation row stays hidden. | Treat an empty index as a normal state and build it through the scheduled or manual task (backend/…/build_recommendations.py• L33-59, frontend/…/Home.vue• L73-85). |
| A scan changes games but does not update the similarity index. | New or changed games have stale or missing relationships until a later full build. | Run a targeted top-up after scans and queue a full build for large changes (backend/…/scan.py• L1310-1315, backend/…/builder.py• L573-600). |
| A graph rebuild leaves old personal feed versions usable. | Users receive rankings based on relationships that no longer match the catalog. | Bump the graph cache version after a successful rebuild (backend/…/build_recommendations.py• L46-53, backend/…/feed.py• L342-369). |
| A viewer can no longer see a ROM that is present in a cached ranking. | A hidden or missing game can appear in a recommendation response. | Rehydrate current ROMs and apply visibility after cache reads (backend/…/feed.py• L299-322, backend/…/serving.py• L69-76). |
| One series or platform supplies most high-scoring candidates. | The shelf becomes a duplicate of a series filter or one-platform list. | Overfetch and apply series and platform caps with backfill (backend/…/diversity.py• L44-100, backend/…/feed.py• L224-264). |
| The backend adds a new reason facet without a frontend mapping. | The client cannot render the reason contract safely. | Keep the generated Facet type and the exhaustive reason icon map in sync (backend/…/scoring.py• L18-42, frontend/…/similarityReasons.ts• L12-33). |
Key files
| File | Why to read it |
|---|---|
| backend/…/builder.py | Shows how the library snapshot becomes a stored similarity graph and how scans update it. |
| backend/…/scoring.py | Defines the catalog signals, relevance score, and explanation facets. |
| backend/…/feed.py | Shows how live user activity becomes a personal ranking and how that ranking is cached. |
| backend/…/diversity.py | Defines the shared series and platform diversity behavior. |
| backend/…/serving.py | Connects ranking, hydration, permission filtering, visibility-aware depth, and final result limits. |
| backend/…/recommendation.py | Defines the persisted relationship and reason data. |
| backend/…/build_recommendations.py | Defines scheduled and manual full index rebuilds. |
| backend/…/recommendations.py | Defines the personal feed API contract. |
| backend/…/__init__.py | Defines the catalog-facing similar-games route. |
| backend/…/recommendation.py | Defines the score, reason, and seed fields returned to clients. |
| frontend/…/Home.vue | Shows the personal feed as a home catalog surface. |
| frontend/…/OverviewTab.vue | Shows the similar-games shelf in the game detail view. |
| frontend/…/similarityReasons.ts | Maps backend reason facets to user-facing icons and labels. |
| Catalog data and API operations | Related page for the broader catalog API and response contracts. |
| Library scanning and filesystem handling | Related page for scan changes that trigger recommendation updates. |
| Metadata enrichment | Related page for the metadata that supplies recommendation facets. |