- Go 66.5%
- Svelte 23%
- TypeScript 7.2%
- Shell 2.4%
- CSS 0.6%
- Other 0.3%
The topic page's table had its Topics column out of line: the cell was
itself a flex box, so it stopped being a table cell. The list now uses
the same cards as the front page, moved into CommunityCard, with the
community's topics under its description and a sort menu in place of
the column headers.
GET /api/topics/{path} returns whole communities for the cards, with
descriptions cut to 400 characters: a root topic lists thousands
(technology: 4222 communities, 730 kB gzipped).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|---|---|---|
| .vscode | ||
| cmd/explorer | ||
| docs | ||
| internal | ||
| labels | ||
| scripts | ||
| web | ||
| .gitignore | ||
| go.mod | ||
| go.sum | ||
| README.md | ||
Threadiverse Explorer
Discover communities across the threadiverse (Lemmy, PieFed, GoThread, Mbin, …), and see how instances federate with and block each other.
- Backend (Go): a crawler that walks federation links from a set of seed instances, and a JSON API over the crawled SQLite database.
- Frontend (
web/): a SvelteKit static SPA. No Node at runtime; the Go server serves the built files.
Quickstart
On a Linux server with systemd:
curl -fsSL https://git.jimmy-b.se/JimBer110/threadiverse_explorer/raw/branch/master/scripts/setup.sh | bash
It asks where to listen, whether a reverse proxy sits in front (and its addresses, so only
its forwarded client addresses are believed), a contact for the crawler's User-Agent, how
often to recrawl and reclassify, and an admin password. Then, with sudo, it creates a
threadiverse system user, writes /etc/threadiverse-explorer/explorer.conf, installs
/usr/local/bin/threadiverse-explorer from the latest release (checksum-verified), and
enables a hardened threadiverse-explorer systemd service. Point your reverse proxy at the
listen address and open /admin. Run the same command again to upgrade.
curl ... | bash -s -- --yes installs without questions, taking answers from TE_ADDR,
TE_PROXIES, TE_CONTACT, TE_CRAWL_EVERY, TE_CLASSIFY_EVERY, TE_ADMIN_PASSWORD and
TE_DATA_DIR; --from-source builds instead of downloading (needs git, Go and Node); see
the top of scripts/setup.sh. Commands on the server run as the service user, e.g.
sudo -u threadiverse threadiverse-explorer admin passwd.
To uninstall: sudo systemctl disable --now threadiverse-explorer, then remove
/usr/local/bin/threadiverse-explorer, /etc/systemd/system/threadiverse-explorer.service,
/etc/threadiverse-explorer, the data directory (/var/lib/threadiverse-explorer) and the
threadiverse user.
Configuration
Every command reads a config file: -config <file>, else $EXPLORER_CONFIG, else
/etc/threadiverse-explorer/explorer.conf if it exists. One key = value per line, #
comments on their own lines:
db = /var/lib/threadiverse-explorer/explorer.db
# serve's listen address
addr = 127.0.0.1:8080
# The built SPA directory; empty serves the one built into the binary.
web =
# Where the reverse proxy puts the client address, and the proxies to believe it from
# (addresses or CIDRs).
real_ip_header = X-Forwarded-For
trusted_proxies = 127.0.0.1, ::1
# Any setting from `explorer settings list`, as a default:
crawl.user_agent = threadiverse-explorer (admin@example.org)
schedule.crawl_every = 7d
Settings in the file are defaults: one saved on /admin/settings (or with explorer settings set) wins over it, and a command-line flag wins over both for that run. An
unknown key or a bad value stops the command with an error naming it.
Without trusted_proxies, real_ip_header is believed from anyone, which is only safe
when nothing but the proxy can reach the server (serve warns about it).
Releases
scripts/release.sh builds dist/: Linux amd64 and arm64 archives with the frontend built
into the binary (-tags embedweb), and SHA256SUMS. To publish one for the installer,
tag it and upload:
git tag v0.1.0 && git push origin v0.1.0
FORGEJO_TOKEN=... scripts/release.sh --publish # a token with repository write access
Development
Requires Go 1.27+ (as go.mod says) and Node 22+. Nothing else: classification runs in process.
# Crawl: revisits every instance already known to be live plus a few large seeds,
# then follows federation links, best-connected domains first. Pass domains to
# crawl just those; add -every 24h to keep recrawling.
go run ./cmd/explorer crawl -max-instances 50
# ...or generate fictional test data instead (~1000 communities on 36 .example instances)
go run ./cmd/explorer seed -db dev.db
# Group and classify communities into topics, in process: a Model2Vec embedding model
# (downloaded once, ~530 MB, to embed.model_dir), the trained topic model built into the
# binary, and name rules. Takes under a minute for ~20k communities on a laptop CPU.
go run ./cmd/explorer classify -db dev.db
# Score the classifier against labels/gold.tsv without saving anything; -tune searches
# the grouping threshold and score weights (see "Retraining the classifier")
go run ./cmd/explorer eval -db explorer.db
# Save settings (crawler, classifier, schedule) as the defaults for crawl and classify;
# a flag given on the command line still wins for that run
go run ./cmd/explorer settings -db dev.db set classify.review_min_active 20
go run ./cmd/explorer settings -db dev.db list
# Set the password for the admin pages (/admin): start, cancel and schedule crawls and
# classification, review and correct topics, and change settings
go run ./cmd/explorer admin -db dev.db passwd
# Correct a community's topics by hand (also on /admin/review); applies to its group at once
# and is kept across crawls and classify runs
go run ./cmd/explorer override -db dev.db set '!rust@b.example' gaming/video-games
# Everything on http://localhost:8080: the API plus the Vite dev server (hot reload),
# which serve starts and stops itself. Installs web/node_modules on first run.
go run ./cmd/explorer serve -dev -db dev.db
Production-style: cd web && npm run build, then
go run ./cmd/explorer serve -web web/build, or build a single binary with the frontend in
it: go build -tags embedweb ./cmd/explorer (after npm run build).
Behind a reverse proxy, set real_ip_header (e.g. X-Forwarded-For) and trusted_proxies
(the proxy's address) in the config file, or pass serve -real-ip-header and
-trusted-proxies, so failed admin logins are limited per client rather than for everyone,
and keep the Host header as the browser sent it.
Run go run ./cmd/explorer crawl -h for crawler options. Please set -user-agent to
something that includes contact info before crawling at scale.
Set and forget
serve can keep the data fresh on its own. On /admin/settings (or with explorer settings):
schedule.crawl_every, e.g.7d: recrawl every live instance (and the seeds) this long after the last crawl started. Crawling refreshes instances, communities, their descriptions and post titles.schedule.classify_every, e.g.30d: reclassify everything this long after the last run. Topics follow what communities are now about, so one that changes (a subreddit-style takeover, a rename) moves with it.schedule.classify_after_crawl: also classify after each crawl.crawl.forget_after(default30d): after each crawl, delete communities not seen for this long whose instance has been visited since, so ones that were deleted, or whose instance died, don't linger. Instances a crawl didn't reach (one limited to some domains) keep theirs. Topics set by hand for a deleted community are kept on /admin/overrides.
Durations take s, m, h, d and w; 0 turns a schedule off. Topics set by hand are
kept by every run, but each remembers what the classifier saw when it was set: if the
classifier later sees the community as something unrelated, the group comes back on
/admin/review ("changed since its topics were set by hand"). Groups too small to matter
(classify.review_min_*) are classified but never flagged.
serve runs the jobs started from /admin or the schedule, one at a time. A CLI crawl or
classify on the same database waits its turn: it refuses to start while the server is
running one, and a job queued in the server waits while a CLI run holds the lock.
The crawler is meant to be a polite guest: one request at a time per instance, post-title sampling paced to stay under Lemmy's default rate limit (it backs off when told to), and domains that keep failing are retried after a day, doubling up to a month.
Retraining the classifier
A community's topic comes from three signals added into one score: a small trained model
(internal/topicmodel/default.bin, built into the binary), embedding similarity to each
topic's description, and the community's name matching a topic's label or keywords
(internal/taxonomy/taxonomy.txt). NSFW-marked communities only get adult topics.
The trained model learns from the labelled communities in labels/ (see
labels/README.md): train.tsv to learn from, and gold.tsv, a hand-checked test set, to
score against. Every topic fixed on /admin/review is a label waiting to be used. To
retrain, after reviewing or after changing labels or the taxonomy:
# 1. Add the topics set by hand (on /admin/review or with `explorer override`) to
# labels/train.tsv as "human" labels. Communities in gold.tsv stay out.
go run ./cmd/explorer labels -db explorer.db export
# 2. Train. Needs a crawl database with the labelled communities: it learns from their
# descriptions and post titles. Downloads the embedding model (~530 MB) on first use.
# Prints how the new model alone scores on gold.tsv and writes
# internal/topicmodel/default.bin.
go run ./cmd/explorer train -db explorer.db
# 3. Score the whole classifier on gold.tsv, without saving anything; -tune also
# searches the grouping threshold and score weights and prints the settings to save.
go run ./cmd/explorer eval -db explorer.db
# 4. Commit labels/train.tsv and internal/topicmodel/default.bin, rebuild, and reclassify.
Fixing gold.tsv itself (a wrong hand label) needs no retraining, only a new eval. Keep it
out of training: its score is only honest for communities the model hasn't seen.
Labels for communities the database doesn't have are skipped (and counted), so a smaller
crawl trains a weaker model. go test ./internal/topicmodel fails if the built-in model
predicts a topic the taxonomy no longer has.
Layout
cmd/explorer/ CLI entrypoint: crawl, serve, seed, classify, override, settings, admin, train, eval, labels, version
internal/config/ the config file
scripts/ setup.sh (install as a service), release.sh (build and publish releases)
internal/settings/ tunable settings: defaults, saved values, flags
internal/crawler/ nodeinfo + Lemmy/PieFed API clients, federation-link discovery
internal/store/ SQLite schema (FTS5 community search) and queries
internal/api/ HTTP API + SPA file serving
internal/taxonomy/ curated topic tree (taxonomy.txt) and its parser
internal/embed/ embedding interface and vector helpers
internal/model2vec/ in-process Model2Vec embeddings (tokenizer, model, download)
internal/topicmodel/ the trained topic model: logistic regression, labels files, built-in weights
labels/ labelled communities for training and testing the classifier
internal/classify/ topic groups, scoring, review flags, training and evaluation
internal/maplayout/ deterministic layout of topics, groups and communities for the map
web/ SvelteKit SPA
API
| Endpoint | Notes |
|---|---|
GET /api/communities |
q, sort (active, subscribers, posts, new), software, instance, nsfw=true, inactive=true (include communities with no activity this month), limit, offset |
GET /api/communities/{domain}/{name} |
Community plus daily stat snapshots |
GET /api/instances |
software |
GET /api/instances/{domain} |
Instance, its federation links, and which crawled instances block it |
GET /api/topics |
Taxonomy with community counts and sizes aggregated per subtree |
GET /api/topics/{path...} |
One topic: ancestors, subtopics, and the groups directly in it |
GET /api/map |
Topics, groups and communities with map positions |
GET /api/graph |
relations=linked,allowed,blocked (default blocked), min_blockers (default 2: also include uncrawled domains blocked by at least that many instances) |
Status
- Lemmy and PieFed: instances, communities (with a sample of post titles), federation links.
- GoThread: instances, communities with post titles, and, from 1.8, per-community activity and federation links. Its federation list doesn't name software, so its linked hosts are tried and the non-threadiverse ones backed off. Before 1.8, a community with posts counts as active and there are no federation links.
- Mbin/kbin: instance stats only (their community API needs OAuth client credentials).
- Topics: classification in process (no model server): Model2Vec embeddings, the trained
topic model and name rules, scored against
labels/gold.tsvwithexplorer eval. Groups big and active enough (classify.review_min_*) are flagged for review when the signals disagree; review and manual overrides are on/admin/reviewand/admin/overrides, andexplorer labels exportturns them into training labels. The zoomable community map is at/map; seedocs/community-map.md. - Upgrading from the bge-m3/Ollama classifier: its cached vectors stay in an
embeddingstable nothing uses any more. To reclaim the space (stop the server first):sqlite3 explorer.db 'DROP TABLE embeddings; VACUUM;'. Savedembed.url/embed.modelsettings are ignored; savedclassify.margin,cross_marginandmin_gapvalues are on the old scale, so reset them (explorer settings reset classify.margin, …). - Federation page (
/graph): a network of who blocks whom (instances with similar block lists sit together), a block-list matrix, and a most-defederated table.?instance=preselects one. - Home instance: set one in the header (kept in the browser) and community links open there,
ready to subscribe. Lemmy, PieFed and GoThread homes go through
/activitypub/externalInteraction, which fetches communities they haven't seen yet; others get/c/name@domain(/m/on Mbin/kbin), which only finds communities they already know. - Stats page (
/stats, API/api/stats): live instances, communities and active users by software, post-title coverage, and why unreachable domains failed.