···6677The feed generator has three main components:
8899-1. **Ingester** (`ingester/`) - Consumes the Spark firehose in real-time and
1010- indexes records to MongoDB. By default, it indexes `so.sprk.feed.post`
1111- records. Handlers for `follow`, `like`, and `repost` are included but
99+1. **Ingester** (`ingester/`) - Consumes the Spark firehose in real-time and
1010+ indexes records to MongoDB. By default, it indexes `so.sprk.feed.post`
1111+ records. Handlers for `follow`, `like`, and `repost` are included but
1212 disabled - enable them by uncommenting in `ingester/index.ts`.
13131414-2. **Algorithms** (`algos/`) - Define how posts are selected and sorted for
1515- your feed. Each algorithm exports:
1414+2. **Algorithms** (`algos/`) - Define how posts are selected and sorted for your
1515+ feed. Each algorithm exports:
1616 - `handler` - Query function that returns posts from the database
1717 - `needsAuth` - Whether the feed requires user authentication
1818 - `publisherDid` - The DID of the feed publisher
1919 - `rkey` - Unique identifier for this algorithm
20202121-3. **API Server** - Exposes XRPC endpoints that Spark clients call to fetch
2222- feed content (`so.sprk.feed.getFeedSkeleton`, `so.sprk.feed.describeFeedGenerator`).
2323- You won't need to modify these when creating a feed.
2121+3. **API Server** - Exposes XRPC endpoints that Spark clients call to fetch feed
2222+ content (`so.sprk.feed.getFeedSkeleton`,
2323+ `so.sprk.feed.describeFeedGenerator`). You won't need to modify these when
2424+ creating a feed.
24252526## Creating Custom Feeds
26272727-**For topic/community feeds:** Filter posts at the ingester level. Modify
2828-the handler in `ingester/handlers/post.ts` to only index posts matching your
2828+**For topic/community feeds:** Filter posts at the ingester level. Modify the
2929+handler in `ingester/handlers/post.ts` to only index posts matching your
2930criteria (hashtags, keywords, specific authors, etc.).
30313131-**For personalized/sorted feeds:** Create a new algorithm in `algos/`. Copy
3232-`simple-desc.ts` as a starting point, then modify the query logic. Register
3333-your algorithm in `algos/index.ts`.
3232+**For personalized/sorted feeds:** Create a new algorithm in `algos/`. Copy
3333+`simple-desc.ts` as a starting point, then modify the query logic. Register your
3434+algorithm in `algos/index.ts`.
34353536Example algorithm structure:
3737+3638```ts
3739// algos/my-feed.ts
3840export const info = {
···4042 // Query posts from ctx.db.models.Post
4143 // Return { cursor, feed: [{ post: "at://..." }] }
4244 },
4343- needsAuth: false, // Set true if feed needs user's DID
4545+ needsAuth: false, // Set true if feed needs user's DID
4446 publisherDid: "did:plc:your-did",
4545- rkey: "my-feed", // at://your-did/so.sprk.feed.generator/my-feed
4747+ rkey: "my-feed", // at://your-did/so.sprk.feed.generator/my-feed
4648} as Algorithm;
4749```
4850···979998100## Endpoints
99101100100-| Endpoint | Description |
101101-|----------|-------------|
102102-| `GET /` | Service info |
103103-| `GET /health` | Health check |
104104-| `GET /.well-known/did.json` | DID document for `did:web` resolution |
105105-| `GET /xrpc/so.sprk.feed.describeFeedGenerator` | List available feeds |
106106-| `GET /xrpc/so.sprk.feed.getFeedSkeleton` | Fetch feed posts |
102102+| Endpoint | Description |
103103+| ---------------------------------------------- | ------------------------------------- |
104104+| `GET /` | Service info |
105105+| `GET /health` | Health check |
106106+| `GET /.well-known/did.json` | DID document for `did:web` resolution |
107107+| `GET /xrpc/so.sprk.feed.describeFeedGenerator` | List available feeds |
108108+| `GET /xrpc/so.sprk.feed.getFeedSkeleton` | Fetch feed posts |