Philosophy Reader

Overview

Philosophy Reader is a personal Android app for reading the Stanford Encyclopedia of Philosophy all the way through. It fetches an entry from plato.stanford.edu, keeps only the article and renders it in a reading view with its own fonts, themes and spacing. Highlights, notes, bookmarks and concept pages turn the reading into a private catalogue, and all of it stays on the phone.

The problem

SEP entries often run past 15,000 words, and the website isn't built for reading that much on a phone. Footnotes and links to other entries pull you away from your place, and unfamiliar terms send you off to another tab. Annotations also have to survive the SEP revising an entry, and the app has to respect the SEP's terms: no bundled or mirrored content, and no bulk crawling.

Approach

I built a reader rather than a website wrapper. The rest of the app is native Kotlin and Compose, while the article itself renders in a bundled HTML page inside a WebView, which keeps MathJax, native text selection across paragraphs and precise highlight anchoring. Anything that would leave the page, such as a footnote, a cross-reference or a look-up, opens in a sheet over the text instead.

Architecture

  1. Fetch and extract

    An OkHttp client fetches an entry only when it's opened or marked for offline reading, with a PhilosophyReader/1.0 user agent. Jsoup pulls out the title, authors, dates, preamble, sections and bibliography, and fetches footnotes from the entry's notes page. The cleaned entry is cached in Room on the phone, with no server in between.

  2. Reader page and bridge

    The reader is a local HTML, CSS and JS page served from the app's assets, with bundled fonts and MathJax 3, so it never loads assets from the SEP. The page never navigates by itself: it sends taps, selections and scroll position to Kotlin through a web message channel, and Kotlin opens the matching sheet or screen.

  3. Annotations that survive revisions

    Highlights and notes are stored with a text-quote selector (the quote plus surrounding context) backed by a text position, in the style of W3C Web Annotations. When the SEP revises an entry they are re-anchored by their quoted text, and any that can't be placed go to a Detached list instead of being lost. The anchoring core has no DOM dependency, so it runs under node --test as well.

  4. Look-up in context

    Selecting a term offers three look-ups. SEP search pins the entry with the exact title first, Wiktionary gives dictionary senses, and Explain sends only the term, its paragraph, the section headings and the entry title to Claude, using the reader's own API key stored with Android Keystore.

  5. Background work as a polite guest

    WorkManager runs only two automatic jobs: a daily RSS check that flags entries revised since you read them, and a weekly table-of-contents refresh. A shared rate limiter keeps background requests, including offline downloads of whole folders, at least 5 seconds apart, as the SEP's robots.txt asks.

Outcomes

  • Unit tests cover the extractor, parsers, editions, citations, folder tree, look-up parsing and Markdown export, with Room tests on a device and Node tests for text anchoring.
Home, reader and text settings

Takeaways

  1. Resume restores your place down to the paragraph, and the Sections drawer shows read state and time left for every section.

  2. Highlights in four colours, notes, nested bookmark folders and concept pages, gathered in a searchable Notebook.

  3. Backup and restore to one JSON file, optional daily backups to a chosen folder, and Markdown export for Obsidian.