Queuecumber architecture

Status: proposal, awaiting approval. Decisions already made are referenced by their itsaplan issue (POD-n).

Constraints

  • iPhone, iPad and CarPlay, iOS/iPadOS 26+ (current and previous major), SwiftUI. The iPad app also runs on Apple silicon Macs (“Designed for iPad”).
  • UI in English to start; all strings localisable from day one.
  • Everything works offline and on-device. No Queuecumber server.
  • No analytics, crash reporting or other third-party SDKs. The only planned dependency is GRDB (MIT).
  • Optional iCloud sync (POD-1). Turning it off must leave a fully working app.
  • Open source, MPL 2.0.

Modules

One local Swift package, QueuecumberKit, holds everything that isn’t UI, so it can be tested without a simulator UI:

Target Responsibility
Storage GRDB database, schema migrations, record types
Feeds Fetch and parse RSS/Atom + Podcasting 2.0 tags, conditional GET, URL normalisation
Queue Ranking and queue maintenance (pure functions over records)
Downloads Background URLSession, download policy, storage cap, cleanup
Sync CKSyncEngine mapping between local records and CloudKit
Search Podcast Index / Apple search clients (POD-11)
Import Shortcut hand-off and OPML import/export (POD-2)

The app target holds SwiftUI views, the player, and the CarPlay scene.

Player:

  • Built on AVPlayer, with Now Playing and remote commands. It plays audio and video episodes; video gets an inline player and Picture in Picture.
  • CarPlay is audio-only by Apple’s rules, so a video episode plays its sound in the car.
  • v1: playback speed per show and a sleep timer.
  • Audio goes through an audio-processing tap from the start, so silence trimming and volume levelling can be added later without rebuilding the player.

The feed parser is our own, built on Foundation’s XMLParser, rather than a third-party feed library.

Data model

All IDs are deterministic, so two devices create the same IDs for the same show and episode without talking to each other:

  • podcast key = SHA-256 of the normalised feed URL;
  • episode key = podcast key + SHA-256 of the item <guid>. If there is no GUID, the enclosure URL is used instead.
Table Key fields Synced
podcast key, feedURL, title, author, artworkURL, podcastGUID, etag, lastModified, lastRefreshAt, downloadPolicy (followQueue / always / never), alwaysMaxEpisodes (default 3), playbackSpeed (default 1.0), subscribedAt Subscription, title, downloadPolicy, alwaysMaxEpisodes and playbackSpeed
episode key, podcastKey, guid, title, publishedAt, duration, enclosureURL, enclosureLength, mimeType, summary No. Rebuilt from the feeds on each device
playState episodeKey, position, completedAt, lastPlayedAt Yes
listeningEvent id, episodeKey, podcastKey, kind (started, finished, skipped, abandoned, removedFromQueue, movedUp, movedDown), at, position Yes (append-only)
queueEntry episodeKey, position, origin (auto / manual), pinned Only in shared-queue mode (see Sync)
download episodeKey, state, localFile, bytes, origin (auto / manual), finishedAt No. Device-local

Device settings (Wi-Fi only, auto-download, X, cap, manual-download expiry, autoplay, search provider, sync on/off, shared queue on/off) live in UserDefaults and are not synced.

Sync (when enabled)

  • CKSyncEngine against the user’s private database, in a custom zone Library. CloudKit container: iCloud.dk.queuecumber.app.
  • Record types: Subscription, PlayState, ListeningEvent, SharedQueue. Episodes are never uploaded; each device rebuilds them from the feeds.
  • Queue mode is a per-device switch:
    • Shared queue: the device joins one queue shared by every device that has it switched on. That queue is a single SharedQueue record holding the ordered episode keys, manual edits and pins. Whichever device re-ranks or edits it writes the new order.
    • Separate queue (default): the device keeps its own queue, ranked locally. Listening history still syncs, so the show affinity is learnt from everything you hear, while the order and manual edits stay on this device.
  • Conflicts are resolved per record type:
    • PlayState: the most recent lastPlayedAt wins.
    • Subscription: last writer wins per field.
    • ListeningEvent: append-only, so it cannot conflict.
    • SharedQueue: last writer wins for the order. Manual edits from both sides are merged before the losing side re-ranks, so a manual change is never silently dropped.
  • Growth: events older than 180 days are compacted into per-show totals, locally and in CloudKit.
  • Turning sync off stops the engine and keeps local data. A separate “Remove iCloud data” button deletes the zone.

Feed refresh

  • Conditional GET (ETag / If-Modified-Since), with a per-show backoff for shows that rarely publish.
  • Triggers: app open, CarPlay connect, BGAppRefreshTask (iOS decides the timing), and pull to refresh.
  • No cleartext. A plain http:// feed is upgraded to https:// and tried there. If that fails, the show is marked broken and the user is told why (“This feed is only available over an insecure connection”). There is no App Transport Security exception, for feeds or for episodes.
  • Requests carry no cookies and no identifiers, and use a Queuecumber/<version> User-Agent.

Queue ranking v1

Plain, explainable rules, with no on-device ML yet. Each new or unplayed episode gets a score:

  • Show affinity: finished minus abandoned/skipped episodes of the show, decayed over about 60 days. Manual “move up” and “move down” count as extra signal.
  • Freshness: decays with the episode’s age; news-like shows (daily cadence) decay faster.
  • Continuity: episodes already started rank high; for serial shows, the next episode in order follows the last finished one.
  • Pins: pinned shows always go first. Manual queue edits are kept and never reordered by the ranking.

The app can show the user why an episode is where it is (“You finish most episodes of this show”).

Downloads (POD-3 decisions)

  • Background URLSession for downloads. Wi-Fi only maps to allowsCellularAccess / allowsExpensiveNetworkAccess.
  • Auto-download (on by default) keeps the top 5 queue entries downloaded. Per-show always / never override this.
  • 5 GB cap. When full, fewer episodes are downloaded; nothing in the top 5 is deleted to make room.
  • An auto-downloaded episode is removed 24 h after it stops being wanted:
    • it has been played to the end;
    • it was skipped or removed from the queue;
    • it has been ranked below the top 5.

    If it climbs back into the top 5 within those 24 h, it stays.

  • Manual downloads and “Always download” shows follow the same rules:
    • removed 24 h after they’re played;
    • an unheard one is kept until played, unless “Keep manual downloads for X days” is switched on (off by default; X = 7 when switched on). Then it is removed X days after it was downloaded, heard or not.
  • “Always download” shows also have a per-show maximum (default 3 episodes). Only the newest N unheard episodes are kept; older ones are removed 24 h after dropping out of the newest N.
  • Unsubscribing removes all of the show’s downloads 24 h later, so an accidental unsubscribe can be undone.

So every download has a cleanup path.

Network calls (for the privacy policy)

  1. The feeds and episode files the user subscribes to, fetched directly from their hosts.
  2. Search queries to the chosen provider (POD-9).
  3. The user’s own iCloud private database, if sync is enabled.

Nothing else.

Decided in review

  1. Cleartext: http:// feeds are tried over https, otherwise reported as broken. No ATS exception.
  2. Queue order across devices: a per-device switch between a shared queue and a separate one (see Sync).