Skip to content

Frontend and API ​

API Design ​

The reader calls the backend directly through the configured API base (PUBLIC_API_BASE). There is no Backend for Frontend (BFF).

Routes read state from the edition controller, which calls the API client. Handlers delegate durable work to storage, services, and workers.

Frontend Structure ​

The frontend is a static SvelteKit single-page app. It renders entirely in the browser.

PathPurpose
src/lib/api.tsAll backend requests, token header, readable errors
src/lib/session.svelte.tsFirebase Google sign-in state
src/lib/edition/printing.tsLoads every channel and merges stories by release date
src/lib/edition/stories.tsPure story, section, and date helpers
src/lib/edition/summary.tsSplits a summary into standfirst, glance box, and body
src/lib/edition/markdown.tsMarkdown to sanitized HTML
src/lib/edition/keepsake.tsLast edition and chosen section in browser storage
src/lib/edition/reader.svelte.tsReader state: sections, lead story, mark read, undo
src/lib/highlights/anchoring.tsBuilds a highlight from a selection and finds it again
src/lib/highlights/passage.tsStory text as one string; draws and clears highlight marks
src/lib/highlights/story-highlights.svelte.tsHighlights of the story on screen, optimistic add and remove
src/lib/highlights/collection.tsSearch and remove on the grouped highlights list
src/lib/components/Masthead, section nav, story, read bar, rail, sign-in
src/lib/bindings/Types generated from the backend by ts-rs

Routing ​

RoutePurpose
/The reader: front page or one section
/highlightsEvery highlight by story, newest stories first, with search
/finishedStories marked as read, most recently finished first
/stories/{id}One story, read or unread, with its highlights
/profileSubscriptions (follow or stop following channels); sign out
/sectionsOld URL. Firebase Hosting redirects it to /profile.
/miniOld reader URL. Firebase Hosting redirects it to /.

Signed-out visitors see the sign-in page on every route.

Loading The Paper ​

GET /api/mini returns unread summaries for one channel at a time. The reader asks once without a channel id, which returns the channel list and the first channel's summaries, then asks for the other channels with at most four requests in flight. It merges the results newest first.

The reader shows the stored edition at once, then loads every channel and stores the merged result. Finishing a story sends one small PUT.

Marking a story read updates the page first and then sends the request. If the request fails, the story comes back and a notice explains why. Undo sends read: false after the first request has finished, so the two never race.

The reader reloads only when asked, or when the tab becomes visible again after 30 minutes. See Running Cost For One Reader.

Request Trust ​

Product clients authenticate directly with Firebase bearer tokens. Trusted first-party callers can use the proxy-auth header path.

The backend accepts two trust modes:

ModeInputsUsed by
Direct authAuthorization: Bearer <firebase-id-token>Reader frontend
Trusted proxyx-dastill-proxy-auth plus x-dastill-auth-state, role, and user idsTrusted first-party automation

Every protected request resolves an AccessContext before channel, video, search, chat, or operator-only authorization decisions.

The reader requires Google sign-in. The backend still supports signed-out access on routes that allow it, such as the ephemeral chat path.

API Families ​

The reader uses the mini reader, channel, and highlight APIs. The other API families remain in the backend without a UI.

The reader uses:

  • GET /api/mini and PUT /api/mini/videos/{id}/read
  • GET /api/mini/videos/{id}: one story from a followed channel, read or unread
  • GET /api/mini/finished?offset&limit: finished stories, most recently finished first, with finished_at and has_more
  • GET /api/channels, POST /api/channels, and DELETE /api/channels/{id}
  • GET /api/highlights, GET and POST /api/videos/{id}/highlights, and DELETE /api/highlights/{id}. Highlight ids are sent as strings because they are larger than JavaScript's safe integers.

Read state per reader is cached in memory on the backend for 30 minutes and updated on every write, so loading the paper and the finished list does not read one storage object per story.

The families below are still served by the backend. The current frontend does not call them.

Library And Content ​

  • channel list, subscribe, update, delete, refresh, and backfill
  • channel snapshots and per-channel videos
  • transcript, summary, video info, summary audio
  • manual transcript/summary edits
  • summary regeneration
  • acknowledged state updates
  • search content
  • inspect search status
  • stream search status
  • rebuild the derived search projection

Chat ​

  • list conversations
  • create, update, and delete conversations
  • stream assistant responses through SSE
  • cancel or reconnect to in-progress generation
  • send signed-out prompts through the ephemeral path
  • allow per-message deep-research retrieval expansion

Auth And Mobile Handoff ​

  • create, poll, complete, and delete Android mobile-auth handoff sessions
  • support system-browser Google sign-in for the Tauri Android shell

User State ​

  • highlight listing, creation, and deletion
  • route-level highlight grouping
  • user preference loading and saving

Analytics ​

  • bounded frontend analytics event ingest

Backend Handlers ​

Backend handler modules group routes by concern:

HandlerRoutes
auth.rsAndroid mobile-auth handoff session lifecycle
channels.rschannel CRUD, sync, refresh, backfill, bootstrap
videos.rsvideo listing, video info, acknowledged state
content.rstranscripts, summaries, summary audio, AI health
highlights.rshighlight CRUD
preferences.rsuser preferences
analytics.rsanalytics event ingest
search.rssearch queries, status, status stream, rebuild
chat.rsconversations, message streaming, RAG retrieval
query.rsshared filter and pagination query parameters

Handlers orchestrate request-level work. Durable logic primarily lives in:

  • db/*
  • services/*
  • workers.rs

Contract Style ​

The frontend and backend communicate through typed JSON payloads plus SSE streams.

The backend OpenAPI document for local debugging can be found in /api/openapi.json. The checked-in backend/openapi.postman.yaml file is a snapshot artifact that might be stale.