Files
romm/backend/handler/database/__init__.py
Sam Dornan 399aec5c8b feat(backend): add a library-aware recommendations engine
Recommendations came straight from IGDB's `similar_games`, which mostly
names titles the server does not hold and is absent entirely for anything
IGDB never matched.

`rom_similarity` holds a precomputed item-item graph blending four signals:
IDF-weighted metadata overlap, the IGDB prior resolved against the library,
collection co-membership and co-play. Scores are library-relative, so a
shelf full of arcade games learns on its own that "Action" says nothing
while "Metroidvania" says a great deal, with no tuning.

Each edge stores the facets that produced it, so the UI can explain a
recommendation rather than showing an unattributed row of covers.

Candidate generation runs off an inverted index with a document-frequency
cap, avoiding the all-pairs comparison. The graph is rebuilt wholesale by a
scheduled task because the IDF weighting shifts as the library grows, and
writes commit in batches so a task that dies leaves stale edges rather than
an empty table.

The personalised feed is ranked on demand from those edges plus live play
history, since a nightly feed would ignore the game played an hour ago.
Ratings below the scale midpoint act as negative seeds, results are
diversified per franchise and platform, and owned-but-unplayed games are
boosted.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-07 20:12:19 -05:00

36 lines
1.6 KiB
Python

from .client_tokens_handler import DBClientTokensHandler
from .collections_handler import DBCollectionsHandler
from .device_save_sync_handler import DBDeviceSaveSyncHandler
from .devices_handler import DBDevicesHandler
from .firmware_handler import DBFirmwareHandler
from .music_playlists_handler import DBMusicPlaylistsHandler
from .permissions_handler import DBPermissionsHandler
from .platforms_handler import DBPlatformsHandler
from .play_sessions_handler import DBPlaySessionsHandler
from .recommendations_handler import DBRecommendationsHandler
from .roms_handler import DBRomsHandler
from .saves_handler import DBSavesHandler
from .screenshots_handler import DBScreenshotsHandler
from .states_handler import DBStatesHandler
from .stats_handler import DBStatsHandler
from .sync_sessions_handler import DBSyncSessionsHandler
from .users_handler import DBUsersHandler
db_client_token_handler = DBClientTokensHandler()
db_collection_handler = DBCollectionsHandler()
db_device_handler = DBDevicesHandler()
db_device_save_sync_handler = DBDeviceSaveSyncHandler()
db_firmware_handler = DBFirmwareHandler()
db_music_playlist_handler = DBMusicPlaylistsHandler()
db_permission_handler = DBPermissionsHandler()
db_platform_handler = DBPlatformsHandler()
db_play_session_handler = DBPlaySessionsHandler()
db_recommendation_handler = DBRecommendationsHandler()
db_rom_handler = DBRomsHandler()
db_save_handler = DBSavesHandler()
db_screenshot_handler = DBScreenshotsHandler()
db_state_handler = DBStatesHandler()
db_stats_handler = DBStatsHandler()
db_sync_session_handler = DBSyncSessionsHandler()
db_user_handler = DBUsersHandler()