docker-compose up will leave you with working ukeeper-readability service (both API and frontend) running on http://localhost:8080.
docker-compose.yml runs MongoDB 9.0, which can't open a data directory left by an older release directly: MongoDB upgrades one major release at a time and reaches 9.0 only from 8.0 or 8.3. Check the running release with db.version(), then step through every major release after it; from 5.0, the release this file used before, that is 6.0, 7.0, 8.0 and 9.0. Before each step, set featureCompatibilityVersion to the release that is running, for example db.adminCommand({setFeatureCompatibilityVersion: "6.0"}) on 6.0; from 7.0 on, add confirm: true. Each release's notes in the MongoDB manual describe its upgrade step. The database holds the rules and a cache of summaries; the cache can be dropped.
| Command line | Environment | Default | Description |
|---|---|---|---|
| address | UKEEPER_ADDRESS | all interfaces | web server listening address |
| port | UKEEPER_PORT | 8080 |
web server port |
| mongo-uri | MONGO_URI | none | MongoDB connection string, required |
| frontend-dir | FRONTEND_DIR | /srv/web |
directory with frontend files |
| token | UKEEPER_TOKEN | none | token for API endpoint auth |
| mongo-delay | MONGO_DELAY | 0 |
mongo initial delay |
| mongo-db | MONGO_DB | ureadability |
mongo database name |
| creds | CREDS | none | credentials for protected calls (POST, DELETE /rules) |
| cf-account-id | CF_ACCOUNT_ID | none | Cloudflare account ID for Browser Rendering API |
| cf-api-token | CF_API_TOKEN | none | Cloudflare API token with Browser Rendering Edit perm |
| cf-route-all | CF_ROUTE_ALL | false |
route every request through Cloudflare Browser Rendering |
| cf-fallback | CF_FALLBACK | false |
retry through Cloudflare Browser Rendering when the direct fetch gets 403 or 429 |
| dbg | DEBUG | false |
debug mode |
Setting --openai.api-key enables article summaries and selector suggestions for pages that are parsed wrong; without it no OpenAI calls are made.
| Command line | Environment | Default | Description |
|---|---|---|---|
| openai.api-key | OPENAI_API_KEY | none | OpenAI API key, enables summaries and selector suggestions |
| openai.model | OPENAI_MODEL | gpt-6-luna |
OpenAI model |
| openai.summary-prompt | OPENAI_SUMMARY_PROMPT | built-in | custom system prompt for summaries |
| openai.max-content-length | OPENAI_MAX_CONTENT_LENGTH | 10000 |
max characters of article text sent for summarizing (0 for no limit) |
Cloudflare Browser Rendering is useful for JavaScript-heavy pages and sites behind a "please enable JS" wall, but it's slower than direct HTTP and the free tier throttles at 1 request per 10 seconds. To keep the service cost-effective, Cloudflare routing is opt-in.
- Set
--cf-account-idand--cf-api-tokento enable Cloudflare routing. - Either flip the
use_cloudflarecheckbox on individual rules (per-domain, recommended) or set--cf-route-all(CF_ROUTE_ALL=true) to route every request through Cloudflare. - Optionally set
--cf-fallback(CF_FALLBACK=true) to retry a page through Cloudflare when the direct fetch is refused with 403 or 429, as sites that block server addresses do. Sites that run a bot check challenge Cloudflare's browser too, since Cloudflare marks it as a bot; such a page then answers with the status Cloudflare's browser got. When the Cloudflare request itself fails, for example on its daily limit, the original 403 or 429 is returned.
A rule with use_cloudflare set may leave its content selector empty: it then only routes its domain through Cloudflare, and the page is read by the general parser.
Reddit pages always go through Cloudflare when it is configured, whatever the rules say, since Reddit refuses requests from server addresses. Links on old.reddit.com and other Reddit hosts are fetched from www.reddit.com (redd.it and v.redd.it short links go through Cloudflare too), and a post page becomes an article with the post (its text, picture, video poster or link) followed by the comments the page shows, replies nested under their comment. A rule with a content selector for a Reddit domain reads the page itself instead.
Hacker News item pages (news.ycombinator.com/item?id=...) are fetched directly and become an article with the story or comment at the top (its points, author, date, link and text) followed by the comments in the order the page ranks them, each reply nested under its comment. A poll lists its options with their points, a comment's own page links the story it is on, and a flagged, dead or deleted comment keeps only its replies. The page lays the discussion out as one table per comment with spacer pictures for the indent; none of that reaches the article. When a thread is split over several pages, the article holds the first one and ends with a link to the rest.
On Reddit and Hacker News, replies nest at most 8 quotes deep; a deeper reply follows the one it answers at that depth, so a long chain keeps the width of an e-reader page. A rule with a content selector for one of these sites reads the page itself while its selector finds an article; when the selector finds nothing, the site's own code reads the page. A page of such a site that its code cannot read, such as a listing, is read by the general parser.
When Cloudflare credentials are not set, the service uses a standard HTTP client for everything (default). On HTTP 429 (rate limit), or when a page navigates while Cloudflare renders it, the service automatically retries with exponential backoff and respects the Retry-After header.
Some sites challenge every automated request, Cloudflare's browser included. A rule with the use_archive checkbox set ("Брать последнюю копию из Wayback Machine") fetches the newest copy of the page that the Wayback Machine (web.archive.org) archived while the page answered 200, instead of the page itself. The copy is used as archived, without the archive's toolbar, and keeps the page's own URL; its pictures, video posters and media sources are taken from the archive's copies. It can be older than the live page. When the address has no copy but holds tracking parameters (ref, source, utm_* and similar), the copy of the address without them is used; a page with no archived copy gives an error, which the rule preview lists. The preview uses the checkboxes as submitted, so a rule can be tried before it is saved. The setting wins over use_cloudflare and --cf-route-all. archive.org refuses connections for a while after a burst of requests, so this suits a few pages at a time, not bulk extraction. When the archive limits the rate (429), fails on its side (5xx) or does not answer, /api/extract and the legacy parser endpoint answer 503 Service Unavailable with {"error": "can't extract content"}, so a caller can ask again later; a page with no archived copy still answers 400.
GET /api/content/v1/parser?token=secret&url=http://aa.com/blah - extract content (emulate Readability API parse call)
GET /api/content/v1/parser?token=secret&url=http://aa.com/blah&summary=true - extract content with AI-generated summary
POST /api/extract {url: http://aa.com/blah} - extract content
POST /api/extract-html {url: http://aa.com/blah, html: "<html>..."} - extract content from the page html the client sends
POST /api/content-parsed-wrong?url=http://aa.com/blah - ask OpenAI for a rule for a page that is parsed wrong (credentials required)
The extracted article carries parser, what read it: site:reddit or site:hackernews for a site's own code, rule for a rule's content selector, readeck for the general parser, readeck-hidden when the general parser read the page with its hidden elements shown, and media-only for a page with no text, only pictures, video or embeds.
When the target page answers with a 4xx or 5xx status (after redirects), nothing is extracted, summarised or stored, and the extraction endpoints answer 424 Failed Dependency with the status of the page:
{"error": "https://example.com/gone returned 404 Not Found", "target_status": 404}The URL in error is the final URL after redirects when it is known, otherwise the requested one (Cloudflare does not always report the final URL). GET /api/content/v1/parser, POST /api/extract and POST /api/content-parsed-wrong use this response; the rule preview in the web UI lists each such test URL as submitted, with the status, instead of its page. Other failures keep their current status codes. With Cloudflare Browser Rendering the status comes from meta.status of the Cloudflare response; when Cloudflare does not report it, the page is extracted as before.
A target that answers with an image, a PDF or application/octet-stream is not extracted either, and the three extraction endpoints answer 400 with {"error": "can't extract content"}. Other content types are extracted as before, since many servers label text pages wrongly. Cloudflare Browser Rendering does not report the target's content type, so this check applies to the default HTTP retriever only.
POST /api/extract-html does not fetch the page: it extracts the article from the html in the request, as UTF-8, with the rule for the URL's domain, so a page behind a login can be extracted as the reader's browser shows it. The request is limited to 16 MiB and its body is not written to the request log. Pictures are still downloaded from their URLs to pick the lead image. A Reddit or Hacker News page is read by its site's code, as a fetched one is.
Summary generation requires the server token to be set and an OpenAI API key. Summaries are cached in MongoDB for 30 days, keyed by model, prompt and article text; a TTL index removes expired ones. When the key is set, rule previews in the web UI also show a summary.
POST /api/content-parsed-wrong uses the same credentials as the rule management routes and calls OpenAI only when it is requested, never during normal extraction. The model gets an outline of the page body and suggests a CSS selector for the article. The selector is applied to the page and accepted only when it matches a plausible amount of text, not nearly the whole page and not what is extracted now; up to three suggestions are tried. The response holds the selector, the page extracted with it and saved. When the domain has no rule yet, the selector is stored as a disabled rule, so nothing changes for readers until it is reviewed and enabled in the web UI. When the domain already has a rule, enabled or not, that rule is left as it is and only the suggestion is returned. Pages of Reddit and Hacker News are refused with 422, like a page no selector is found for, listings included, since a rule for their hosts would replace the code that reads every post.
The datastore tests start MongoDB in a container through testcontainers, so they need Docker. main_test.go also needs MongoDB running without authorisation on localhost:27017, for example docker run --rm -p 127.0.0.1:27017:27017 mongo:9.0, and runs only when ENABLE_MONGO_TESTS is set, to any value.
Command to run full test suite would be:
ENABLE_MONGO_TESTS=true go test ./...