Files
k-tv/crates/docs/adr/0001-library-as-single-source-of-truth.md

1.3 KiB

ADR-0001: Library as single source of truth for media

Status

Accepted

Context

The system originally had two representations of media: MediaItem (fetched live from providers at schedule-generation time) and LibraryItem (cached in the local database for browsing). The schedule engine bypassed the library entirely and queried providers directly, creating a tight coupling to provider availability and duplicating the concept of "a piece of media."

Decision

The local library is the single source of truth for all media in the system. Providers (Jellyfin, Plex, local files, YouTube, etc.) are sync sources only — they feed items into the library, but are never queried at runtime by the schedule engine.

One unified type — MediaItem — lives in the library. The schedule engine queries the library, not providers.

Consequences

  • Schedule generation works even when a provider is offline.
  • No more two-type split (MediaItem vs LibraryItem) — one concept, one type.
  • Provider adapters become sync-only: their job is to discover items and upsert them into the library.
  • Stream URL resolution still needs the provider at playback time (the library stores metadata, not video files). This is the one runtime provider dependency.
  • Filters (genres, decade, content type, etc.) operate on library data, not provider APIs.