···10101111## What it does
12121313-Asterism connects directly to the relay Firehose (`com.atproto.sync.subscribeRepos`), decodes each repo commit's CAR-framed CBOR blocks itself, and recursively walks each record for link references (strong refs, AT-URIs, DIDs, URLs). Links are stored keyed by target, source collection, and field path. On startup it backfills existing repos for your configured collections so the index is useful immediately.
1313+Asterism connects directly to the relay Firehose (`com.atproto.sync.subscribeRepos`), decodes each repo commit's CAR-framed CBOR blocks itself, and recursively walks each record for link references (strong refs, AT-URIs, DIDs, URLs). Links are stored keyed by target, source collection, and field path. It can optionally backfill existing repos for your configured collections on startup so the index is useful immediately.
14141515This matters for two reasons:
1616···3030The typical deployment indexes only the collections your app queries:
31313232```bash
3333-go run ./cmd/asterism/ -collections sh.tangled.graph.follow,sh.tangled.repo.issue,sh.tangled.feed.comment
3333+go run ./cmd/asterism/ --collections sh.tangled.graph.follow,sh.tangled.repo.issue,sh.tangled.feed.comment
3434```
35353636-This connects to the relay Firehose, backfills existing repos for those collections in the background, stores links in an sqlite database at `asterism.db`, and serves the query API on `:8081`.
3636+This connects to the relay Firehose, stores links in an sqlite database at `asterism.db`, and serves the query API on `:8081`. Firehose events that are too large to include inline are fetched through the repo API automatically.
37373838-To index all collections (Constellation-equivalent scope, not recommended for sovereign deployments):
3838+To also backfill existing repos for your configured collections on startup:
39394040```bash
4141+go run ./cmd/asterism/ --backfill --collections sh.tangled.graph.follow,sh.tangled.repo.issue,sh.tangled.feed.comment
4242+```
4343+4444+To live-index all collections (Constellation-equivalent scope, not recommended for sovereign deployments):
4545+4646+```bash
4747+go run ./cmd/asterism/
4848+```
4949+5050+### Configuration
5151+5252+Every flag can also be set with an environment variable.
5353+5454+| Flag | Environment variable | Default | Description |
5555+|---|---|---|---|
5656+| `--collections` | `ASTERISM_COLLECTIONS` | empty | Comma-separated collection NSIDs to index. Empty means all collections. |
5757+| `--backfill` | `ASTERISM_BACKFILL` | false | Backfill existing repos for configured collections on startup. |
5858+| `--database` | `ASTERISM_DATABASE` | `asterism.db` | SQLite database path. |
5959+| `--listen` | `ASTERISM_LISTEN` | `:8081` | HTTP API listen address. |
6060+| `--relay` | `ASTERISM_RELAY` | `relay1.us-east.bsky.network` | Relay host. Asterism derives the Firehose websocket and relay HTTP API URLs from this host. |
6161+6262+For example:
6363+6464+```bash
6565+ASTERISM_DATABASE=/var/lib/asterism/asterism.db \
6666+ASTERISM_LISTEN=:8081 \
6767+ASTERISM_COLLECTIONS=sh.tangled.graph.follow,sh.tangled.repo.issue \
6868+ASTERISM_BACKFILL=true \
4169go run ./cmd/asterism/
4270```
4371···126154**Near term**
127155128156- [x] Full Constellation API parity (`getBacklinksCount`, `getBacklinkDids`, `getBacklinks`, `getManyToMany`, `getManyToManyCounts`)
129129-- [ ] Configurable listen address, database path, and relay URL
157157+- [x] Configurable listen address, database path, relay host, and startup backfill
130158- [ ] Account deletion and deactivation handling
131159- [x] Graceful shutdown and Firehose reconnect
132160