- TypeScript 93.6%
- CSS 3.2%
- JavaScript 1.8%
- Go Template 1.1%
- Dockerfile 0.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo | ||
| apps | ||
| e2e | ||
| packages | ||
| screenshots | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| .nvmrc | ||
| CHANGELOG.md | ||
| compose.example.yml | ||
| Dockerfile | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| PLAN.md | ||
| README.md | ||
| renovate.json | ||
Forage
Your Mastodon home timeline, ranked the way you choose.
Forage reads your Mastodon home timeline, along with what's trending on the servers you follow people on, and ranks it by what you say counts: who you follow and interact with, the hashtags you care about, what's popular, how recent a post is, what you've already seen. You set the weights and filters; the feed re-ranks as you change them. It runs on your own server as a small web app you can install on your phone, and keeps working while you're away: the feed is ready when you open it, and it opens offline with the last one.
It's for one Mastodon account per installation: yours.
Forage is built on fedialgo by michelcrypt4d4mus (originally by pkreissel), which does the ranking. This repository started as a fork of fedialgo's browser demo; the ranking now runs on a server instead of in the browser.
![]() |
![]() |
| Why it's here: every post's score, explained. | Trending: posts, links and hashtags across the servers you follow people on. |

- Running it
- Settings
- The reverse proxy
- Updating
- Backups
- Logs and monitoring
- Troubleshooting
- Development
Running it
You need a host with Docker and Docker Compose, a domain for Forage with HTTPS from a reverse proxy you already run (Caddy, nginx, Traefik…), and a Mastodon account.
- Copy
compose.example.ymltocompose.ymland.env.exampleto.env, in a directory of their own. - Fill in
.env: at leastALLOWED_ACCOUNT,APP_SECRETandPUBLIC_URL(see Settings). ForAPP_SECRET:openssl rand -base64 48 - Create the directory Forage keeps its data in, owned by the container's user (uid 1000):
If Docker creates it instead, it's owned by root and Forage can't write its database.mkdir data && sudo chown 1000:1000 data - Point your reverse proxy at port 3000 (see The reverse proxy).
- Start it:
docker compose up -d - Open
PUBLIC_URL, log in with your Mastodon account, and approve Forage on your instance's page. The first feed takes a minute or two to build. To install it on a phone, use the browser's "Add to Home Screen" (iOS) or "Install app" (Android).
The image is code.thms.uk/michael/forage, built from this repository's main branch: latest, or a dated version such as 2026.11.16.42. Everything Forage keeps is in ./data, next to compose.yml (/data in the container).
Settings
Environment variables, in .env (which compose.yml reads).
| Variable | Required | What it is |
|---|---|---|
ALLOWED_ACCOUNT |
yes | The one Mastodon account that can log in, as [email protected]. Anyone else is turned away. |
APP_SECRET |
yes | At least 32 characters. Encrypts the Mastodon access token and app credentials stored in the database. Changing it means logging in again. |
PUBLIC_URL |
yes | Where Forage is reached, e.g. https://feed.example. Your instance sends you back to PUBLIC_URL/auth/callback after you log in, and changing requests must come from this origin. Use https:// (session cookies are only marked secure then). |
MASTODON_URL |
no | Your instance's own address, when it isn't the domain in your handle: handles like @[email protected] on an instance running at https://mastodon.example.com. |
LANGUAGE |
no | Your language, as de or de-DE: trending hashtags in other languages are left out, and if the servers you follow people on don't make up 30 big enough ones, servers in your language fill in before the popular general ones. Forage knows de, es, eu, fr, it, ja, pt, ru and tr; the default is English. |
TRENDING_SERVERS |
no | Servers to ask what's trending when the ones you follow people on aren't enough, separated by commas, e.g. mastodon.social, hachyderm.io. Forage asks up to 30 servers: first the ones you follow the most people on (with at least 100 active users), then your language's (see LANGUAGE), then these, in this order. Without it, the top-up is a mix of popular general servers. |
ENGINE_WORKER |
no | true to build and rank your feed in a thread of its own, so the app stays quick to answer while a refresh is under way. Default false (one thread for everything). If that thread crashes, or stops answering for two minutes, the server exits so Docker starts it again (restart: unless-stopped in compose.yml). |
LOG_LEVEL |
no | debug, info (the default), warn or error. |
PORT |
no | The port inside the container (default 3000). |
DATA_DIR |
no | Where the database is kept in the container (default /data, which compose.yml maps to ./data). |
STATIC_DIR |
no | The built web app (the image sets it). Unset, the server serves only its API. |
The reverse proxy
Forage serves plain HTTP on port 3000; your proxy terminates HTTPS and passes everything on. Three things matter:
- Nothing under
/apior/authmay be cached by the proxy or a CDN in front of it. Those answers are your feed and your login: a cached copy is served to whoever asks next. Forage marks themCache-Control: private, no-store, which caches that follow the origin's headers obey, but a rule that caches everything can override it. With Cloudflare's proxy (the orange cloud), add a Cache Rule that bypasses the cache for/api/*and/auth/*. - Live updates come over a long-lived event stream at
/api/events. The proxy mustn't buffer it, and must let it stay open: Forage sends a keep-alive every 25 seconds, so any read timeout over a minute is fine. - Media uploads (pictures and videos in replies) go through Forage to your instance, so allow request bodies as large as your instance does (around 100 MB for video on a default Mastodon).
Caddy doesn't cache, and does the other two by itself:
feed.example {
reverse_proxy 127.0.0.1:3000
}
nginx needs them spelled out:
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Host $host;
client_max_body_size 100m;
}
location /api/events {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_buffering off;
proxy_read_timeout 1h;
}
compose.example.yml publishes port 3000 on 127.0.0.1 only, for a proxy on the same host. If yours runs elsewhere, drop the 127.0.0.1: (and keep port 3000 away from the internet), or put both on a shared Docker network.
Updating
docker compose pull
docker compose up -d
Database changes are applied when the new version starts. There's no going back to an older version after one, so take a backup before updating. To stay on a version, use its dated tag instead of latest in compose.yml.
Changing a setting in .env takes effect when you restart (docker compose up -d). For LANGUAGE and TRENDING_SERVERS, Forage then fetches what's trending afresh.
Backups
All of Forage's state is one SQLite database, data/fedialgo.db: your login, weights and filters, and the ranked feed. Back it up while it runs with SQLite's own backup (copying the file alone can catch it mid-write), which writes data/backup.db:
docker compose exec forage node -e "require('better-sqlite3')('/data/fedialgo.db').backup('/data/backup.db')"
Then copy data/backup.db wherever your backups go. Or stop Forage (docker compose stop) and copy the whole data directory.
To restore, stop Forage, put the backup in data as fedialgo.db (removing any fedialgo.db-wal and fedialgo.db-shm beside it, and keeping it owned by uid 1000), and start it again.
The stored access token is encrypted with APP_SECRET, so keep that with your backups: restored without it, everything works except that you have to log in again. Losing the database altogether costs your weights and filters; the feed rebuilds itself after you log in.
Logs and monitoring
docker compose logs -f
Forage logs one JSON object per line on stdout. At startup, the ranking library also prints its configuration as plain text.
For health checks:
GET /healthz: the process is up. Always200 {"status":"ok"}.GET /readyz: Forage can serve requests (its database answers):200 {"status":"ready",…}, or503.
Neither needs a login. /readyz through your proxy (https://feed.example/readyz) is the one to monitor, with Uptime Kuma for example: it checks the proxy, the container and the database at once. The image's Docker health check uses it too, so docker compose ps shows whether the container is healthy.
Troubleshooting
- Forage stops straight away with
SqliteError: unable to open database file: it can't write todata. Give it to the container's user:sudo chown -R 1000:1000 data. - Logging in fails with "Your Mastodon server couldn't be reached", and the logs mention
POST /api/v1/apps returned 404: your instance doesn't run at the domain in your handle. SetMASTODON_URLto its real address. - "That Mastodon account isn't the one this server is set up for": you approved Forage as a different account. Log out of the other account on your instance's site, or check
ALLOWED_ACCOUNT. - Logging in loops back to the login page: the browser isn't at
PUBLIC_URLexactly (scheme, host and port must all match). With anhttps://PUBLIC_URL, opening Forage over plain HTTP (port 3000 directly, say) can't keep the session cookie. - Changes don't save ("Cross-origin request refused"): the same
PUBLIC_URLmismatch, as the server sees it. - Another device or browser shows your feed without logging in: something between the internet and Forage is caching its answers (a CDN such as Cloudflare's proxy, or a caching proxy). Stop it caching
/apiand/auth(see The reverse proxy), purge its cache, and log in again on your devices after ending every session:docker compose exec forage node -e "require('better-sqlite3')('/data/fedialgo.db').prepare('DELETE FROM session').run()" - The feed never updates live, but reloading shows new posts: the proxy is buffering
/api/events(see The reverse proxy). - Logged out after changing
APP_SECRET: expected. Log in again.
Development
npm workspaces:
| Workspace | What it is |
|---|---|
packages/core (fedialgo) |
The ranking library, vendored from upstream with git subtree |
packages/shared |
The API's types (zod schemas), and the app's name and colours (brand.ts) |
apps/server |
The server: Hono, SQLite (Drizzle), the feed engine |
apps/web |
The web app: React, TanStack Query, a service worker |
packages/fake-mastodon, packages/test-fixtures |
A Mastodon stand-in replaying recorded, scrubbed API responses, for tests |
e2e |
Playwright specs: the built app and the real server against fake-mastodon |
With Node 24 (see .nvmrc):
npm ci
npm test # every workspace's tests
npm run lint
npm run typecheck
npm run e2e # builds, then runs the end-to-end specs (needs: npx -w @fedialgo/e2e playwright install chromium)
To run it locally against a real account, start the server with your settings in its environment, then the web app's dev server, which passes /api and /auth on to it:
PORT=3001 PUBLIC_URL=http://localhost:3000 ALLOWED_ACCOUNT=[email protected] APP_SECRET=… DATA_DIR=./data \
npm run dev -w @fedialgo/server
npm start # the web app on http://localhost:3000
No test reaches the network: tests run against MSW or fake-mastodon, using recordings in packages/test-fixtures (see its README for recording new ones). PLAN.md has the architecture, the decisions behind it, and the testing policy. Pull requests into main run lint, typecheck, unit tests and the end-to-end specs; merging builds, smoke-tests and publishes the image.
Licence
GPL-3.0 (LICENSE), like fedialgo.


