Architecture
Stack
| Concern | Choice |
|---|---|
| Language/runtime | TypeScript 6.0 (strict, ESM, erasable syntax only), Node 24 LTS running .ts directly via native type stripping (no build step for Node packages), pnpm workspaces |
| HTTP server | Fastify 5, Zod type provider, @fastify/swagger (OpenAPI) |
| Database | PostgreSQL 18; Drizzle ORM; drizzle-kit SQL migrations |
| Jobs | pg-boss (Docker), SQS (AWS) |
| HTTP client | undici |
| Feed parsing | feedsmith (RSS, Atom, RDF, JSON Feed, OPML); htmlparser2 for feed autodiscovery |
| Content | sanitize-html; @mozilla/readability + linkedom |
| Auth | @node-rs/argon2, otpauth |
| Logging | Pino (JSON), with the active trace's ids |
| Observability | OpenTelemetry API and Node SDK (OTLP); @fastify/otel, pg-boss's built-in tracing, pg and Node runtime instrumentation; nodemailer for alert email. AWS: ADOT Lambda layer to X-Ray, SNS, AWS Budgets |
| nodemailer: SMTP; on AWS its SES transport (SES v2 API) | |
| Web | Vue 3, Vite, Vuetify 4, Pinia, Vue Router, TanStack Vue Query, vue-i18n |
| Desktop | Electron, esbuild, electron-builder |
| Mobile | Capacitor (Android) |
| Tests | Vitest (v8 coverage), Testcontainers (Postgres), Playwright, axe-core (WCAG 2.2 AA scans in the Playwright suite) |
| Infrastructure | AWS CDK (TypeScript) |
| CI/CD | CDK Pipelines (CodePipeline + CodeBuild) defined in infra/; no GitHub workflows |
Repository layout
Workspace packages exist only where runtime or toolchain differs.
| Path | Contents |
|---|---|
server/ | Server code: Docker image roles and Lambda handlers (Node) |
web/ | Vue SPA (PWA), built by Vite |
desktop/ | Electron shell around the web build |
mobile/ | Capacitor shell around the web build |
shared/ | Zod schemas, API types, typed API client (browser and Node) |
plugin-api/ | @newses/plugin-api: the contract plugins are written against (definePlugin, secret(), url(), multiline(), and feeds(), context, hook, and storage types, STORAGE_LIMITS, PLUGIN_API_VERSION); zod is a peer dependency, so settings schemas use the server's copy |
infra/ | CDK app: stage stacks, per-stage deploy and release pipelines, release buildspecs |
docker/ | Dockerfile, compose.yaml, .env.example, reverse-proxy examples, the apps build (compose.apps.yaml, apps.Dockerfile, apps-build.sh) |
server/src layers. ESLint enforces the allowed imports.
| Folder | Contents | May import |
|---|---|---|
core | Domain services (feeds, entries, filters, search, auth) and port interfaces; no framework or cloud SDK imports | db, shared |
db | Drizzle schema and migrations | shared |
adapters | Port implementations (pg-boss, local FS, S3, SSE, SMTP, instrumented fetcher, …) | core, db, shared, telemetry |
api | Native REST, TTRSS-compatible and Google Reader routes, SSE endpoint | core, db, shared, telemetry |
telemetry | OpenTelemetry helpers, instruments, SDK preload, Fastify tracing | shared |
importer | TTRSS importer | core, db, shared |
plugins | Plugin host: registry, plugins' network access, hook runner; implements the core ports that run hooks | core, db, shared, telemetry |
entrypoints | server, worker, migrate, cli, and lambda/ handlers — wire adapters into core | anything |
Runtime model
- Docker: one container image, role selected by command:
server,worker,migrate,cli. - AWS: Lambda handlers
api,tick(dispatch with push, queueing digests, plugin deliveries, alert checks, and kept images; purge, auth prune, archive compaction),fetch,favicon,extract,plugin,digest,migrate, bundled by esbuild; each reads the database password parameter once per cold start.
Rules:
- Server is stateless; sessions live in Postgres.
- No local-disk state outside
BlobStore. - Migrations run as a one-shot
migratecommand (on AWS, a function invoked before each deployment's functions update), guarded by a Postgres advisory lock. It loads no plugins: their startup writes to tables the migrations may not have made yet. - Database connections time out after 10 s and idle transactions after 60 s. The server role also limits statements to 30 s and lock waits to 10 s, so requests fail instead of hanging.
- The server logs a warning, with pool usage and the longest event-loop delay, for responses slower than 2 s and for requests the client abandons before a response.
buildApp()constructs the Fastify app without listening, so it can be mounted bylisten()or a Lambda adapter.- The SPA is a standalone static build and talks only to the API.
- Clients treat realtime as optional and poll counters when no stream is available, or the user's change marker when the server gives one.
Ports
| Port | Responsibility | Self-hosted | AWS |
|---|---|---|---|
JobQueue | Enqueue and consume jobs with retries; optional dedupe by key | pg-boss | SQS (no dedupe), consumed by Lambda |
Scheduler | Periodically dispatch due feeds and purges | In-process timer in worker | EventBridge Scheduler |
BlobStore | Favicons, cached images, archive files | Local volume | S3 |
ArchiveWriter | Write entries to the cold-storage archive | Parquet through BlobStore | Parquet through BlobStore, catalogued in Glue for Athena |
ArchiveReader | List, search, and get archived articles; compact the archive | DuckDB in-process, over the local blob directory | Athena over the Glue table |
Realtime | Publish per-user invalidation events from any process; server streams them to clients over SSE, or gives the path of a marker they poll | Postgres LISTEN/NOTIFY | Change markers in the blob bucket, served by CloudFront; the stream answers 204 |
Config | Settings and secrets | Environment | Environment and SSM Parameter Store |
Logger | Structured logs | Pino | Pino |
Notifier | Tell operators when alerts open or resolve | Email over SMTP, when configured | The stage's SNS alert topic |
Mailer | Email users | nodemailer over SMTP, when SMTP_URL is set | nodemailer's SES transport with the stage's configuration set (MAIL_SES_CONFIGURATION_SET) |
PushSender | Deliver encrypted Web Push messages to the push services devices subscribed with | Web Push over HTTPS | Web Push over HTTPS |
Web app
Folder (web/src) | Contents |
|---|---|
views | Route pages: login, signed-in layout (feed tree drawer, dialogs), reader, archive, settings |
components | Reader (tree, headlines, combined list, article), dialogs, settings panels |
composables | Server state (TanStack Query), live counters, shortcuts, session |
lib | Pure logic: stream keys, tree building, shortcut matching, reordering, cache patches |
offline | Connectivity, and the per-account local store (IndexedDB through Dexie) |
platform | Platform bridge and the apps' server and token |
stores | Pinia store for UI state only (drawer, dialogs, notices) |
- Routes:
/connect(apps only),/login,/settings/:tab,/:stream/:entry?,/:stream/archive/:key?(allor a subscription), and/publish?url=&title=&text=,/subscribe?url=, and/share?title=&text=&url=, which fill in the Publish or Subscribe dialog, or offer the shared page to subscribe to or publish (its address is the first one intextorurl), then show All articles; they never act on their own. The Settings → Sharing bookmarklets open the first two for the current page (its title and up to 2,000 characters of selected text) in a small window from the server's origin, which closes once the page is published. Streams areall,fresh,starred,published,read,f<subscription>,c<category>(c0uncategorised),l<label>,t<tag>(URL-encoded); search is?q=. - The archive view lists past articles read-only. Star, Publish, Labels, and Add note restore the article (the last two read, then open their dialog on it) and open it in its feed. It is reached from a subscription's or All articles' toolbar, and from a search, which it repeats over the archive.
- Server data lives in the TanStack Query cache. Article changes (flags, score, catch-up, note, labels, tags) patch every cached copy, then save; a refusal restores the previous values. Without offline reading, a failure to reach the server does too. Headline lists are not refetched when entries change state, so read entries stay in place until the list is reloaded.
- With offline reading on, headline lists, entries, and the snapshot queries fall back to the store when the server cannot be reached, and without a network do not ask it. Stored lists follow the server's stream rules (subcategories, Fresh window, low scores hidden where the server hides them, feeds hidden from All) and page by offset. Without the server, search covers the store: titles, authors, and feed names of stored entries and their stored text (HTML stripped), as words folded to lower case without accents, CJK as character pairs, in multi-entry
wordsindexes onentriesandcontents; every group of alternatives (OR) must match, a term when all its words do, the last one typed also as a prefix, and a negated term when they do not. A word also matches stored words with the same stem (@orama/stemmers, loaded per language) in the languages of the stored entries and the device; operators filter the stored entries as the server does, with dates in the device's time zone; newest first. Content is indexed as it downloads, older content in batches after a sync; the index counts toward the storage limit, and settings show its size. A stored entry whose content is its latest version opens without a request. - Connectivity is online, offline (the shell reports no network), or unreachable: a request failed at the network, took over 45 s to answer, or got 502–504. Any other answer makes it online. While unreachable,
GET /serverchecks again after 5 s, backing off to once a minute, and at once when the network returns or the app resumes. Queries pause and are not retried unless online; the first session check still runs, so the app can say the server is unreachable, and it reloads once the server answers. - The local store is one IndexedDB database per account (
newses-<user>, in the appsnewses-<server hash>-<user>);localStorageremembers the last account, and in the apps each profile's, with the profile's offline settings and last theme. In the browser, signing out or another user signing in deletes the previous account's store; in the apps a profile keeps its store while the app runs on another, and signing out deletes it. When the server ends a session without a sign-out here (a 401, found by the page, the service worker, or the Android job), what a reader could see goes: the store keeps only changes not yet sent, which the same user sends after signing in again, when it downloads again; with none, it is deleted too. - Offline reading is on in the apps, and in a browser once turned on for the device. Against API 1.1 or later the app keeps the store current. The first sync takes
/sync/token, then the unread (up to the device's setting: 1,000, 5,000, or 10,000; All's first, then each feed hidden from All), starred (2,000), and Recently read (2,000) headlines, the lists, preferences, themes, counters, tags, and the session without its CSRF token; later syncs follow/sync, and a410, or keeping more unread entries, loads everything again. Syncs run at launch, on resume, when the server answers again, when counters change, and every 15 min (30 while hidden, then only where counters are polled in the background); one tab runs them at a time. - The store keeps unread and starred entries and those read in the last 7 days; past each limit the oldest go, and content and images no other stored entry shows go with it.
- After each sync, the content of stored entries without a current copy (unread newest first, then starred, then recently read) downloads 100 at a time through
POST /entries/contents, then their images through the image proxy: two at a time, one per image host, up to 4 MB each in 60 s, failures retried after 24 h, and on Android only on Wi-Fi unless set otherwise. Content and images together stay under the device's limit (256 MB, 1 GB, or 4 GB; in the apps per profile, 1 GB for the first and 256 MB for later ones); past it, images and then text of the lowest-priority entries go. In the apps, Settings → Account shows what each profile's store takes and removes its downloaded data; Offline settings shows all profiles' total from the storage estimate and warns when their limits together pass the quota; the apps ask for persistent storage at launch. - Stored images show from the device, online too, matched by their original URL whether or not the content was proxied; an entry's content renders once they are looked up or after 1.5 s (those found later then replace the others), and without a connection its other images have no source. Without offline reading, opening or scrolling past entries offline does not mark them read. Stored content is served to readers who proxy images with every image at its proxy path, and without the ones that have none.
- With offline reading on, article changes made while the server cannot be reached, before the session is confirmed, or behind changes already waiting go to the store's outbox and the stored entries; counters are adjusted as the server will count them. Waiting changes are merged per entry and flag, keeping each catch-up in its place; an offline catch-up applies to the stored entries and is sent with the newest stored id as
maxId. Each change records what the entry had before it. Each sync first sends them, oldest first, equal flag changes in bulkPATCH /entries(up to 1,000). Against API 1.2 they are compare-and-set: flags carryexpect, labels and tags go as added and removed, and notes carryexpected; changes the server kept for newer values are counted for the reader, and a note changed elsewhere too asks the reader to keep their own, keep the server's, or copy their own and keep the server's. Older servers have changes replaced as they are. A failure to reach the server retries after 2 s, doubling to 5 min; a 429 waits forRetry-After; a 401 waits for sign-in; a 404 drops the change, except labels, sent again without the labels that are gone; other refusals drop it and tell the reader. Entries from the server, synced or listed, show the changes still waiting for them. Signing out with changes waiting asks first. - Preferences, categories (create, rename, move, collapse, delete), feeds (subscribe, rename, move, settings, unsubscribe), labels, and themes (create, edit, publish, delete, import) change offline the same way, shown at once in the cached lists, which show waiting changes over both the server's and the store's copies. Objects created offline get negative ids; once the server creates one, waiting changes, stored entries' labels, and the
appearanceThemepreference take its id. Deleting one before it is sent forgets it and the changes to it: its feeds and subcategories go to its parent, entries lose the label, a theme in use falls back to Original. A refused create does the same and tells the reader; a page offering several feeds asks to subscribe again; a theme name taken meanwhile gets a number, a label caption taken meanwhile means that label, and a refused theme stays as a draft in Appearance to export. Feeds and categories not yet sent are marked in the tree, labels and themes in their settings; a feed opens once subscribed. Fetching feeds, OPML, filters, sharing, and account settings need the server. - Settings → Plugins shows for admins, and for others where
GET /serversays plugins are installed; its changes need the server. - A status in the corner (
role="status") says when the app is offline or the server unreachable, with the changes waiting and the last sync; while online, that changes are being sent, and briefly that the connection is back. Share, full-text extraction (stored full text still shows), and the archive say they need a connection when used offline and are markedaria-disabled. - The Offline settings tab holds the device's choices (unread entries kept, images, Wi-Fi only on Android, storage limit, sync while closed) in
localStorage, what the store holds, changes waiting, the last sync and its error, Sync now, and Clear, which deletes the store and downloads it again. In a browser a switch turns offline reading on for the device, asking the browser to keep the storage, and off, which deletes the store; it says whether the browser keeps the storage and, in Safari on iOS, to add the app to the Home Screen. Synced changes patch cached lists and entries, and headline pages loaded online are written to the store. - The snapshot queries (session, preferences, subscriptions, categories, labels, counters, tags, themes) are copied to the store whenever they load, and the first sync writes them before any headlines; the session is also written once the route guard knows the account. When the server cannot be reached, the app starts from them, seeded as stale; once it answers, the session is checked again, and a 401 signs out.
- Entries scored above the user's
scoreHighlightAboveget a highlight bar and a bold score. - Opening an entry marks it read once. Combined layout can mark entries read as they scroll above the top, saved in one request per second.
- Counters refetch on
countersevents. Without a stream they are polled every 60 s, paused while the page is hidden; a closed stream is retried every 5 minutes. - Below 900 px one pane shows at a time; below 700 px secondary toolbar actions move into a menu.
- A theme is a set of tokens (
shared/src/themes.ts): style, light and dark palettes, UI and article fonts as keys, UI text scale, corners, density, borders, shadows, and effects. Built-in themes are inshared, with the API minor each, and each style and font, arrived in; theappearanceThemepreference names one, or a custom theme's id, andthemeAdjustmentsholds the reader's partial overrides. Thethemepreference is the mode: light, dark, or the system's. - A theme resolves as its built-in base, then its overrides, then the reader's adjustments; a reference that no longer resolves, or a built-in this app doesn't have, shows Original. The result replaces the colours of Vuetify's
lightanddarkthemes in place, provides Vuetify defaults around the routes, and sets--v-font-body,--ui-font-scale,data-theme-style, anddata-effectson the document root. - Styles other than
standardare stylesheets inweb/src/themes/, unlayered so they override Vuetify's layers, scoped bydata-theme-style, and aimed at app-owned classes where possible. Decorations are generated content with empty alternative text.data-effectsturns on textures and animation; animation stops under reduced motion and effects under forced colours. Sketch's lines wobble through an SVG filter on frame pseudo-elements, never on text or list rows. E-ink stops every transition and animation (Vuetify's scripted ones, and its ripples, through its defaults), leaves out hover tints and dimming scrims, and keeps text at full strength. Synthwave takes its blue from the surface; its sunset and grid stay in the app bar, behind its content, and its tints there and on the open feed are faint enough that text keeps AA contrast. Noir's texture jitters titles (app bar, article heading) letter by letter, each turned and raised by an amount fixed per letter, throughJitterText: only in scripts whose letters stand apart (Latin, Greek, Cyrillic), with the plain text for screen readers. - Against a server older than a built-in theme's, style's, or font's API minor, Appearance and Reading leave it out, and importing a theme that uses one says the server needs updating; until the server answers, all show.
- Palette contrast checks (built-in theme tests, and warnings while adjusting) count text as secondary text shows it, faded to Vuetify's medium emphasis.
- Custom themes export as JSON
{ format: 'newses-theme', version: 1, name, base, tokens }; importing posts the file's theme to/themes, so the server validates it, and numbers a name already taken. - The last resolved tokens are kept in
localStorageand applied before mounting, so a reload starts with the reader's theme and signed-out screens use it. - Reading preferences (font, text size, line width) set CSS custom properties on the document root that article styles read; the
defaultfont is the theme's article font, and the text size is kept under the theme's scale. LOCALESinsharedlists the shipped languages. Thelanguagepreference (API 1.7) holds a language tag, any tag so that a server never refuses an app's newer language, and null follows the device. Before mounting, the app shows the last choice kept per profile inlocalStorage, else the first ofnavigator.languageson offer (es-MXases), elseen, and setslanganddiron the document root; signed-out screens stay on that. Signed in, the preference replaces it, and is fetched again each time the app regains focus. Against a server older than API 1.7, where/prefshas nolanguage, the choice stays on the device and is never sent.enand its Vuetify strings are always loaded and fill any gaps. Other languages are lazy chunks, which the service worker precaches and the native build bundles; one that fails to load leaves the current language. Vuetify's text and direction follow throughcreateVueI18nAdapter.t(), on the one composeruseI18n()returns, formats numeric parameters for the language, and isolates text parameters with FSI and PDI in a right-to-left language or when they hold right-to-left text. Titles sort withIntl.Collatorin the app's language.- Right to left, icons listed in
web/src/lib/mirrored-icons.tsflip with CSS, and the desktop's window controls keep their side. Code, media controls, URLs, one-time codes, and patterns stay left to right. Theme fonts bundlelatinsubsets only; other scripts use system fonts. - Article bodies, excerpts, and titles take their direction from their text (
dir="auto") and carrylang, from the entry'sxml:lang,dc:language, or JSON Feedlanguage, else its feed's (RSS<language>). A language a changed entry no longer gives is kept. - Fonts are system font stacks, except the theme fonts Patrick Hand and IBM Plex Mono (latin subsets), which are bundled and served from the app's own origin. A browser downloads one only when text uses it; the service worker caches fonts when first used rather than precaching them, and with offline reading on, the first sync of a page loads all of them so themes render offline.
- Shortcuts follow TTRSS's defaults, including two-key chords (
g a) with a 1.5 s window. They are ignored in text fields and while a dialog is open. On a non-Latin layout, a key not bound itself acts as the Latin letter at its position. - The
shortcutBindingspreference holds only changed actions; each replaces that action's defaults, and[]unbinds it. A key cannot be bound alone while it starts a chord. - PWA: the manifest's
share_target(GET/share) puts installed apps in the system share sheet. The service worker (web/src/worker/sw.ts, WorkboxinjectManifest) precaches the app shell only; API requests always go to the network. Feed icons (/favicons/*) are cached when first shown (up to 500), so they show offline; signing out or the session ending deletes them. It is checked with the worker's globals (web/src/worker/tsconfig.json), so the offline modules it runs import neither Vue nor the DOM. - With offline reading on, installed Chrome and Edge apps sync with no window open: Periodic Background Sync (
newses-sync, at least 30 min, when the browser grants it to the installed app) sends waiting changes, follows/sync, and downloads text; Background Sync (newses-outbox, registered when a change is kept) sends waiting changes when the connection returns. The page hands the worker the account's store and the device's choices in a smallnewses-workerdatabase, as it has nolocalStorage; it confirms the session (and gets the CSRF token) first, and when it has ended clears what a reader could see and stops until a page signs in again. What it could not send is reported by the next page that opens. Tabs and the worker share the Web Locks, so only one syncs. Other browsers sync while the app is open, and the Offline settings say which applies. - New-entry notifications in browsers (off by default, per browser and user; Settings → Account → Notifications, shown where the browser has Web Push and the server gives
push.key; on iPhone and iPad it asks for the app to be added to the Home Screen): turning them on asks for the permission, subscribes with the server's key (userVisibleOnly), andPUTs the subscription; turning them offDELETEs it and unsubscribes. Each launch binds the subscription to the session again, subscribing again when the key changed, and unsubscribes one another user turned on or that a server withoutpushno longer takes. Signing out here unsubscribes; a session the server ended keeps the subscription for the same user's next sign-in. The page hands the worker the user and the notification's messages in the app's language (as Android's job gets them) innewses-worker, again when the language changes. - The worker shows each push message (
asPushMessagechecks it) as one notification (tagnewses-new-entries), added to the one still showing as a running total, worded with those messages, silent while a window is visible; then, with offline reading on, it syncs as Periodic Background Sync does. Clicking it focuses a window and has it open the stream (newses-navigatemessage), or opens one there. A window becoming visible closes it, so the next counts from then.
Native build (build:native, web/dist-native), bundled by the desktop and mobile apps:
- No service worker.
NATIVE_CSP(shared/src/web-csp.ts) is in a<meta>:WEB_CSPwithconnect-src https:, because the server is chosen at runtime. - The shells set
window.rssReaderBridge(web/src/platform/bridge.ts) before the app's scripts run: server profiles (a server and a user each, one active) with each profile's bearer token in secure storage, open in the system browser, share a link (the share sheet, else a new mail with no recipients; the browser usesnavigator.share, else amailto:link), save a file, notify, app version, update status, network status (and on Android whether it is Wi-Fi), and refresh requests (resume, unlock, the tray; Android's return to the foreground). An update that is ready or available prompts once per version per launch; settings shows the version, the update status, and Check for updates. The web build uses a browser stand-in; the native build outside a shell keeps profiles and tokens in memory. - Profiles are named by the reader's label, else
login @ server: the server's instance name, kept with each of its profiles and updated when the app checks the server at launch, or else its host, with an initial on a colour from the profile's id. A profile menu at the top of the drawer, and "Use another profile" on the sign-in page and the unreachable-server screen, lists them (signed-out ones marked) to switch to, and opens the connect screen to add a server. Settings → Account lists them to switch to, rename, or remove; removing asks first, saying how many changes not yet sent are lost, then deletes its store and settings and revokes its session. Sign-in fills in the profile's login. - The connect screen ("Add a server" once a profile exists) opens on first run, from "Add server", and from "Change server" while there is one profile (sign-in page, unreachable server). It takes an HTTPS origin and checks
GET /api/v1/server: another product or API major is refused, an older minor warned about. Another server moves the app to that server's profile, a signed-in one first, or to a new one; the profile left keeps its session and store. Moving to another profile waits for a sync or send in progress, stores what the Android job fetched, stops background sync, then reloads the app on the new profile. - Sign-in asks for a bearer token, which the bridge keeps for the active profile; the login request carries no token, so it ends no other profile's session. Signing in as another user than the profile's moves the app to that user's profile on the server, made if needed, and the profile left stays signed out. Any 401 forgets the token and returns to sign-in; signing out revokes the session, then forgets it.
- Feed icons load from
iconUrlon the server. A server before API 1.3 gives aniconUrlthat needs the session, which an<img>cannot send, so against one they load from the user'siconsPath(login and session responses; the signed/feed-iconspath). - Against a server before API 1.4 the feed dialog leaves out Pause updates, Hide from All articles, and the check interval.
- Server-relative URLs in entry content (proxied images, links) are made absolute against the server; public page links use the server's origin.
- The counters stream is read with
fetch, which can send the token; 204 or an error falls back to polling, and an ended stream reconnects after 5 s. - OPML export saves through the bridge. Links to other origins open in the system browser and never navigate the app.
- Every response carries
X-Content-Type-Options: nosniff, and HSTS (1 year) when the request arrived over HTTPS; API responses default toCache-Control: no-store. On AWS, CloudFront also adds HSTS to every response and a viewer-response function addscharset=utf-8to text responses from S3. - In the Docker image the server serves the build from
WEB_DIR, with a CSP (scripts from self only, frames from the sanitiser's video hosts),Referrer-Policy: no-referrer, and immutable caching of fingerprinted assets. Unknown non-API GETs returnindex.html. On AWS, CloudFront serves the build from S3 with the same headers, and a viewer-request function maps extensionless paths toindex.html.
Desktop app
desktop/: Electron for Windows and Linux (x64). esbuild bundles the main process and preload into out/, beside the native web build (out/web); electron-builder packages a per-user NSIS installer, a zip of the app (runs without installing; not updated by electron-updater), a portable exe, an AppImage, and a deb.
- The web build is served from
app://newses, a privileged standard scheme: client-side routes fall back toindex.html, and responses carry the native CSP as a header. The API sees that origin. - The window has context isolation, the sandbox, no Node integration, and no webviews. New windows are denied and navigation away from the app is blocked; http(s) links open in the system browser. The only
mailto:the app opens is the bridge's shared link, which the main process builds from a title, text, and http(s) URL. Only the notification and clipboard-write permissions are granted. - Fuses: no
RunAsNode,NODE_OPTIONS, or inspect arguments; the app loads only from its integrity-checked asar. - The preload exposes the bridge; the main process answers only frames on the app origin and validates arguments.
- The app's theme preference sets Electron's theme source:
systemfollows the OS (prefers-color-scheme), light and dark pin it. The window's background follows the appearance theme's, and the last one is kept in settings so a new window opens in it. - No native title bar: the app bar moves the window (an empty strip at the top on screens without one), and the window controls overlay its end (Window Controls Overlay, transparent), drawn in the appearance theme's text colour, also kept in settings. Open overlays and the narrow layout's drawer turn the drag area off.
settings.jsonin the user data folder (owner-only) holds the profiles, the active one, window bounds, and each profile's token encrypted withsafeStorage(DPAPI on Windows, the keyring on Linux). On Linux without a keyring (basic_text) tokens are kept in memory only, so each launch signs in.- Portable exe (
portabletarget): unpacks the app into a new temporary folder on each launch (unpackDirName: false) and deletes it on exit. WithPORTABLE_EXECUTABLE_DIRset, the app movesuserData(settings, the offline store, Chromium's data) toNewses Databeside the exe before taking the single-instance lock, or keeps the default when that folder cannot be written. On another PC or Windows user, DPAPI cannot decrypt the tokens, so each profile signs in again. - One instance at a time. Closing saves the window bounds unless the window is minimized or off every screen; they are restored while still on a screen, else the window opens centred on the primary screen. The menu (File, Edit, View) has no bar; its shortcuts work.
- WSLg places Linux windows itself, ignoring the bounds the app asks for, and does not report Windows-side moves or minimizing to the app. A window closed while minimized there reopens minimized and off-screen.
- New entries: while the window is hidden or unfocused, the main process shows one notification of the unread entries added to existing subscriptions since it went there ("12 new entries": the categories, most first). The first shows at once; it is then replaced with the running total, when that has grown, at most every 15 min, and closed when the window is focused. Clicking it opens the feed or category, or All; after a move to another profile it only shows the window. Hidden windows poll counters (on AWS, the change marker) every 30 min (the AWS dispatch interval) instead of pausing; resume, unlock, and the tray's Check now refresh at once. Notifications can be turned off.
- The tray and application menu use
desktop/src/locales, in the language the app reports (setLanguage), kept insettings.jsonfor menus built before the window runs; on first run, the system's. Each menu role has its label, as Electron's stay English. - Optional, in settings: keep running in the tray when the window closes (Open, Check now, with several profiles a Profiles submenu marking the active one, Quit; picking another shows the window and moves the app there), and start at login (
--hidden, straight to the tray when it is on; a login item on Windows, an XDG autostart entry on Linux; not offered by the portable exe). Desktop options live insettings.json. - Updates (release builds only; electron-updater on the stage's
/downloadsfeed): checked at launch and every 6 h. AppImages and signed NSIS installs (uninstaller beside the exe, publisher in the feed config) download in the background and install on restart or quit; updates must carry the same Windows publisher. A deb, the Windows zip, or the portable exe gets a link to the downloads page instead. Prereleases update to newer prereleases (semver order). pnpm devservesapp://newsesfrom the web app's Vite dev server in native mode, so the origin and bridge match the packaged app.
Mobile app
mobile/: Capacitor for Android, app.newses, served from https://localhost. android/ is committed.
buildassembleswww/from the native web build andbridge.js(the bridge bundled with the Capacitor plugins), loaded before the app's scripts, then syncs it intoandroid/.- Bridge: the profiles in Preferences; each profile's token in secure storage (AES-GCM with an Android Keystore key); links in Custom Tabs; files saved to the cache and offered through the share sheet; shared links through the share sheet, the title as the subject; status and navigation bar icons are light over a dark theme background, judged by its luminance rather than the mode.
- Background sync: the app's
BackgroundSyncplugin runs a WorkManager job every 30 min (every 4 h while the server's pushes arrive, see Push), needing a network (unmetered with images on Wi-Fi only) and a battery that is not low. It follows/syncfrom the store's token (at most 20 pages), then fetches the text of unread and starred entries that changed, keeping each response in app storage (at most 8 MB), tagged with the profile, without sending waiting changes. It runs for the active profile only: the bridge hands it that profile's id, server, and bearer token, which it keeps encrypted with its own Keystore key. On launch and resume the web app takes the pages fetched for the active profile, dropping any other's, and stores them in order, a sync page only when it carries on from the store's token, then hands over its token after each sync; a 401 stops the job until sign-in and deletes what it kept, and turning it off, signing out, Clear, offline reading off, leaving the profile, or another profile taking it over deletes what it kept. - New-entry notifications (off by default; Settings → Account → Notifications, which asks for
POST_NOTIFICATIONSon Android 13+ and stays off when refused): with them on, the bridge also hands the job the store's highest entry and subscription ids, each subscription's category and title, and the notification's messages in the app's language (the title per plural form, lists of one to three places, "and N more", the channel name), again when the language changes. From each/syncpage the job counts unread entries above those ids, outside subscriptions added since, as a running total; entries read or deleted since drop out. While the app is not on screen it shows one notification (channelnew-entries), worded as the desktop's, replacing the last: alerting when the total grew, quietly when it shrank, removed at none. Tapping it opens the feed or category, or All. Resuming the app removes it and starts the total again. - The back button closes the top dialog or menu, then the drawer, then goes back; at the start of the app's history it exits.
- The app draws edge to edge (the native build's viewport has
viewport-fit=cover):#appis inset by the safe areas (Capacitor's--safe-area-inset-*variables, elseenv()) and contains the layout, which scrolls inside it. - Push: with background sync on and a server that gives
push.key, the plugin registers with the reader's UnifiedPush distributor (org.unifiedpush.android:connector, no embedded FCM): the one chosen, else the only one installed; with several, Settings → Offline asks for one (the system's picker, else a list). The registration carries the server's key and is made again for a new key or distributor, after a failure or an unanswered request (10 min), and daily.NewsesPushServicetakes the distributor's endpoint and keys, whichPushSubscriptionWorkersends withPUT /push/subscriptionand the job's token, so it works with the app closed; a message that decrypts runs the job once, after any run in progress. While an endpoint is registered the timer runs every 4 h. Leaving the profileDELETEs its session's subscription and sends the endpoint with the new one's; turning background sync off, signing out, and offline reading off unregister. The distributor unregistering, or refusing, falls back to the 30-minute timer. Settings → Offline says through which distributor pushes arrive, or suggests installing one (ntfy, atpush.distributorwhen the server gives it). - HTTPS only (cleartext off), the permissions are
INTERNET,ACCESS_NETWORK_STATE, andPOST_NOTIFICATIONS(and those WorkManager adds: wake lock, boot completed, foreground service), and app data is not backed up (Keystore keys do not move between devices). - Share to the app: an
ACTION_SENDtext/plainfilter on thesingleTaskactivity; the app'sShareTargetplugin passes the text and its subject to the bridge (also for a share that launches the app). The first http(s) URL, titled by the subject or else the rest of the text, is offered to subscribe to or publish, after sign-in when signed out; servers before API 1.5 open the subscribe dialog filled in. The page goes to the active profile; with others signed in, the dialog names it and can move the page to another, kept insessionStorageacross the reload. - Updates (release builds only): at launch, at most daily, the bridge fetches the stage's
/downloads/latest.jsonnatively (no CORS) and compares itsversionCode; a newer APK opens in the browser, which hands it to the package installer. The last result is kept between launches. versionNamecomes from the release tag andversionCodeis major·1000000 + minor·10000 + patch·100 + a prerelease slot:-rc.N(1–98) is N, a release 99, atry-release.shbuild (-try.*) 0; other prerelease tags are refused. Local builds are0.0.0-dev(code 1). Release APKs are signed with the release keystore whenANDROID_KEYSTORE_*is set, else unsigned.
Ingest pipeline
Scheduler ─▶ claim due sources ─▶ feed.fetch job per host (≤ 20 sources, fetched one after another)
fetch conditional GET (ETag/Last-Modified); per host at most 2 concurrent requests, starts ≥ 1 s apart
decode bytes → text; charset from BOM, then HTTP Content-Type, then XML declaration/HTML meta, else UTF-8
parse feedsmith → per-format mapping to normalised entries; XML that fails to parse is a fetch error
dates parsed leniently, zone-less dates are UTC, unparseable dates are null
entry links, enclosures, and site URLs kept only if absolute http(s)
identify feed GUID, else sha256(link + title), else sha256(content); duplicates within a document dropped
a new item takes over an imported entry (GUID `ttrss:…`) with the same link in the same source
sanitise allow-list HTML; strip control characters; resolve relative URLs (incl. srcset); drop tracking pixels
(1×1 images, images from hosts in `trackers.ts`); titles to plain text
store insert new entries; rewrite existing ones only when their content hash changed; replace enclosures
fan out new entries become unread user entries for every subscription, unless older than its purge age
the entry's feed categories become the subscriber's tags
filter each recipient's enabled filters, in order, until "stop" (see Filters)
notify Realtime `counters` event per user who received entries
push Web Push message to each such user's devices, at most one per window (see Push)
full text `entry.extract` job for the source when a subscriber opted in and entries were added
schedule next fetch after the interval, or after backoff on failure; favicon refresh when older than 30 daysUpdater:
- Dispatch claims due sources that have an unpaused subscription with
FOR UPDATE SKIP LOCKED, at most 20 per host, pushing their next fetch 15 minutes out, so concurrent dispatchers never double-fetch. A finished fetch sets the real next time. - One
feed.fetchjob per host may wait in the queue; sources that cannot join it stay due for the next dispatch. - A
feed.fetchjob holds its host's lease (fetch_hosts.lease_id, 2 minutes, renewed before each source, released at the end). A job that finds the host leased pushes its sources' claim to 15 minutes out and is queued again a minute later, or leaves them due when a job for the host already waits; one that loses its lease leaves the rest due. - The base interval is the shortest among unpaused subscriptions, each taking the subscription's override, else the user's
updateIntervalMinutespreference, elseFEED_UPDATE_INTERVAL_MINUTES; never below 5 minutes. Users and subscriptions cannot set less than 15 minutes. - The interval in effect is the longest of the base, the publisher's hint (Cache-Control
max-age/Expires, RSSttl,sy:updatePeriod; at most 24 h), the source's slowdown, and its host's minimum (fetch_host_rules, set by admins). The source stores it and what set it; the next fetch waits it plus up to 10 % random jitter. - Each 429, or 503 with
Retry-After, doubles the source's slowdown, starting from the interval without it, up to 24 h. Five successful fetches in a row halve it; it is cleared once no longer than the interval without it. - Changing a subscription's interval or pause, a user's
updateIntervalMinutes, subscribing to or unsubscribing from a fetched source, and setting or clearing a host's minimum reschedule the source: next fetch at its last fetch plus the new interval (with jitter), not before now orblocked_until. Sources that are disabled, failing, never fetched, or due within the 15-minute claim window keep their time. - Subscriptions report the interval in effect and why (
own,sharedwhen other subscriptions make it shorter,publisher,slowdown,siteMinimum) and the next fetch; paused ones reportpausedand neither, so other subscribers' fetches stay private. sort_atis the published time (fetch time when absent), clamped to now.- A failed fetch waits interval × 2^(failures − 1), capped at 24 h and never less than
Retry-After. HTTP 410, orFEED_DISABLE_AFTER_FAILURESconsecutive failures, disables the source. - Every request to a remote host (feeds, subscribe, favicons, images, full text, pages) goes through
PoliteFetcher: within the per-host limits (2 concurrent, ≥ 1 s apart, per process), never to a paused host (host_blocked), and a 429, or a 503 withRetry-After(without it: 10 minutes), pauses the host that answered until then (fetch_hosts.blocked_until, shared by all processes). Retry-After(and HTTP 429 without it: 10 minutes) sets the source'sblocked_until. A paused host's sources are postponed until the pause ends, without counting failures.- Per user, in a minute from their first request, on-demand full text (20), subscribing to a feed not yet fetched (10), reading a page to publish (10), the feed debugger (5), and OPML imports (5) are counted in
rate_limits; past the limit they get 429 withRetry-After, except publishing, which publishes the page unread. - "Update now" clears errors, re-enables the source, and enqueues a fetch. It is a no-op within a minute of the last fetch and refused (
throttled) whileblocked_untilis in the future. - A permanent redirect (301/308 from the first hop on) moves the source to the new URL after a successful fetch, unless another shared source already has that URL; a source with credentials moves only within its origin.
- Image proxy (per-user
proxyImagespreference): when an entry is served to such a user,imgsrc/srcset, picturesourcesrcset, and videoposterURLs become/api/v1/images/<hmac>/<base64url URL>, signed with theimage-urlkey, and image enclosures (by MIME type, else file extension) carry that path asproxy. The route serves fromBlobStore(images/<sha256 of URL>) or fetches once throughPoliteFetcher, up to 4 MB, accepting only images (declared or sniffed). Failures are not retried for 24 h. Responses arepublic, max-age30 days, immutable, with a sandboxing CSP andAccess-Control-Allow-Origin: *(also on 403 and 404), so the apps can read them whatever CloudFront cached. - Kept images: a sweep (every 5 minutes on Docker, after each dispatch on AWS, at most 2 minutes) lists the images of entries someone keeps (starred, published, noted, labelled, or shared) in
entry_images: those of the content and full text, at most 30, asPOST /entries/contentslists them, again when the content version changes (entry_image_sets). It then fetches listed images not cached, 4 at a time across hosts, and failed ones again after 24 h, at most 3 times in a row; a paused host's wait for the next run. - Favicons: declared
<link rel="icon">/apple-touch-icon, else/favicon.ico; the first 3 candidates only; page read up to 512 KB, icons up to 256 KB; reused from another source of the same site checked within 30 days instead of refetched; share the per-host limits. Stored inBlobStoreasfavicons/<sha256 of type and bytes>, so sources showing the same icon share one blob, deleted once no source shows it.iconUrlis/<key>:public, max-age1 year, immutable, with a sandboxing CSP.
Purge (every 6 h):
- Deletes user entries older than the purge age: the subscription's
purge_days, else the user'spurgeDayspreference, elseFEED_PURGE_DAYS; 0 never. Kept entries (starred, published, noted, labelled, or shared) are never purged. - Deletes user entries without a subscription (pages, kept entries of unsubscribed feeds) that are no longer kept once unchanged (
updated_at) for the user's purge age, so counted from when they stopped being kept. - Deletes entries no user references once they have been absent from their feed for 7 days (
last_seen_at), so purged entries are not re-ingested as new. - Deletes feed sources with no subscriptions and no kept entries, and their favicons; never the pages source.
- Forgets the images of entries no longer kept, then deletes proxied images and remembered failures fetched more than 30 days ago, except images of kept entries.
- Deletes tombstones older than 30 days, and host rows whose pause and lease have both ended.
- With
ARCHIVE_ENABLED, entries other than pages and those of sources with credentials go to the archive before they are deleted, in batches of 1,000, for up to 3 minutes per run: unreferenced entries past the grace period, then every entry of a feed source about to be deleted. Each batch's delete re-checks its conditions, so an entry used again meanwhile stays (and is also archived). A source is deleted only once its entries are; the rest waits for the next run.
Archive:
- Parquet files under the blob root,
archive/entries/month=YYYY-MM/<uuid>.parquet, one month ofsort_atper folder, rows sorted by feed URL andsort_at, snappy-compressed; files are only added. Layout:server/src/adapters/archive-format.ts. - Columns: the entry's id (null for imported rows), feed URL and title, GUID, link, title, author, content, its plain text, language, published, source-updated, fetched, sort, and archived times, and enclosures.
- AWS: the Glue table
archive_entriesin database<prefix>_<stage>projects partitions from the month folders; objects move to Intelligent-Tiering. Queries run in the<prefix>-<stage>Athena workgroup, results underathena-results/(kept a day), at most 10 GB scanned per query. - Reads: an article is a feed URL and GUID; readers keep the copy archived last, and the database's copy of an article wins over the archive's. Order: newest
sort_atfirst, then feed URL and GUID. Search matches the copy archived last: every word and phrase anywhere in the title or plain text and none of the negated ones, ignoring case and accents (in the database: the full-text index, stems included), withtitle:,author:, and dates; cold storage countsORasAND. Past articles have no state, so operators asking for state (star:true,note:true,tag:,label:, and the like) match none, and their negations every one. - A user's archive of a feed is the entries of its source they do not hold (purged for them, or older than their subscription) plus archived rows with the feed's URL; only current subscribers reach it.
- Restoring an article re-inserts the entry with its original id when that is free (else a new one) and its enclosures, unless the database still has it, then adds the user's entry, read, in its subscription, with the requested state. Sync picks it up through
updated_at. A restored article that is not kept is purged, and archived, again. - Compaction (daily): each month before the current one with several files becomes one file, without duplicates, sorted as written; the files read are then deleted. Docker: DuckDB writes the file, at most 10 minutes per run. AWS: Athena
UNLOADs the month toarchive/staging/, from where it moves into the month folder, at most 3 minutes per run. - Docker reads the archive only from a local blob directory: with
BLOB_BUCKETit is written but not read.
Fetching untrusted URLs (HttpFetcher):
- http(s) only, at most 5 redirects, a 20 s timeout, and a 10 MB body limit (lower per request where less is needed); downloads stop once the limit is exceeded. Responses are decompressed.
- Private, loopback, link-local, multicast, documentation, and IPv4-embedding IPv6 (NAT64, 6to4, Teredo) addresses are refused unless allowed by
FETCH_ALLOW_PRIVATE_NETWORKS. The check runs on the resolved address at connect time, which also covers redirects and DNS rebinding. - Errors from subscribing and from fetching a page name the failure class (private network, HTTP status, too large, unreachable), never the network error text. A 401 says whether a login was sent (
fetch_login_required,fetch_login_refused). - HTTP Basic credentials (UTF-8) go only to the origin of the URL fetched, never across a redirect to another origin.
Subscription lifecycle:
- Subscribing normalises the URL. An existing feed source is reused without fetching. Otherwise the URL is fetched and must parse as a feed, or be an HTML page whose
<link rel="alternate">names exactly one feed; several feeds are returned for the user to choose. - Subscribing with HTTP Basic credentials (
credentialsonPOST /subscriptions, API 1.12) always fetches with them and creates a source of the subscription's own; a feed a page names on another origin is refused (feed_login_elsewhere). A user has one subscription per URL, with credentials or without.PATCHtries new credentials before storing them (withoutpassword, the stored one); adding or removing them moves the subscription to a new own source or to the shared one, whose entries arrive as new, while its kept entries stay with no subscription. Subscriptions returnauthLogin, never the password. The web apps send credentials only while online, never through the offline outbox. - Subscribing to a new source ingests the response that validated it, so the feed is not fetched twice. OPML import creates sources and subscriptions only; their entries arrive with the first scheduled fetch. Subscribing to a source that already has entries delivers those within the purge window immediately.
- Unsubscribing deletes the user's entries from that feed except kept ones, which stay with no subscription. Feed sources without subscriptions are left for purge.
- OPML import counts feeds the user reads with credentials as already subscribed; the export lists their URLs only.
- Deleting a category moves its feeds and child categories to its parent.
- OPML import reuses categories with the same name and parent, and existing subscriptions, so re-importing is a no-op. It skips TTRSS's
tt-rss-prefs,tt-rss-labels, andtt-rss-filtersoutlines. A file with more than 2,000 feeds and folders, or folders nested more than 10 deep, is refused before anything is written; the rest is written in a few statements, in one transaction. Feeds with addresses past/api/v1's length limit are listed as invalid; longer folder names and feed titles are cut.
Full text:
entry.extractjobs (one per feed source at a time) take the source's 20 newest entries not tried yet, newest first, and fetch each linked page through the per-host limits, unless the host is paused (HTML only, at most 5 MB). Readability (@mozilla/readabilityon linkedom) extracts the article, which is sanitised like feed content and stored inentries.full_content. Failures are recorded infull_content_errorand not retried by jobs.POST /api/v1/entries/:id/full-textextracts on demand, retrying earlier failures, and returns the stored text when there is one.- Readers see the full text first for subscriptions opted in to it, with a toggle back to the feed's content, and on request for others. TTRSS and Google Reader clients get it in place of the content for opted-in subscriptions. The original content is always kept, and search indexes it only.
Observability
| Signal | Recorded | Where |
|---|---|---|
| Traces | Requests (span per route), jobs and scheduled tasks, pg-boss send/process, database queries inside a request or job, requests to remote hosts | Docker: OTLP, when OTEL_EXPORTER_OTLP_ENDPOINT is set. AWS: X-Ray |
| Metrics | http.server.request.duration by route and status; rss.outbound.requests/.duration by purpose and outcome; rss.jobs.duration/.failures by job; rss.ops.alerts.active; pg-boss queue depth; pg pool; Node event loop, heap, GC | OTLP |
| Logs | Pino lines carry trace_id and span_id | stdout; also OTLP |
| Operations data | Rollups and audit events below | Postgres; admin Operations page |
- The Docker image preloads
server/src/telemetry/register.ts; without an OTLP endpoint no SDK module loads. The standardOTEL_*variables (sampler, export interval, per-signal exporters) apply. Service names arenewses-<role>. - Telemetry never carries credentials, cookies, raw request URLs, feed URLs, or article content: request spans keep the route pattern, outbound spans the host. Database spans keep parameterised statements, never values. Remote hosts never receive trace headers.
- Request logs keep the route pattern (
unmatchedwithout a route), and log lines above debug name hosts, not feed, page, or image URLs. WithLOG_LEVELdebugortrace, request logs carry the URL and debug lines the addresses; parameters and query fields a route lists inlogSecrets(published-feed keys, share ids, image signatures, icon tokens) are redacted at every level.COMPAT_TRACElogs compatibility-API parameters as clients send them. - pg-boss jobs continue the trace that queued them: pg-boss stores the W3C trace context on the job (no baggage). SQS carries it as a
traceparentmessage attribute, and each Lambda invocation keeps its own trace, its job span linked to the queuing span.
Operations data (OpsRecorder counts in memory and adds to the tables every minute on Docker; on AWS at the end of each invocation that used the database, so the api function holds counts from database-free requests until its next such invocation and never wakes a paused database to write them):
| Table | Grain | Feeds |
|---|---|---|
user_activity_daily | User, day, client (web, desktop, mobile from X-RSS-Client; greader, ttrss, public, other by path) | Users tab; articles read come from user_entries.read_at |
request_stats_hourly | Hour, client, status class | Summary, api.errors |
host_fetch_stats_hourly | Hour, host, purpose (feed, favicon, image, fulltext, subscribe, plugin), outcome | Sites tab, host rules |
job_stats_hourly | Hour, job or task | Jobs tab, jobs.failing |
audit_events | One security event (the logSecurity events) | Audit tab |
ops_alerts, ops_state | One alert episode per rule and subject; the last check | Alerts tab, stale-monitoring banner |
Rollups and resolved alerts are pruned after OPS_RETENTION_DAYS, audit events after AUDIT_RETENTION_DAYS, with the 6-hourly purge.
ops.check (worker every 5 minutes; after each dispatch on AWS) evaluates the rules, opens and resolves alerts, and notifies on changes:
| Rule | Subject | Severity | Fires when |
|---|---|---|---|
host.rate_limited | Host | Warning | A 429, or 503 with Retry-After, in the current or previous hour |
host.over_budget | Host | Warning | More than OPS_HOST_HOURLY_BUDGET requests to the host in one hour |
host.failing | Host | Warning | Half or more of ≥ 10 requests failed in 6 hours |
jobs.failing | Job | Critical | More than 20% of ≥ 5 runs failed in the current or previous hour |
jobs.backlog | Queue | Warning | 100 or more jobs ready and waiting (pg-boss) |
ingest.stale | all | Critical | Enabled feeds with an unpaused subscription overdue by more than 2 hours |
api.errors | all | Critical | More than 5% of ≥ 20 API requests answered 5xx in the current or previous hour |
plugin.disabled | Plugin | Warning | The plugin was turned off for the instance after failing repeatedly, until an admin enables it |
plugin.refused | Plugin (its id, else its package) | Warning | The deployment installs a plugin the server would not load, with the registry's reason, until a deployment loads it or no longer installs it |
User email
- Every user mail comes from
MAIL_FROM(defaultNewses <newses@host>on thePUBLIC_URLhost, elselocalhost); a user's address only appears asReply-To. SMTP_URL(smtp://orsmtps://) turns user mail on, independent of alert email;ALERT_EMAIL_FROMdefaults toMAIL_FROM.SMTP_URLandMAIL_SES_CONFIGURATION_SETexclude each other; the Docker image refuses SES, whose SDK only the functions bundle.- A user's address receives mail once confirmed:
PUT /account/emailkeeps it pending and mailsPUBLIC_URL/confirm-email#<token>(else the request's origin), whose page posts the token toPOST /account/email/confirmafter a click, without a session; the token's hash is kept for 24 hours, and a new request replaces it. Requests are limited per user (emailConfirm). POST /entries/:id/emailmails the user's entry (whole content, else its excerpt, with its link) to at most 5 addresses with an optional note;Reply-Tois the sender's confirmed address, without which it is refused (email_unconfirmed). With the sender'sproxyImages, images are signed proxy URLs onPUBLIC_URL. Limited per user (emailArticle).- Unread digest (
digestFrequencydaily or weekly, atdigestHourondigestWeekdayintimeZone, UTC when unset; the web app sets the device's zone when turning it on):digest.dispatch(every 5 minutes on Docker, after each dispatch on AWS) creates the state of users with digests on and none (after a restore), then claims at most 50 users whose digest is due (SKIP LOCKED, leased for an hour), the longest due first, and queues adigest.sendjob for each with its lease. The jobs send one digest at a time in the order queued: the worker one at a time, on AWS thedigestfunction from<prefix>-<stage>-digest-send, one per invocation and at most 2 at once. A job sends only while the user's claim is still the one it was queued with, so a job delivered twice, or claimed again after its lease lapsed, sends nothing; one that fails is logged and not retried, and the user is claimed again once the lease lapses. Each gets their unread entries above the watermark shown in All (not hidden from All, not scored belowscoreHideBelow), the newest 100 listed by category and feed with their excerpt, a link into thereaderroute and to the original, and the rest counted; withdigestMarkRead, the listed ones are marked read. The watermark moves past every entry above it, read or not, once mailed or when none is unread; a failed mail or a user without a confirmed address keeps it. Changing a digest preference or the time zone sets the next due time, turning digests off deletes the state. Digests need mail andPUBLIC_URL(GET /server'sdigest) and are in the user's language. - Test digest:
POST /account/digest/test(API 1.17, 3 a minute per user) is refused without digests (mail_unavailable), a confirmed address (email_unconfirmed), or an unread entry shown in All that came in over the last 24 hours (digest_test_empty); otherwise it answers 202 and queues adigest.sendjob for the test, sent as due digests are, behind those queued before it. One that fails is logged, not retried. The digest holds those entries, the newest 100 listed, with everydigest.composeaddition of the plugins on for the user (not counted toward turning them off) and, for each that added nothing, why; its subject and opening say it is a test, it has no unsubscribe link, and it leaves the user's digest state and the entries' read state as they were. In Settings → Plugins, a user's Send test of a plugin withdigest.compose(Plugin.digests) asks for one once the plugin's own test passes, or at once without one. - Digest unsubscribe:
PUBLIC_URL/public/unsubscribe/<user id>.<HMAC>(digest-unsubscribekey, so a restore onto anotherAPP_SECRETinvalidates old links).GETshows a page whose button posts back,POST(the page's, or the mail client's one-click with any body) turns digests off. - Mail sent on a schedule carries
List-UnsubscribeandList-Unsubscribe-Post: List-Unsubscribe=One-Click(RFC 8058); SES receives raw MIME, so the headers are kept.
Plugins
@newses/plugin-apiversions the contract apart from the app. While its major is 0, additions raise the patch and breaking changes the minor. A plugin'sapiVersionis a caret range (^0.1,^0.1.2) that must acceptPLUGIN_API_VERSION.- The workspace package keeps no version and is private;
plugin-api/src/publish.tsbuilds it to JavaScript and declarations inplugin-api/dist, as the public npm package versionedPLUGIN_API_VERSIONwithzoda peer dependency, and publishes it with--publish, refusing a version npm has. Its/testingentry is the test kit:runHook(runs a hook as the server does: the contract's version, settings parsed by the plugin's schemas, the hook's limit fromEVENT_LIMITSorDIGEST_LIMITS, a digest result checked withdigestAdditionsSchema),createTestContext(approved hosts only, redirects returned),MemoryStore(the stores' limits), and fixture entries. definePlugintypes each hook's context by the plugin's settings schemas (ContextOf); the runtime check is the registry's.- The installed plugins are
INSTALLED_PLUGINSfrom#installed-plugins(server/package.jsonimports), which isserver/src/plugins/installed.ts, none, in the repository. A deployment installs plugins when it builds, never while it runs:server/src/plugins/install.tsinstalls npm packages at exact versions (at most 20) into a folder underserver/with npm, without install scripts or peer dependencies, so plugins resolve the server's zod and@newses/plugin-api; refuses a plugin bringing its own copy of either; fails on high and critical advisories; and writes the list (installed.js, default imports) andplugins.json. Plugins' licences are checked with the build's (Third-party notices). - AWS: each stage's
pluginsin the deployment config; the deploy pipeline's synth runspnpm --filter @newses/infra plugins:installafter the checks, intoserver/.plugins/<stage>, and every function's bundle aliases#installed-pluginsto that stage's list (infra/src/plugins.ts); synth refuses a stage whose installed list differs from its config. Docker:docker/compose.plugins.yamlbuildsnewses-plugins:localfrom the app image (NEWSES_IMAGE) withPLUGINSinstalled into/app/server/.plugins,installed.tsre-exporting its list (--link), and the licences rewritten, formigrate,server, andworker;up -d --buildapplies a change.PLUGINSmay also name plugins packed withnpm packas./plugins/<file>.tgz, from apluginsfolder beside the compose file that the build mounts, never copies into the image; the installer reads each one's name and version from itspackage.json, installs it as it does npm packages, and lists it by its path. AWS stages install from npm only. - Every process loads them once (
loadPlugins: the server and worker, and each function at a cold start), records the ones refused (ops_stateplugins.refused, forplugin.refused), writing each installed plugin's event hooks and user scope to itsplugin_settingsrow (and none to plugins no longer installed) for the triggers; saving a plugin's instance settings writes them too. - The registry takes the installed plugins (source and default export) and refuses, with the reason, each one whose definition does not parse (id, semver version, scopes, lower-case hosts, known hooks only), whose
apiVersionrejects this contract, or whose id an earlier plugin took. It logs what it loads and refuses, and never throws. - The runner runs one hook of one plugin under the hook's time limit, aborting the context's
signalwhen it ends, and checks the result against the hook's output schema. A throw, timeout, or unusable result is a failure the caller skips. Each run has a span (rss.plugin.id,rss.plugin.hook,rss.plugin.outcome) and counts as jobplugin:<id>:<hook>in the job statistics and metrics, so the Operations page and the failing-jobs alert cover plugins. - A hook runs only while the plugin is on for the instance and, with scope
user, for the user it runs for, and while its saved settings parse with the installed version's schema; otherwise the runner skips it without counting a run. - A hook's context: the plugin's id, the hook's
signal, the server's logger with every line taggedplugin, the instance settings and (for a user's run of a plugin with user settings) the user's, with secrets opened, its storage for the instance and (for a user's run) the user, and a standardfetch. Thatfetchreaches http(s) URLs on hosts approved for the plugin only, throughPoliteFetcher.request(per-host limits of their own, 6 concurrent, ≥ 1 s apart, per process; the pauses of feed fetches, a 429, or 503 withRetry-After, pausing the host), with the address guard ofHttpFetcher(FETCH_ALLOW_PRIVATE_NETWORKS) except for hosts inPLUGIN_TRUSTED_HOSTS(the operator's own services, such as a model server on the Docker network, which may resolve to private addresses), returning redirects instead of following them, ending with the hook'ssignaland no time limit of its own. Requests count in the per-host statistics as purposeplugin; refusals reject with aTypeError. - Settings (
core/plugins, behind thePluginCatalogport the registry implements): a plugin'ssettings.instanceandsettings.userare zod object schemas, user settings only with scopeuser.secret()andurl()mark top-level string fields, andfeeds()top-level user settings holding subscription ids; a mark anywhere else refuses the plugin. Admins enable a plugin, set its instance settings, and approve its hosts (at most 50); users enable plugins with scopeuserand set their settings. A change replaces the plain fields; a secret given is set, given null cleared, left out kept. The result must parse with the schema whenever settings change or the scope is on, URL fields only on approved hosts, at most 64 KiB with sealed secrets. Views of settings name the secrets set, never their values. Rows outlast the plugin's removal until an admin removes them, with its storage; a user's go with the user. - Settings forms: the registry describes each scope's settings as JSON Schema (
z.toJSONSchema, input side), each top-level property's marks asnewses(secret,url,multiline,feeds,shownWhen), and secrets without their default.shownWhennames other top-level selects or checkboxes of the scope and values of theirs, which the registry checks; the form shows the setting only while each has one of them, and saves a hidden setting's value as it is. The web app edits text, multi-line text, URLs, secrets, booleans, selects, numbers, the user's feeds (picked from their subscriptions, one they left kept until saved), and lists of objects of the other kinds; a setting it cannot edit is sent back as saved. A plugin'smessagesare plain text per language tag (name,description,settings.<field>,.hint,.option.<value>,.item.<property>), shown in the reader's language, else its language without a region, else English, else the key. - Storage: per plugin for the instance, or per plugin and user; keys of 1 to 200 characters, JSON values of at most 64 KiB, at most 10,000 keys and 16 MiB per store (
STORAGE_LIMITS, checked under a per-store advisory lock), optional expiry of at most 366 days. Expired values are ignored and deleted with the 6-hourly purge. - Failures: every counted run resets or adds to the plugin's failures in a row, a user's run of a plugin with user settings on the user's row, any other on the instance's, with how it failed and, for a throw, what it said (
last_failure_detail: the error's message as plain text, at most 300 characters), which Settings → Plugins shows. The 10th in a row turns the plugin off there (disabled_reasonfailures); on the instance's that raisesplugin.disabled. Enabling it again clears the count. - Tests ("Send test"): a plugin's
testhook runs with the saved settings, for the user (a plugin with user settings) or the instance, while the plugin is on there, under 30 s, and reports{ ok, message }(plain text, at most 500 characters). A test that throws, runs out of time, or reports otherwise fails, with what it threw. Tests are not jobs and never count toward turning a plugin off. - Event hooks (
entries.added,published.changed) each declare a debounce window (debounceSeconds, 0 to 3600, default 0). Events are recorded inplugin_events, in the transaction that made the change, for each plugin on for the instance that implements the hook and, with user scope, is on for the user (plugin_listeners):entries.addedby the fan-out for each subscriber's new user entries (fetched or backfilled), before filters run;published.changedby statement-level triggers onuser_entries(rows inserted published, updates changingpublished, published rows deleted while their user remains), so every path counts: the APIs, sync, published pages, filters, and the TTRSS import. - Dispatch (
PluginEventService.dispatch): a plugin, user, and hook's events become one delivery (plugin_deliveries, at most 500 entries, the last state of each) once the window since the first has passed. A due delivery is claimed withSKIP LOCKEDfor a 3-minute lease and run under a 60-second limit; one that fails is retried after 1, 4, 16, and 64 minutes, then 4 and 6 hours, then dropped and logged; one whose plugin is off, uninstalled, or no longer implements the hook is dropped. A lease that lapses (a crashed run) makes it due again, so deliveries arrive at least once. Each run counts as jobplugin:<id>:<hook>(Jobs tab,jobs.failing) and toward the plugin's failures in a row. - Delivery reads the entries as the user sees them then.
entries.addedcarries those the user still has, each with plain text (full text when extracted, 20,000 characters at most) and content hash;published.changedcarries the entries now published, the ids of the others, and the published feed's URL (PUBLIC_URL/public/feeds/<key>, once the user has a key and the serverPUBLIC_URL). An entry's feed is the user's subscription and title; a feed with a login has no URL, and pages have no feed. digest.composeruns while a user's digest is sent, for each plugin implementing it that is on for the instance and, with user scope, for the user, all at once, each under 5 minutes. It gets the listed entries as events carry them (without text) with their excerpts and content hashes, the digest's language and frequency, the count left out, and the first 2,000 of those left out (unlisted), newest first, as listed entries are; it returns an overview (at most 4,000 characters), sections (plugin API 0.1.2), and text per entry id (at most 1,000 each). Sections are headings with points, as paragraphs or a list, each point citing entries by id;DIGEST_LIMITSbounds them. All are plain text: control characters other than line breaks are removed, cited ids the plugin was not given and text for ids the digest does not list are ignored, and a hook that throws, times out, or returns more adds nothing. Overviews and then sections open the digest under each plugin's name in the digest's language, each point followed by the titles of the entries it cites, linked into the web app; per-entry text follows the entry's excerpt; all escaped, in install order.- Actions (
actions, at most 5, named as plugin ids are): buttons beside Send test (Plugin.actions), labelled by the plugin's messagesaction.<name>andaction.<name>.hint, run as a test is (with the saved settings, for the user with user settings, else the instance, under 30 s, never counted) and reporting aTestResult. One withdigest(only with user settings) is given whatdigest.composewould get for a test digest now; nothing is sent. - Docker runs dispatch in the worker every 30 s (25 s budget). AWS has nothing polling, so the database can pause: every function's
countersnotice (each change to a user's entries) queues aplugin.dispatchmessage on<prefix>-<stage>-plugin-dispatch, delayed until the next delivery is due, when events wait and the process has not queued one for then already. Thepluginfunction runs dispatch (3-minute budget) for each message and queues the next; thetickdispatch catches up on any missed.
Data model
Shared rows are stored once per instance; per-user rows carry user_id. Every table synced to clients has updated_at and sync_xid (the id of the transaction that last wrote the row), maintained by database triggers. Statement-level triggers record deletions of categories, subscriptions, labels, and user entries as tombstones for incremental sync. Assigning or removing a label or tag touches the user entry, so sync carries its label ids and tags; tags copied at fan-out do not. A change to an entry's content hash (title, link, or content) or full text touches every subscriber's user entry; fetches that change neither, and failed extractions, do not.
| Entity | Scope | Notes |
|---|---|---|
users | Instance | Login (unique), Argon2id hash, role (admin/user), disabled flag; sealed TOTP secret, enabled time, last accepted time step; confirmed email address and when; a pending address with its link token's hash and expiry |
recovery_codes | User | SHA-256 hash, used time |
sessions | User | Token hash, kind (cookie/bearer/api), user agent, app password (api only), last seen, expiry |
app_passwords | User | Name, hash, last used |
push_subscriptions | User | → session (one each, deleted with it); push service endpoint (unique), device public key and auth secret, last delivery. Not synced |
push_state | User | Highest user entry id pushed (watermark), whether entries wait for the window to end, last message time. Not synced |
digest_state | User | Highest user entry id a digest covered (watermark), when the next is due, last digest time; only for users with digests on. Not synced |
image_cache | Instance | Blob key, fetch time, size, failed flag, failures in a row |
entry_images | Entry | Images (blob key, URL) of a kept entry's content version, which entry_image_sets records |
user_prefs | User | One row per changed preference (JSON value); unset keys take the defaults in shared |
categories | User | Self-referencing tree (parent_id), order |
feed_sources | Shared | Normalised URL, unique among sources without credentials; fetch state (ETag, Last-Modified, next fetch, error count, last error with its reason and params, publisher TTL hint, capped hint, slowdown and successes since, blocked_until); interval in effect and its reason; site URL; favicon ref; HTTP Basic login and password, sealed (feed-credentials key, the source's id as context), on a source of one subscription's own that is never found by URL, shared, or archived. The pages source (newses:pages, disabled) holds pages from outside any feed; nobody can subscribe to it, and it is never fetched or purged |
fetch_host_rules | Instance | Host (with port), admins' minimum interval, admin who set it. Not synced |
subscriptions | User | → feed source, category; title override, interval and purge overrides, full-text opt-in, paused, hidden from All. Unique (user, feed source) |
entries | Shared | → feed source; GUID, link, title, author, content, content hash, extracted full text (with attempt time and error), published/updated times, language, normalised feed categories, tsvector (generated, GIN index). Unique (feed source, GUID). A page is one user's own: GUID page: + SHA-256 of the user id and normalised URL; its feed title is the link's host |
enclosures | Shared | → entry; URL, MIME type, length, dimensions |
user_entries | User | → entry, subscription (nullable when archived) or archived feed; unread, starred, published, score, plain-text note (null when none), read time, share UUID. Unique (user, entry) |
archived_feeds | User | Title and URL of an unsubscribed feed that still holds kept entries |
labels / entry_labels | User | Caption (unique per user, case-insensitive), text and background colours (#rrggbb); many-to-many with user_entries |
entry_tags | User | (user entry, tag) pairs; tags are lower-case, single-spaced, without commas, at most 64 characters and 50 per entry |
themes | User | Name (unique per user, case-insensitive, at most 60 characters), built-in base key, partial tokens (JSON) over the base, shared flag; at most 50 per user. Not synced |
filters / filter_rules / filter_actions | User | Ordered filters; match any/all, inverse, enabled; rules: field (title, content, title-or-content, author, link, tag), RE2 pattern, inverse, scope (subscription and category id arrays; empty for all feeds); actions: type with a label, tag, or score |
access_keys | User | Secret keys for published feed and generated feeds |
plugin_settings | Instance | Per plugin id, installed or not: enabled, settings (JSON), secret fields sealed (plugin-secrets key, plugin, scope, and field as context), approved hosts, failed runs in a row, last failure, why the server turned it off; the installed version's event hooks and user scope. Not synced |
plugin_user_settings | User | The same per plugin and user, without hosts. Not synced |
plugin_events, plugin_deliveries | User | Changes waiting for a plugin's event hook (plugin, user, hook, user entry, published state), and the deliveries made of them (events, attempts, due time, lease). Not synced |
plugin_storage | Instance or user | Plugins' key-value data: plugin id, user (null for the instance), key, JSON value and its size, expiry. Not synced |
import_map | Instance | (TTRSS table, source id) → new id and owning user; on user rows, when that user's last import finished |
Key indexes:
user_entries (user_id, unread), partial indexes onstarredandpublished.user_entries (subscription_id, …)for feed views.entries (feed_source_id, published_at DESC).
Headline lists use keyset pagination on (sort key, id). user_entries.sort_at is a denormalised copy of the entry's published time (fetch time when absent), so every headline view is served by one index. Descending index columns are NULLS LAST; queries order the same way so the indexes apply.
Search:
qis read byparseSearchQueryinshared, alike for headline lists, the archive, offline search, and TTRSSgetHeadlines: TTRSS's operators filter the stream, and the rest is free text. Unknown operators and values are free text; operator keywords are English in every language.title:,author:, andnote:match a substring ignoring case;tag:a whole tag, normalised as tags are;label:a label's caption ignoring case.note:,unread:,star:, andpub:taketrueorfalse. A leading-negates any operator; values with spaces are quoted.- Dates (
@YYYY-MM-DD,@today,@yesterday,@-Ndays,@-Nweeks) match the day ofsort_atin the reader's time zone:timeZone(IANA) onGET /entriesandGET /archive/entries, which the web app sends; UTC without it, as for the compatibility APIs. - Operators alone have nothing to rank by, so they list newest first.
- A generated
tsvectoronentries(markup stripped, title weighted above content) holds each word folded (newses_simple:simpleafterunaccent), and again stemmed in the entry's language (newses_<language>: the Snowball stemmer afterunaccent) whenlangnames one ofSEARCH_LANGUAGESinshared, the stemmers PostgreSQL and the web app both have. - The free text keeps
websearch_to_tsquery's meaning (quotes,OR,-), built term by term: a word or phrase matches folded, or stemmed in one of the reader's languages, those of their feeds (each subscription's newest entry) and of their app. title:,author:, andnote:fold accents too (unaccent).- The user's notes match too, folded, through a partial GIN index on
to_tsvector('newses_simple', note); notes have no language, so they are not stemmed. Notes do not count towards the 20,000 below. - A query matching at most 20,000 entries instance-wide (counted from the GIN index) is resolved into a materialised set of the user's matches, then sorted. A more common one walks the headline index, where matches are dense.
- Relevance order ranks (
ts_rank) the 1,000 most recent matches and pages by offset.
Authentication
| Client | Credential | Notes |
|---|---|---|
| Web | httpOnly, SameSite=Lax session cookie | CSRF token on state-changing requests; TOTP at login when enabled |
| Electron / Capacitor | Bearer session token | TOTP at login when enabled; stored in OS secure storage (Electron safeStorage, platform keystore on mobile) |
| TTRSS / Google Reader clients | App password → api session | App passwords bypass TOTP |
- Session tokens are 256-bit random values stored as SHA-256 hashes. Cookie sessions last 30 days, bearer and
apisessions 90 days, all sliding on use. Logging in ends the session the client sent, if any. apisessions are opened only by an app-password login through a compatibility API and belong to that app password: revoking it ends them, and each keeps its 10 most recent.- The cookie is
__Host-rss_session(Secure) over HTTPS andrss_sessionover plain HTTP; HTTPS is taken fromX-Forwarded-Protoonly whenTRUST_PROXYtrusts the proxy. - A user created with a generated password (the AWS bootstrap admin, users the TTRSS importer creates) has
password_change_requireduntil they change it, and the web app shows only the password change. - A generated password expires 7 days after it is set (
password_expires_at). Past that, it no longer signs in: login answers 401password_expired, counted as a failed login and logged aslogin_failedwith that reason, and the user's sessions end. Changing or resetting the password clears both. On AWS, the migrate function'sreissue-admintask gives the first admin a new generated password in SSM, and enables it, but only while no other admin is active. - The first admin's login may not contain
admin,root, orsuperuser, nor besawith only digits and separators besides (isReservedAdminLogininshared). Bootstrapping into a database without users refuses one, and startup logs asecuritywarning while an enabled admin has one. - Cookie-session requests other than GET/HEAD/OPTIONS must send the session's CSRF token in
X-CSRF-Token. Login accepts JSON only, so cross-site form posts cannot log a browser in. - Failed logins are counted in
login_attemptsper account (lockout after 5) and per IP (after 20). Lockouts start at 1 s and double per further failure, up to 15 minutes. A wrong current password when changing it counts against the account. A lockout only delays further password, code, and app-password checks for that account or IP; signed-in sessions keep working, so an attacker can at worst hold off new sign-ins 15 minutes at a time. - Passwords are 8–1,024 characters and not on the bundled common-password list (the 10,000 most frequent of 8+ characters,
shared/src/common-passwords.ts). - Logins, failures, lockouts, CSRF rejections, password changes, session revocations, and admin user changes are logged with a
securityfield naming the event, and kept inaudit_eventswith the account concerned, the acting admin, address, and user agent. The logger redacts credentials and auth headers. - TOTP (RFC 6238: SHA-1, 6 digits, 30 s, ±1 step) is optional per user. With it on, a correct password returns a signed 5-minute challenge instead of a session;
POST /auth/login/2faexchanges it with a TOTP code or one of 10 single-use recovery codes. A code from a time step at or before the last accepted one is refused. Code failures count against the account and IP like password failures. - Starting enrolment and turning 2FA off re-check the password; turning off and regenerating recovery codes need a code. Enabling 2FA signs out the user's other sessions. Admins (
POST /admin/users/:id/2fa/reset) andcli user reset-2faturn it off and sign the user out everywhere. - App passwords are 160-bit random values shown once (
xxxx-xxxx-…; case and dashes ignored), stored as SHA-256 hashes, at most 50 per user. Creating one re-checks the account password.AuthService.authenticateAppPasswordis the only check that accepts them: it skips TOTP, refuses account passwords, shares the login throttle, and records last use at most hourly./auth/loginnever accepts them. An admin password reset revokes them; a disabled user's are refused. - Changing or resetting a password, or disabling a user, revokes their other sessions.
APP_SECRET(Docker env; SSMapp-secreton AWS) is the root of per-purpose keys derived with HKDF-SHA256 (server/src/core/crypto.ts). Stored secrets are sealed with AES-256-GCM asv1.<iv>.<ciphertext>.<tag>, authenticated against their owning row; tokens are signed with HMAC-SHA256. A new secret voids every sealed value and signature; there is no rotation.cli reseal-secretsre-seals feed passwords, plugin secrets, and TOTP secrets sealed under another instance's secret, read from stdin, with this one; feed passwords and plugin secrets this secret opens already are left, so it can be run again.
Authorization
Function level:
| Surface | Who may call it | Enforced by |
|---|---|---|
Web app files, /healthz, GET /api/v1/server, GET /api/v1/openapi.json | Anyone | — |
POST /api/v1/auth/login, POST /api/v1/auth/login/2fa | Anyone; the code step only with the challenge its login returned | Login throttle; signed challenge |
Other /api/v1/* | A cookie or bearer session of an enabled user; api sessions are ignored. While password_change_required, only session, login, logout, and password change; others get 403 password_change_required | registerAuth and requireUser (server/src/api/auth.ts) |
/api/v1/admin/* | Admins | requireAdmin |
GET /api/v1/images/<hmac>/<url> | Anyone with the signed address | Image URL signature |
/favicons/<sha256> | Anyone, for keys a feed source shows | Content key |
/feed-icons/<segment>/<id>.ico | Anyone with the user's signed segment, for that user's subscriptions only | Segment signature |
/public/feeds/<key>, /public/share/<uuid> | Anyone with the key or share id, while the owner is enabled; else 404 | access_keys, user_entries.share_id |
/public.php | Anyone; redirects only | — |
TTRSS /api/, Google Reader /accounts/ClientLogin and /reader/api/0/* | Login: anyone, with an app password. Everything else: an api session from that login | server/src/api/compat/common.ts |
Disabling a user ends their sessions, and session checks refuse disabled users, so every row above requiring a session excludes them.
Data level:
- A row with a user id belongs to that user. Services scope every read and write to the caller's id, so another user's rows answer 404.
- Feed sources and entries are shared between subscribers. A user reaches them only through their own subscriptions and user entries, and never sees who else subscribes.
- The archive of a feed is open to its current subscribers only.
- Themes: every user reads shared ones; only the author changes, publishes, or deletes one; admins may unpublish anyone's.
- A published feed or shared entry is readable by anyone holding its key or share id; only the owner regenerates the key or revokes the share.
Admins:
- Manage users (create, change role, disable, delete, reset password or 2FA), set per-site minimum intervals, and unpublish themes. The last active admin cannot be demoted, disabled, or deleted.
- See each user's login, role, status, last sign-in, and activity (requests by client, entries read) on the Operations page, per-site fetch statistics for all users together, and the audit log. They do not see other users' feeds, entries, notes, labels, filters, or preferences.
- Can sign in as a user by resetting their password. The reset is audited, ends the user's sessions and app passwords, and stops the user's own password working, so it does not go unnoticed.
- Operators with access to the database, the host, or the AWS account are outside these rules.
APIs
| Surface | Path | Notes |
|---|---|---|
| Native REST | /api/v1/* | OpenAPI at /api/v1/openapi.json: the input rules (types, required fields, lengths, ranges), generated from the shared Zod schemas; typed client in shared |
| Server info | /api/v1/server | Product, build, API version, instance name, and push key |
| Events | /api/v1/events | SSE: counters invalidation events |
| Images | /api/v1/images/<hmac>/<url> | Proxied entry images |
| Public | /public/* | Published feeds and share links |
| TTRSS-compatible | /api/, /api/index.php (POST, op) | See below |
| Icons | /favicons/<sha256> | Subscriptions' iconUrl; from the blob bucket through CloudFront on AWS |
| Feed icons | /feed-icons/<user segment>/<id>.ico | For TTRSS clients and the apps (iconsPath); see below |
| Change markers | /changes/<HMAC of the user id> | AWS only (changesPath): from the blob bucket through CloudFront, never cached |
| Google Reader | /accounts/ClientLogin, /reader/api/0/*; also under /api/greader.php | See below |
Native REST API
GET /serverreturns the product (newses; apps also accept the earlierrss-reader), the server build (NEWSES_VERSION: the commit on AWS, a Docker build argument, elsedev), the API version (API_VERSIONinshared), the instance name when the operator set one (INSTANCE_NAME; on AWS the stage'sinstanceNamein the deployment config), where its source is (source, see Third-party notices), and the VAPID public key devices subscribe to push with (push.key, API 1.11), with the UnifiedPush distributor the operator offers readers (push.distributor,PUSH_DISTRIBUTOR_URL; the Dockerntfyprofile sets it, and on AWS the stage'spushDistributorUrl), and whether users can add an email address, as user mail is configured (mail, API 1.14). A new major breaks existing apps; a new minor adds endpoints apps may require. Users who must change their password can still reach it.- Names, titles, notes, and addresses have one set of length limits (
shared/src/limits.ts). The schemas check them, and the services check them again, so the compatibility APIs and OPML import hold to them too. Titles a feed gives itself are cut to the limit instead. /api/v1responses over 1 KB are compressed for clients that accept it (Brotli at quality 4, else gzip), except event streams and images. On AWS, CloudFront's API behaviour does not cache, so it forwardsAccept-Encodingto the API and passes compressed responses through, and the Lambda adapter returns them base64-encoded, which keeps large sync and content pages under Lambda's 6 MB response limit.- CORS on
/api/v1/*allows the app originsapp://newses(Electron) andhttps://localhost(Capacitor Android): requests withAuthorizationandContent-Type,Retry-Afterexposed, preflights cached for a day. Credentials are never allowed, so apps use bearer tokens and cookie sessions stay same-origin. Other origins get no CORS headers. CORS is applied before authentication, so apps can read errors too. - Errors are
{ error, message }: a code and English text. Failures the web app shows, whose code does not say enough, addreason(ERROR_REASONSinshared) and itsparams. The web app shows the reason's text, else the code's, elsemessage. - Entries are identified by
user_entries.id. A headline list selects one stream: a subscription, a category (with subcategories;0is uncategorised), a label, a tag, or a special feed (all,fresh,starred,published,recentlyRead). - Fresh: unread entries with
sort_atwithin the user'sfreshMaxAgeHours. Recently read: entries read within the last 7 days, in reading order. - All and Fresh, and a search or catch-up without a stream, leave out entries of subscriptions hidden from All (
hideFromAll), as do their unread counts; the compatibility APIs' All, Fresh, and reading list follow them. - Scores are whole numbers within ±1,000,000, set with the entry's flags. Entries scored below the user's
scoreHideBeloware left out of subscription, category, All, and Fresh lists and unread counts; Starred, Published, label, tag, and Recently read lists show them, and catch-up marks them read. adaptiveview resolves tounreadwhen the stream has unread entries, elseall; the cursor carries the resolved view.- State changes and catch-up publish
counters; rows already in the requested state are not updated. - Compare-and-set (API 1.2), for changes sent late:
PATCH /entriesandPATCH /entries/:idtakeexpect, the values the client saw; a flag changes only where it still has that value, and entries where it has neither that nor the target keep theirs and come back inconflictswith their values now.PATCH /entries/:id/labelsand/tagsadd and remove (unknown labels ignored) and return the result.PUT /entries/:id/notewithexpectedanswers409 conflictwhen the note is neither that nor the new text. GET /archive/entrieslists past articles of the user's feeds (one subscription, or all), with search (q) and a cursor;GET /archive/entries/:keyreturns one with content and enclosures;POST /archive/entries/:key/restoretakesPATCH /entries/:id's body and returns the restored entry. Keys are opaque: the month of the article's sort time, its feed URL, and GUID.POST /published-feed/pages(API 1.5) publishes a page from outside the user's feeds: an http(s) address, and optionally a title and plain-text text, which becomes paragraphs; all sanitised. A missing title or text is read from the page, fetched as full text is; a page that cannot be read is published all the same, titled with its address. The page is the user's own entry in the pages source, read and published, with no subscription. Publishing the same address again replaces what is given, reads the page again for what is not (keeping what was stored when it cannot), republishes it, and moves it to the top. Returns the entry.POST /subscriptions/:id/debug(API 1.6) fetches a subscribed feed through the polite fetcher without validators and stores nothing: status, final and permanent URLs, headers withoutset-cookie, the body as text (first 256 KB), the parse result or error with any feeds an HTML page advertises, and up to 500 entries as ingest would store them, each with the user's enabled filters that would apply, in order up to one that stops. A paused host is reported, not asked; fetch failures say what failed without network detail.- API 1.7 adds
langto entries and archived entries, andlastErrorReasonandlastErrorParamsto subscriptions, which saylastErrorin the reader's language; apps fall back tolastError. - From API 1.8,
appearanceTheme,themeAdjustments, and/themestake each built-in theme and style, and from API 1.10 each font,articleFontincluded, from the API minor recorded for it inshared. GET /themesreturns the user's themes and those others share, each with its author and whether it is the user's. Publishing setsshared;POST /admin/themes/:id/unpublishwithdraws one, logged astheme_unpublished. Stored tokens a later version no longer accepts are left out of the response. The web app refetches the list when it regains focus, so authors' edits and withdrawn themes reach other users; a theme that no longer resolves shows Original.GET /admin/sites/ruleslists admins' minimum intervals per host;PUT /admin/sites/rules/:host(15 min to 7 days) andDELETEset and clear one, logged assite_interval_setandsite_interval_cleared. A host is given with its port when not the default, as in feed URLs.GET /admin/ops/hostsshows each host's minimum.- Plugins (API 1.15, tests and failure details 1.16,
digestsand actions 1.17;GET /server'spluginssays whether any is installed):GET /pluginslists every installed plugin to admins, with its source, instance settings, and status, and to others those on for the instance; each with its messages, settings forms, approved hosts, and the user's own settings for plugins with user scope, and for admins the ids of plugins no longer installed whose settings are kept.PATCH /admin/plugins/:idenables a plugin, sets its instance settings, and approves its hosts, logged asplugin_updated(setting names, never values);DELETE /admin/plugins/:idremoves a plugin's settings, every user's, its storage, and its waiting events and deliveries, installed or not, logged asplugin_removed.PATCH /account/plugins/:idsets the user's settings of a plugin on for the instance,DELETE /account/plugins/:idremoves them and the plugin's storage, events, and deliveries for the user.POST /account/plugins/:id/testtests a plugin with user settings with the user's,POST /admin/plugins/:id/testone without with the instance's, each at most 5 a minute per user; a plugin off there is refused (409 plugin_off).POST /account/plugins/:id/actions/:nameandPOST /admin/plugins/:id/actions/:namerun an action as the test routes run a test (10 a minute per user); adigestaction is refused without unread entries from the last day (digest_test_empty). No response carries a secret's value. GET /syncreturns categories, subscriptions, labels, and entries (without content) changed since a token, and deleted ids. Each call only covers changes below the oldest transaction id still in progress in the database, so rows committed late are never skipped and the clock plays no part. A first call takes every row, then the token carries on from that call's watermark. Entries page by (sync_xid, id);moreasks for another call. Tokens from another copy of the instance (a new sync epoch, as after a restore), older than the 30-day tombstone retention, or unreadable get410 resync_required; tokens from beforesync_xidget the rows written before it byupdated_at, then the rest.GET /sync/tokenreturns a token at the watermark without walking history, for clients that load current state from the headline lists. Entries carryreadAtandcontentVersion, an opaque value that changes with the content hash or extracted full text.POST /entries/contentstakes up to 100 ids in priority order and returns each entry's stored content, full text, enclosures, and content version, with its images (those of the content, then image enclosures; at most 30) mapped to signed proxy paths whatever the user'sproxyImages; ids the user does not hold come back asmissing, and those past the size budget (never the first) asdeferred.
Filters:
- Patterns are RE2 syntax (re2js), matched case-insensitively and in linear time; patterns RE2 cannot compile are refused when saved.
contentrules match the stored HTML;tagrules match each tag; a category scope includes its subcategories.- Enabled filters run in order on each user entry as it is delivered (fetch and new-subscription backfill), in the same transaction, until a
stopaction. Matching filters' actions combine: delete wins, scores add up within ±1,000,000, labels and tags accumulate (at most 50 tags). POST /filters/testchecks a draft against the user's 1,000 most recent entries and returns up to 50 matches.POST /filters/:id/applyruns one saved filter over existing entries, newest first, for at most 15 s per call, returning a cursor to continue; it never deletes kept entries (starred, published, noted, labelled, shared).
Events stream:
- Events are per-user invalidation signals; clients refetch what they describe. Events of one type within 1 s are sent once.
X-Accel-Buffering: nodisables nginx buffering; a comment line every 25 s keeps proxies from timing out; streams end after 30 minutes and clients reconnect, which re-checks the session.
Push:
PUT /push/subscription(API 1.11) takes the endpoint (https, at most 2,048 characters) and keys ofPushSubscription.toJSON()as the calling session's one subscription; another session's with the same endpoint moves to it.DELETEremoves it, as does the session ending (sign-out, revocation, expiry).- The VAPID key pair is derived from
APP_SECRET(vapid); the contact it names to push services isPUBLIC_URLwhen it is https, else the project site. - Ingest pushes the unread entries a fetch delivered to users with subscriptions: one message per user per window of 27 minutes, so a 30-minute dispatch schedule pushes every cycle. Entries within a window wait for it to end and go out on the next flush (every 5 minutes on Docker, after each dispatch on AWS). A user's first subscription counts from then on; a new subscription's backfill, imports, and entries already read are not counted. With nothing to count, nothing is sent and the window stays as it was.
- Messages are JSON, encrypted for the device (RFC 8291,
aes128gcm) and signed (RFC 8292):count, up to 5 places (the category, else the feed, titles cut to 80 characters) with their counts,morePlaces, andtarget, the stream to open (the one feed, the one category, else/all). TTL 12 h,Topic: new-entries,Urgency: normal. - Requests to push services have the fetcher's private-address guard (
FETCH_ALLOW_PRIVATE_NETWORKS), except for hosts inPUSH_TRUSTED_HOSTS(the operator's own distributor, which may resolve to the LAN), and a 10 s timeout; to hosts inPUSH_TOKENS(host=tokenpairs; on AWS the SecureString/<prefix>/<stage>/push-tokenswhen the stage setspushTokens) they carry that ntfy access token as theauthparameter beside VAPID, for a ntfy that only lets users publish. They are counted in the outbound metrics with purposepush, not in per-host statistics. 404 and 410 delete the subscription; other failures are logged and the message is dropped.
Public pages
/public/share/<uuid>: a shared entry as a server-rendered HTML page.user_entries.share_idis a random UUID set when the user shares the entry and cleared when they revoke it. The page's text is in the viewer'sAccept-Language, else its owner'slanguage, else English, withVary: Accept-Language; the not-found page skips the owner./public/feeds/<key>: RSS 2.0 of the user's 50 newest published entries, with content. The key is 32 random bytes (base64url) inaccess_keys, stored as is so the address can be shown again; regenerating replaces it. Its title and description, like the OPML export's title, are in the owner'slanguage. It sets no<language>, which would claim one for the articles./public.php?op=rss&id=-2&key=<key>and/public.php?op=share&key=<uuid>, TTRSS's addresses for the same pages, redirect (301) to them; otherpublic.phprequests answer 404.- The share and feed pages answer 404 for unknown ids. Pages send their own CSP (no scripts, frames only from the sanitiser's video hosts),
Referrer-Policy: no-referrer, andX-Robots-Tag: noindex. - Images go through the image proxy when the owner has it on. Feed URLs are absolute, from
PUBLIC_URL, else the request's origin. - The feed carries a weak ETag over its items and answers
If-None-Matchwith 304.
TTRSS-compatible API
- Operations:
login,logout,isLoggedIn,getApiLevel,getVersion,getConfig,getPref,getUnread,getCounters,getFeeds,getCategories,getFeedTree,getHeadlines,getArticle,updateArticle,catchupFeed,updateFeed,getLabels,setArticleLabel,subscribeToFeed,unsubscribeFeed,shareToPublished. shareToPublishedpublishesurlasPOST /published-feed/pagesdoes, with tags stripped fromtitleandcontent(as TTRSS does), andtitleandcontentpast the limits cut rather than refused.- Feed IDs are subscription IDs; special feed IDs:
-1starred-2published-3fresh-4all-6recently read0archived (empty)
- Category IDs are category IDs;
0uncategorised,-1special feeds,-2labels,-3all feeds,-4all feeds with special feeds and labels. Category streams include subcategories. - Labels are feed ID
-1025 - label_id, in feed lists, counters,getLabels,setArticleLabel, and each headline'slabels([feed ID, caption, fg, bg]). A non-numericfeed_idnames a tag. getHeadlinespages bylimit(at most 200) andskip;view_modeunread,adaptive, andmarked(starred) apply, others list all;order_by=date_reverselists oldest first;searchuses full-text search, across all feeds withsearch_mode=all_feeds.updateArticlefields: 0 starred, 1 published, 2 unread, 3 note (data); modes 0 clear, 1 set, 2 toggle.subscribeToFeedcodes: 0 already subscribed, 1 added (feed_id), 2 invalid URL or login, 3 no feed found, 4 several feeds found (feeds: URL → title), 5 fetch failed.loginandpasswordsubscribe with HTTP Basic credentials.getConfig(alsoconfigin theloginanswer) givesicons_urlfeed-icons/<user segment>: icons are served at/feed-icons/<segment>/<subscription id>.ico, the segment being the user ID signed with thefeed-iconskey.- Content goes through the image proxy for users who turned it on.
getPrefanswers the TTRSS preferences that have an equivalent here andnullfor others, which are logged. - Requests are POSTs whose body is JSON, whatever its declared type, or form-encoded; query strings are ignored, so passwords never appear in logged URLs.
sidis anapisession token;loginaccepts app passwords only and reports API level 20. - Parameters are typed as TTRSS clients send them: numbers and booleans as JSON values or strings, id lists as arrays or comma-separated. Values past
/api/v1's length limits answerINCORRECT_USAGE, or code 2 fromsubscribeToFeed. - Every answer is HTTP 200
{seq, status, content},seqechoing the request. Errors have status 1 andcontent.error:NOT_LOGGED_IN,LOGIN_ERROR,API_DISABLED(password must be changed),UNKNOWN_METHOD(withmethod),INCORRECT_USAGE,FEED_NOT_FOUND.
Google Reader API
- Auth:
ClientLogin(POST formEmail,Passwd; app passwords only) answersSID=…,LSID=null,Auth=…lines, or 401Error=BadAuthentication. Calls sendAuthorization: GoogleLogin auth=<token>; without a validapisession they get 401, or 403 while the password must be changed./reader/api/0/tokenissues theTwrite token, which writes accept unchecked: header authentication leaves no cross-site forgery to prevent. - Endpoints (JSON whatever
outputasks; writes answerOK; others 404):user-info,subscription/list,subscription/edit(subscribe,unsubscribe,edit),subscription/quickadd,subscription/export(OPML)tag/list,unread-countstream/contents(stream in the path ors),stream/items/ids,stream/items/contents(irepeated)edit-tag,rename-tag,disable-tag,mark-all-as-read
- Item IDs are
user_entriesIDs: long formtag:google.com,2005:reader/item/<16 hex>in items, decimal instream/items/ids; requests may use either, or bare 16-digit hex. - Streams (
user/<id>/…is the same asuser/-/…):
| Stream | Selects |
|---|---|
user/-/state/com.google/reading-list | All |
user/-/state/com.google/starred | Starred |
user/-/state/com.google/read | All, read only |
user/-/state/com.google/broadcast | Published |
user/-/label/<name> | The folder with that name, else the tag |
feed/<subscription id> | That subscription; feed/<feed URL> also matches |
- Folders are categories, named by their path (
Parent/Child); tags are labels. A label whose caption equals a folder's name is hidden from the API, and tagging items with a folder's name does nothing. Tagging with an unknown name creates the label;subscription/editwith an unknown folder creates a top-level category. it/xtinclude or exclude thereadandstarredstates (kept-unreadcounts as unread);otandnt(seconds) bound the sort time,otinclusive;r=olists oldest first;ccontinues from a page'scontinuation.- Page sizes:
stream/contentsdefault 20, at most 1,000 and within the entry list's content budget;stream/items/idsdefault 1,000, at most 10,000;stream/items/contentsat most 1,000 ids. edit-tagadds and removesread,kept-unread(marks unread),starred,broadcast(published), and labels.mark-all-as-readmarks the stream read, withts(microseconds) only entries delivered to the user by then.- Items carry
categorieswith their states, folder, and tags;origin.streamIdis the subscription;summary.contentgoes through the image proxy for users who turned it on.subscription/listgivesiconUrlfrom the feed icon path, absolute fromPUBLIC_URLor the request's origin. quickaddsubscribes to the first feed a page advertises.- Names, titles, and addresses past
/api/v1's length limits answer 400;quickaddanswersnumResults: 0.
Both compatibility APIs log each unsupported call with the client's user agent. COMPAT_TRACE logs every call and its parameters, credentials redacted; it is on for the AWS dev stage.
The settings page shows apps' connection details from /api/v1/auth/app-passwords/connection: the server URL (PUBLIC_URL, else the request's origin) and the suggested sync interval, 60 minutes.
Deployment
Self-hosted
docker/compose.yaml:
| Service | Image | Notes |
|---|---|---|
db | postgres:18-alpine | Named volume |
migrate | app image, migrate | Runs to completion before server/worker start |
server | app image, server | Serves API and SPA, and the downloads volume at /downloads/ once compose.apps.yaml has built the apps; behind the user's reverse proxy for TLS; /healthz checks database and queue |
worker | app image, worker | Jobs and scheduler; healthy while the feed dispatch, every minute, has written its heartbeat file within 3 minutes |
backup (backup profile) | postgres:18-alpine | Nightly pg_dump to a volume |
dashboards (observability profile) | app image, sh | On each start, replaces the dashboards volume's contents with the image's copy of docker/observability/dashboards, so an upgrade or up -d --build refreshes them; lgtm waits for it |
ntfy (ntfy profile) | binwiederhier/ntfy, pinned by digest | UnifiedPush distributor for the Android app at NTFY_HOST, its own hostname (it does not run under a path), published on NTFY_PORT (8081) or routed by compose.nginx-proxy.yaml; deny-all, with anyone allowed to publish to up* topics (write-only) unless NTFY_AUTH_ACCESS replaces that (*:up*:deny: only users given access, such as the server's with its token in PUSH_TOKENS), so reading needs a user given access; the web app off; users and cache in the ntfy volume. NTFY_HOST also sets the app containers' PUSH_DISTRIBUTOR_URL and PUSH_TRUSTED_HOSTS |
lgtm (observability profile) | grafana/otel-lgtm | OTLP collector, Tempo, Loki, Prometheus, and Grafana on 127.0.0.1:3000, with the dashboards from the dashboards volume and their provisioning file from an inline Compose configs entry |
- No service mounts host files, so a release's compose file runs from a folder holding only it and
.env; the project directory (docker/in a checkout) holds.env, whoseCOMPOSE_PROFILESandCOMPOSE_FILEname the stack's optional services and override files for every command run there. Inlineconfigsneed Docker Compose 2.23.1 or later. docker/compose.apps.yaml(override, not published with releases, as it builds from a checkout): theappsservice (appsprofile, run withrun --rm, built again on each run withpull_policy: build) ondocker/apps.Dockerfile(Node on Debian, pinned by index digest, with JDK 21, the Android SDK, the command-line tools checked by SHA-256, 32-bit Wine for the NSIS installer, which electron-builder runs to write the uninstaller, and jsign, checked by SHA-256;linux/amd64only, as the Android build tools are x86_64 only), built from the checkout withapps.Dockerfile.dockerignore, which leaves out installs, builds,.envfiles, and keystores.docker/apps-build.shbuilds, forAPPS_PLATFORMS(linux,windows,android; all three by default), the AppImage and deb withlatest-linux.yml, the NSIS installer, block map,latest.yml, zip, and portable exe (one electron-builder run for both desktop platforms), and the signed APK, their SBOMs and the OpenAPI document, forRELEASE_TAGandPUBLIC_URL/downloads(https only), then runspublish.ts --platformsandpublish-local.tsinto thedownloadsvolume. An install from a release's files runs it from a checkout with--env-filenaming its.env, which gives the project name and so the volume. The keystore (base64), its passwords, and its alias are Compose secrets from.envvariables (ANDROID_KEYSTORE_BASE64,ANDROID_KEYSTORE_PASSWORD,ANDROID_KEY_ALIAS,ANDROID_KEY_PASSWORD), read as files, never the container's environment; with any empty, Android stops the build. The Windows apps are signed off Windows with jsign (electron-builder.jsign.cjs, a sign hook given jsign's options in a file, SHA-256 with an RFC 3161 timestamp, replacing any signature) from a.pfx(WIN_CERTIFICATE_BASE64,WIN_CERTIFICATE_PASSWORD; DigiCert's timestamp server) or Artifact Signing (AZURE_CLIENT_SECRET, withAZURE_TENANT_ID,AZURE_CLIENT_ID, and theWIN_SIGNING_*values as environment; Microsoft's timestamp server), whichever is set, both refused; the secrets are Compose secrets, which jsign reads from files (file:). Signing needsWIN_PUBLISHER_NAME, checked against a.pfx's CN and written into the app's feed config; with neither, the Windows apps are unsigned and update by the downloads page. Compose needs every secret's variable in.env, even empty. Gradle and the Electron downloads cache inapps-gradleandapps-cache.servermounts thedownloadsvolume read-only asDOWNLOADS_DIR; the image creates/data/downloadsowned bynode, so the volume is writable by the apps build, which runs asnodetoo.- With
DOWNLOADS_DIR, the server serves it at/downloads/with the downloads layout's headers (below), the page with its CSP;/downloadsredirects there, and a missing file is a 404, never the SPA.publish-local.tscopies the versioned files first, then renames the feeds,latest.json, andindex.htmlinto place, and deletes the folder of the prerelease it replaces. - App image (
docker/Dockerfile): Node on Alpine, pinned by index digest, forlinux/amd64andlinux/arm64. OCI labels come from the build argumentsNEWSES_VERSION,NEWSES_REVISION(commit), andNEWSES_SOURCE(repository URL); the web build runs on the builder's platform. It installs only the server'sdependencies: the packages only the Lambdas load (the Athena, SNS, SQS, and SSM clients,@fastify/aws-lambda) are devDependencies, imported only underentrypoints/lambda(lint-enforced).
AWS
flowchart LR
U[Browser / apps] --> CF[CloudFront]
CF -- default --> S3W[(S3: SPA)]
CF -- "/downloads, /downloads/*" --> S3D[(S3: downloads)]
CF -- "/favicons/*" --> S3B
CF -- "/api, /api/*, /reader/*, /accounts/*, /feed-icons/*, /public/*, /public.php" --> API[HTTP API] --> FA[λ api]
EB[EventBridge Scheduler] --> FT[λ tick]
FT --> QF[[SQS fetch]] --> FF[λ fetch]
FF --> QI[[SQS favicon]] --> FI[λ favicon]
FA & FF --> QX[[SQS extract]] --> FX[λ extract]
FA & FF & FT --> QP[[SQS plugin-dispatch]] --> FP[λ plugin]
FA & FT --> QD[[SQS digest-send]] --> FD[λ digest]
FA & FT & FF & FI & FX & FP & FD --> DB[(RDS PostgreSQL, shared by stages)]
FA & FT & FF & FI --> S3B[(S3: blobs)]
FA & FT --> ATH[Athena + Glue: archive] --> S3B
FA & FF & FI & FX & FP & FD --> NET((Internet feeds))
- Stacks per stage:
Params(generated credentials),Data(blob bucket, archive catalog),App(functions, HTTP API, queues with dead-letter queues, schedules, migrate trigger, alert topic),Edge(CloudFront, SPA and downloads buckets, DNS records),Release(the release pipeline), all in the deployment's region. Both pipelines also deploy the shared<prefix>-db-paramsand<prefix>-dbstacks (VPC with public subnets only, the database instance) before their stage, and the shared<prefix>-budgetstack alongside it; both produce the same resources, without construct-path metadata, and a test holds them equal. The pipelines deploy each stack in one action, without change sets;Releasedeploys alongsideParamsandData. CloudFront uses an existing certificate in us-east-1 covering every stage's domain, imported by ARN; DNS records go in an existing Route 53 zone that each stage's domain is directly under. - Names: stacks are
<prefix>-<stage>-{params,data,app,edge,release,pipeline},<prefix>-db-params,<prefix>-db, and<prefix>-budget, and resources with settable names use<prefix>-<stage>-<role>(functions, log groups, queues, schedules, HTTP API, CloudFront function and policies) or, when shared,<prefix>-db. Bucket names are generated from the stack name, except<prefix>-<stage>-downloads-<account>, which the release pipeline is granted by name. Everything is taggedproject=<prefix>, and everything but the shared stacksstage=<stage>. - Functions run outside any VPC, so they reach feeds without NAT. The database is one RDS PostgreSQL 18 db.t4g.micro instance,
<prefix>-db:- Single-AZ, 20 GB gp3 that can grow to 50 GB, 14-day backups, deletion protection, and a final snapshot on removal.
- Publicly reachable on 5432, with TLS required (
rds.force_ssl); its address is in the String parameter/<prefix>/db/endpoint. - Each stage has a database and login role
<prefix>_<stage>, which owns it.PUBLIChas noCONNECTon it, so stages cannot reach each other's data. - The
migratefunction creates or updates the role and database as the master userrss_admin(password in/<prefix>/db/master-password, generated by<prefix>-db-params, which deploys first because CloudFormation resolvesssm-securereferences when a deployment starts) before migrating.
- Dispatch runs every 30 minutes, so a feed is checked at most that often, whatever its interval; purge (every 6 h), auth prune (hourly), and archive compaction (daily, 04:00 UTC) fall on dispatch times. One fetch invocation handles one host's batch; at most 8 run at once.
- CloudFront adds a secret
x-origin-verifyheader to API requests; the API refuses requests without it. - CloudFront does not forward the viewer's
Host, so functions getPUBLIC_URLset to the stage's domain. /api/v1/images/*is cached at the edge (managed CachingOptimized policy: no cookies or viewer headers in the key, TTL from the API'sCache-Control); other API paths are not cached./favicons/*comes from the blob bucket through its own Origin Access Control, with no function involved; the Data stack's bucket policy lets the account's distributions read onlyfavicons/*. The edge keeps icons a year, and a response headers policy sets theirCache-Control(S3 stores none) and sandboxing CSP.- Generated credentials are Standard SSM parameters under
/<prefix>/<stage>/, created once by a custom resource inParamsand deleted with it;Paramsdeploys beforeApp, whose functions read them:db-password(the stage role's),admin-password, andapp-secret(SecureString),origin-header(String, because CloudFront resolves only String parameters).TRUST_PROXYis two hops (API Gateway appends CloudFront's address after the viewer's). - The SPA bucket is private, accessed via Origin Access Control.
assets/is cached as immutable; other files are revalidated, and each deployment invalidates the distribution. - The downloads bucket is private behind its own Origin Access Control, written only by the release pipeline (kept with the stack when the stage retains data).
/downloadsredirects to/downloads/, and folder paths serveindex.html; the page has its own CSP (no scripts). Pages on the stage'sdownloadsCorsOrigins(the project site) may fetch the downloads cross-origin (GET and HEAD). - Logs go to CloudWatch, kept a month. No CloudWatch metrics, alarms, or dashboards; the Operations page reports, and
ops.checkruns after each dispatch. - Tracing: functions run the ADOT layer (
adotLayerArnin the deployment config) when the stage'straceSamplingis above 0. The SDK samples that share of traces by trace id (traceidratio) and sends spans to X-Ray through Lambda's local endpoint; Lambda active tracing (not needed for these spans), Application Signals, and X-Ray Transaction Search are off. Only theaws-lambdaandaws-sdkinstrumentations run; undici is never instrumented, so feed requests carry no trace headers. Only our spans and AWS SDK calls are recorded: functions are bundled, sopgis not instrumented. Service names are<prefix>-<function>. - Alerts:
tickpublishes alert changes to the SNS topic<prefix>-<stage>-alerts; email subscriptions are added outside the stack (seeAGENTS.md), so addresses stay out of the repository. - User mail: with the stage's
mailoption, the app stack makes the stage domain an SES identity (Easy DKIM records, MAIL FROMbounce.<domain>with its MX and SPF records, in the hosted zone) and the configuration set<prefix>-<stage>-mail, which suppresses addresses that bounced or complained. Onlyapianddigestmay send (ses:SendEmailon the identity, the configuration set, and email-address identities, which the SES sandbox also checks for recipients); they andtick, which queues digests only with mail, getMAIL_SES_CONFIGURATION_SET; mail comes fromnewses@<domain>. A new account is in the SES sandbox, which delivers only to verified addresses until production access is granted (seeAGENTS.md). - Pipeline results: the stage's pipeline stack owns the SNS topic
<prefix>-<stage>-pipelines; CodeStar Notifications rules send each succeeded or failed run of the stage's deploy and release pipelines to it. Email subscriptions are added the same way as for alerts. - Budget: the
<prefix>-budgetstack holds one monthly AWS Budget (budgetUsdin the deployment config) over running the project: everything taggedproject=<prefix>, both stages, except the CodeBuild and CodePipeline services. Whichever pipeline runs first creates it; later runs change nothing, and removing a stage leaves it in place. It notifies its own topic,<prefix>-budget, at 80% and 100% of actual spend and 100% of forecast. It counts only once theprojectcost-allocation tag is active, which only the paying account (an organization's management account) can do. Untaggable charges (X-Ray, tax) fall outside it. - Web traffic is same-origin through CloudFront. The API behaviour forwards
OriginandOPTIONS, so the apps' CORS preflights reach the API; the pipeline smoke test sends one.
Constraints:
- Responses are capped at 6 MB; list pages with content, and contents batches, end early past 2 MB of content and full text (UTF-8).
- No SSE. Each
countersevent rewrites the user's change marker,changes/<HMAC of the user id>(changeskey) in the blob bucket, with new text (one more write for events during one in flight). Login and session responses give its path aschangesPath(API 1.11). Open apps poll it every 60 s while visible (hidden desktop apps with notifications on: every 30 min) through CloudFront's/changes/*behaviour, never cached and answered by S3, so polls reach neither Lambda nor the database; counters are fetched only when its text changed. Apps open no event stream then. Responses areno-cache, revalidated by the browser, and readable from the apps' origins (Access-Control-Allow-Origin: *); the path needs no session. Before a first event S3 answers 403, read as no marker yet.
Releases
A version tag releases the apps, and the server image when the stage has an imageRepository, to one stage: prerelease tags (v1.2.3-rc.1) to dev, other v* tags to prod. The version comes from the tag only.
| Stage | Runs |
|---|---|
| Source | The tagged commit, over the GitHub connection. Runs without a tag (creation, a manual release) skip the next stages. |
| Build | In parallel: Linux x64 (release-linux.yml: AppImage, deb, latest-linux.yml, signed APK, desktop and mobile SBOMs, the OpenAPI document; installs the Android SDK and JDK 21) and Windows Server 2022 (release-windows.yml: Node 24 by download, the Artifact Signing client tools, signed NSIS installer, block map, latest.yml, zip of the signed app, signed portable exe). With an image repository, also the image legs (release-image.yml, privileged): x64 and ARM each build the server image natively with buildx and push it by digest alone, without provenance attestations; the x64 leg adds the image SBOM, from syft on the pushed image. Each hands exactly its files to a scratch bucket (7-day lifecycle) under releases/<tag>/, the image legs their digests as image-<arch>.digest. |
| Publish | release-publish.yml: checks the full set, adds the installers' URLs and hashes to the SBOMs, adds the server's files with the image, writes SHA256SUMS, the feeds, latest.json, and index.html, pushes and signs the image's version tag, uploads to the downloads bucket, HEAD-checks every URL, moves the image's other tags, then tags the prerelease it replaced superseded=true. |
- Downloads layout:
downloads/<version>/<file>(immutable; installers download as attachments,.apkasapplication/vnd.android.package-archive, SBOMsnewses-<version>-{desktop,mobile,image}.cdx.jsoninline asapplication/vnd.cyclonedx+json, the apps' naming the installers they describe by URL and SHA-256,newses-<version>-openapi.jsoninline asapplication/vnd.oai.openapi+json, the release's/api/v1/openapi.jsonbuilt without a database, with the image the server's files inline, andSHA256SUMSfor every versioned file);downloads/latest.yml,latest-linux.yml(electron-updater, pointing into the version folder),latest.json(ReleaseManifestin@newses/shared/release: each platform's installers when the release built them, all three on AWS and those asked for on Docker, with only their feeds, SBOMs, and page sections;serverwhen the stage publishes the image), andindex.html(no-cache; per file its SHA-256 and commands to download, check, and install it, as no scripts run on the page). - Server files, from
docker/:newses-<version>-compose.yaml,compose.yamlwithoutbuild:and with the image pinned as<repository>:<version>@<digest>, still overridable withNEWSES_IMAGE;newses-<version>-env.example,.env.exampleas is;newses-<version>-compose.nginx-proxy.yaml, the nginx-proxy override as is;newses-<version>-compose.plugins.yaml, the plugins override building from the pinned image, still overridable withNEWSES_IMAGE;newses-<version>-cosign.pub, the image's signing key. The page's commands save them ascompose.yaml,.env,compose.nginx-proxy.yaml,compose.plugins.yaml, andcosign.pub. - Superseded prereleases expire 30 days after upload; prod releases are kept.
- Server image:
publish-image.ts join --dry-rungives the digest the legs' digests join into, which the compose file pins; once the files are written,joinpushes the multi-arch image under the version's tag (X.Y.Z,X.Y.Z-rc.N), must give that digest, and signs it once with cosign and the KMS keyalias/<prefix>-image-signing, recorded in Rekor and stored under the tagsha256-<digest>.sig; after the URL check,tagmoves the floating tags to it (infra/src/release/image.ts): a release movesX.Y,X, andlatestwhen it is the newest release each covers; a prerelease movesnextand deletes every other prerelease tag with its images and signature. A version's tag never moves: publishing it again must join the same images, so a failed publish is retried with the build legs' files, and a rebuild is a new version. The build stage pulls the Node base from ECR Public's mirror of Docker Hub's official images, at the Dockerfile's digest; BuildKit and the Dockerfile frontend come from Docker Hub. - Release builds embed the stage's
/downloadsURL (on Docker,PUBLIC_URL/downloads): desktop as electron-updater's generic feed (electron-builder.release.cjs, no update channels), Android asDOWNLOADS_URLin the bridge. - Signing material is SecureString parameters under
/<prefix>/release/windows-signing/and/<prefix>/release/android-signing/, shared by both stages and written byscripts/windows-signing-setup.shandscripts/android-signing-setup.sh. Each build project reads only its own platform's parameters, as project environment variables; only the publish project writes the downloads bucket, and only its stage's. The image legs push to the stage's image repository; only the publish project also tags and deletes there, and signs with the image signing key, which it is granted by its alias. scripts/try-release.shruns the dev legs on the working tree under a made-up prerelease tag, with a dry-run publish unless--publish; the dry run deletes the images the image legs pushed.
Deployment config:
- The account-specific values live in
infra/deploy.config.json, never committed;infra/deploy.config.example.jsonshows the shape, validated byinfra/src/deploy-config.ts:resourcePrefix(<prefix>in this section: the start of every physical name, tag, and parameter path, with_for-in database names; the example's isnewses), account, region, GitHub repository and CodeConnections connection, certificate, hosted zone, ADOT layer, budget, and the stages (devand/orprod: branch, release tags, domain, data retention, backups, compatibility trace, archive, trace sampling, downloads CORS origins, server image repository, the UnifiedPush distributor readers are offered, whether the functions read push tokens, plugins). - The pipelines' synth step writes that file from the String parameter
/<prefix>/deploy-config; a change to it takes effect on each pipeline's next run, whichstore-deploy-config.sh --release STAGEstarts. Tests synthesise against the example. - Scripts that act on a stage (
reset-stage.sh,freeze-stage.sh,try-release.sh,import-ttrss.sh --aws,export-instance.sh --aws,restore-instance.sh --aws, the signing setups with--ssm,image-registry-setup.sh) read the region, domains, and account from the same file.
Operator setup, once per account:
- Prerequisites: a CodeConnections connection to the GitHub repository, an ACM certificate in us-east-1 for the stages' domains, and the Route 53 hosted zone.
- In an organization's member account, Budgets works only after the management account has launched Cost Explorer (console only) and allows member accounts access in Cost Management preferences; until then the
<prefix>-budgetstack fails. The management account's IAM roles reach these pages only once its root user activates IAM access to Billing information. infra/deploy.config.jsonfrom the example, then stored as the parameter (AGENTS.md).pnpm --filter @newses/infra cdk bootstrap aws://<account>/<region>pnpm --filter @newses/infra cdk deploy <prefix>-dev-pipeline(and<prefix>-prod-pipeline); a new pipeline runs once on creation, and later changes deploy through it, release stacks included.- In the paying account's Billing console (or
aws ce update-cost-allocation-tags-status), theprojectcost-allocation tag activated once it appears, up to 24 h after the first deployment. - The signing parameters, before the first release:
scripts/windows-signing-setup.sh --ssmandscripts/android-signing-setup.sh --backup DIR --ssm. - The server image repository, before the first release that publishes the image:
scripts/image-registry-setup.shcreates the ECR Public repository (in us-east-1) with its gallery listing and prints its URI for the stages'imageRepository, and creates the image signing key (ECDSA P-256, in the deployment's region) and prints its public key. A custom registry alias, claimed in the ECR Public console, gives the repository a second URI; the default alias's keeps working. - The first admin is the deploy config's
adminLogin, with a generated password in the SSM SecureString/<prefix>/<stage>/admin-passwordthat must be changed at first sign-in. If it expires first,reissue-admin(AGENTS.md) replaces it.
Moving an instance
scripts/export-instance.sh writes a bundle that scripts/restore-instance.sh loads into another instance, replacing its data; either end is a Docker install or an AWS stage.
- The scripts, and
import-ttrss.sh, act on the Docker install whose compose files--compose(repeatable) orCOMPOSE_FILEnames, else the checkout'sdocker/compose.yaml; its.env, project name, and image come with it (scripts/lib/docker-stack.sh). They warn when the install's image is a release other than the checkout's commit, and give commands for the install in use.
| Bundle file | Contents |
|---|---|
manifest | key=value lines: format (1), source, export time, whether blobs are archive only, user, subscription, entry, and blob counts; written last, so a bundle without it is incomplete |
db.dump | pg_dump -Fc --no-owner --no-acl, without the pgboss schema or the rows of sessions, push_subscriptions, push_state, digest_state, login_attempts, rate_limits, the hourly stats, ops_alerts, and ops_state |
migrations | The source's applied migration hashes |
blobs/ | LocalBlobStore layout (data files, content types under .meta/); cli blobs pull|push DIR copies it from and to S3 |
app-secret | The source's APP_SECRET, for re-sealing only |
- The bundle directory is mode 0700 and holds password hashes and the source's secret.
- The database is dumped before blobs are copied: purge archives entries before deleting them, so a running source can at worst leave an entry both live and archived.
- A restore is refused unless the target has applied every migration in
migrations; the target's newer ones run after the restore (migrate). - The restore stops the target, then drops
drizzle,pgboss, andpublicand restores the dump in one transaction, committed only once the whole dump was read; it then migrates, runscli reseal-secrets, empties and refills the blob store, purges AWS job queues, and starts the target. The target keeps itsAPP_SECRET, configuration, and SSM parameters. - Ids are unchanged, so share links, access keys, and app passwords stay valid; sessions end, and the sync epoch is new, so apps sync from scratch; image-proxy and feed-icon signatures are made again with the target's keys.
- Freezing an AWS stage (
freeze-stage.sh,export-instance.sh --freeze, and every restore) sets the reserved concurrency ofapiandtickto 0 and disables the event source mappings offetch,favicon,extract,plugin, anddigest, so jobs wait in their queues rather than fail into the dead-letter queues; unfreezing removes the reserved concurrency and enables the mappings. Docker's equivalent stopsserverandworker.
SBOMs
CycloneDX 1.6, one per deliverable, composed by infra/src/release/build-sbom.ts (scripts/sbom.sh locally) as newses-<version>-<deliverable>.cdx.json:
| Deliverable | Contents | Source |
|---|---|---|
server | Server dependencies (Lambdas and Docker), and the Lambda-only devDependencies with their dependencies; with --plugins STAGE, the stage's installed plugins | pnpm sbom --prod, and pnpm sbom selected; npm sbom in server/.plugins/<stage> |
image | Docker image: Alpine packages, Node, node_modules | syft on the built image (released: the linux/amd64 one) |
web | Web app dependencies | pnpm sbom --prod |
desktop | Web app, Electron, electron-updater and its dependencies | pnpm sbom, selected (the main process is bundled, so all are devDependencies) |
mobile | Web app, Capacitor packages, the APK's release runtime classpath | pnpm sbom --prod, CycloneDX Gradle plugin (:app:cyclonedxDirectBom) |
- Workspace packages (
@newses/*at0.0.0) and Gradle projects are first party and left out; the root component isnewses-<deliverable>, linked to therepositoryURL in the rootpackage.json. - The release pipeline publishes the desktop and mobile SBOMs, and the image's when the stage publishes the image; the others are made locally.
- Dependency-Track is an external server; uploads run locally (
PUT /api/v1/bom, auto-creating the project). Projectnewses-<deliverable>, version the release's or, untagged, the branch's; tagsnewsesandprod(release),dev(prerelease), orlocal(untagged); tagged uploads become the latest version. The API key needsBOM_UPLOAD,PROJECT_CREATION_UPLOAD, andVIEW_PORTFOLIO.
Third-party notices
What each build bundles, as { name, version, license, text, notice, url } entries (shared/src/third-party-licenses.ts), shown in the About tab with the acknowledgements in shared/src/credits.ts:
| Build | File | From |
|---|---|---|
| Web (both modes) | third-party-licenses.json beside index.html, precached | Rollup chunks and assets of the app and service worker builds (web/vite.config.ts) |
| Desktop | third-party-licenses-platform.json beside the web build | esbuild metafile of the main and preload bundles, and Electron; Electron's LICENSE.electron.txt and LICENSES.chromium.html sit beside the executable |
| Android | third-party-licenses-platform.json beside the web build | esbuild metafile of the bridge, the plugin packages, and, with an APK, the release classpath's CycloneDX SBOM (texts linked, not shipped) |
| Server | third-party-licenses.json beside server/src/licenses.ts (Docker) or the Lambda handler | Docker: installed node_modules, and the plugins' with compose.plugins.yaml; AWS: esbuild metafile (plugins included) and the installed argon2 |
- Each build fails on a package whose licence is outside
ALLOWED_LICENSES(AGPL-compatible) or unknown;pnpm checkchecks the production dependencies ofserver,web,mobile, andsharedthe same way. GET /server/licensesreturns the server's to signed-in users, 404 where the build wrote none (development).sourceinGET /server:SOURCE_URL(Docker), the stage'ssourceUrl(AWS), else the rootpackage.jsonrepositoryat the release tag (/tree/v1.2.3) or commit (/tree/<sha>), or the repository itself for other builds.
Project site
- The landing page, user guides, contributor pages, and download page are a VitePress site in
newses-app/newses.app, with its own CDK app and pipeline, in this deployment's AWS account but in separate stacks. This repository's builds, image, and stacks never reference it. - Domains:
newses.app(www.newses.appredirects to it) anddev.newses.app(not indexed), both under thenewses.apphosted zone and certificate. No analytics or cookies. - The site's
devandmainbranches build from this repository's matching branch, readingdocs/architecture.md,docs/adr/, andAGENTS.mdat build time and publishing them under/contributing/;requirements.mdis not published. /downloadand the self-hosting guides read the matching app stage's/downloads/latest.jsonin the browser, and the guides the server's files it names, so a release needs no site rebuild.