Skip to main content

Data — sources, articles and feed items

Rendered from corpus/wiki/data-reader.md · updated 2026-10-09

This page is generated from the project corpus and rewritten on every docs build. Edit the source in corpus/, not here.

Split out of data.md on 2026-10-09, when the Reader work (2026-10-09) added feed_items. Same database, same schema version (6); the routes over these tables are in api-reader.md.

sources​

ColumnTypeNotes
idTEXT PKslug, e.g. bbc
nameTEXT NOT NULL
rss_urlTEXT NOT NULL UNIQUE
enabledINTEGER NOT NULL DEFAULT 1
created_atTEXT ISO-8601
categoryTEXTthe Reader's grouping; NULL = uncategorized (v6)
etag, last_modifiedTEXTthe feed's last validators, sent back on the next refresh (v6)
last_fetched_atTEXT ISO-8601set only when a refresh got a 200 or a 304 (v6)
last_errorTEXTwhy the last refresh failed; NULL once one succeeds (v6)

Sources moved out of data/sources.json and into the DB in v3. The migration seeds this table from that file once, for the default installation DB only; nothing reads the JSON afterwards. The validators never leave the server.

articles​

The library: only saved articles. A search result or a Reader item is not a row here until the user saves it.

ColumnTypeNotes
idINTEGER PK
source_idTEXT → sources(id) ON DELETE SET NULLNULL for manual or orphaned
source_nameTEXT NOT NULL DEFAULT ''denormalized snapshot, survives the source being deleted
guidTEXT NOT NULLthe item's URL (the feed guid only for rows saved before v6)
titleTEXT NOT NULL
urlTEXT
bodyTEXT NOT NULL DEFAULT ''
published_atTEXT ISO-8601
saved_atTEXT ISO-8601
noteTEXT NOT NULL DEFAULT ''why it was kept (v6); set on first save, then only by PATCH /api/articles/:id
UNIQUE (source_id, guid)

Index: idx_articles_saved_at on (saved_at). SQLite treats NULLs as distinct, so the repository dedupes source-less articles on guid explicitly.

feed_items​

The Reader's stored entries (v6, 2026-10-09). An item becomes an articles row only when saved, and the two share the key (source_id, guid), so "is this item saved?" is a lookup.

ColumnTypeNotes
idINTEGER PK AUTOINCREMENTnever reused, see below
source_idTEXT NOT NULL → sources(id) ON DELETE CASCADE
guidTEXT NOT NULLthe item's link
titleTEXT NOT NULL DEFAULT ''
urlTEXT NOT NULL
authorTEXT
content_htmlTEXT NOT NULL DEFAULT ''the feed's HTML, unsanitized, capped at 256 KB
content_textTEXT NOT NULL DEFAULT ''that HTML stripped: what the filter searches
published_atTEXT ISO-8601as the feed dated it; NULL when undated or unparseable
fetched_atTEXT ISO-8601 NOT NULL
sort_atTEXT ISO-8601 NOT NULLthe timeline position: the earlier of published_at and fetched_at
read_atTEXT ISO-8601NULL = unread
UNIQUE (source_id, guid)

Indexes: idx_feed_items_sort on (sort_at DESC, id DESC), the list's keyset; idx_feed_items_source_read on (source_id, read_at), the counts.

  • Keyed on the link. guid is the item's URL rather than the feed's <guid>, because it is the key Search already writes into articles.guid. A second refresh inserts nothing it already has (ON CONFLICT DO NOTHING), and an item with no http(s) link is not stored at all.
  • Dated defensively. An undated item is kept and sorts at its fetch time; a future-dated one sorts at its fetch time too, so a feed cannot pin an item to the top. rss-parser reads the body from content:encoded, then content, then summary.
  • Capped, then sanitized late. The HTML is stored as the feed sent it, cut at 256 KB on a UTF-8 boundary, and sanitized only in the browser, at render (dependencies.md). The list never carries it.
  • AUTOINCREMENT on purpose. Mark all read takes an upToId. That only means "everything the list had loaded" if a purged id is never handed out again, which plain INTEGER PRIMARY KEY does not promise.
  • Purged after each refresh. An item older than READER_RETENTION_DAYS (by fetched_at) is deleted, except each source's newest 50 by sort_at, so a quiet feed never empties. Saved articles are untouched: they are their own rows. Deleting a source deletes its items.