feat: Kalshi TikTok feed — extension + scraper backend#351
Open
feat: Kalshi TikTok feed — extension + scraper backend#351
Conversation
Chrome extension that opens as a side panel with a TikTok-style vertical swipe feed of Kalshi prediction markets. Features: - Full-viewport vertical scroll-snap cards - YES/NO price bars with probability visualization - Category-based gradient backgrounds (politics, crypto, sports, etc.) - Category filter tabs (trending, all, by category) - "Buy" buttons that deep-link to kalshi.com - Fake data populated for 12 markets - Clear SCHEMA.md documenting the API contract for backend integration Built with WXT, React 19, and Tailwind CSS v4. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Greptile SummaryAdds TikTok-style Kalshi prediction market feed with Chrome extension + backend scraper Chrome Extension (
Backend Service (
Issues Found:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Chrome Extension<br/>kalshi-feed] -->|GET /feed| B[Hono Server<br/>kalshi-scraper]
C[Cron Job] -->|POST /scrape| B
B --> D{Scrape Endpoint}
D -->|Parallel Fetch| E[Kalshi API<br/>fetchAllMarkets]
D -->|Parallel Fetch| F[Kalshi API<br/>fetchEvents]
D -->|Parallel Scrape| G[Browserbase<br/>Playwright DOM Scraping]
E --> H[Transform Markets]
F --> H
G -->|Trending Titles| H
H --> I[Compute Feed Scores<br/>Volume + Controversy<br/>+ Recency + Urgency]
I --> J[Category Mapping<br/>8 Categories]
J --> K[Batch Upsert<br/>Drizzle ORM]
K --> L[(PostgreSQL<br/>Supabase)]
B --> M{Feed Endpoint}
M --> N[Query Markets<br/>Category Filter]
L --> N
N --> O[Cursor Pagination<br/>by feed_score]
O --> P[JSON Response]
P --> A
Last reviewed commit: 0b04c1f |
Hono REST API that ingests Kalshi prediction markets via their public API and Browserbase cloud browser scraping, stores in Supabase via Drizzle ORM, and serves a ranked TikTok-style feed for the kalshi-feed extension. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix cursor pagination: use lt() instead of gt() with desc ordering - Add NaN fallback for limit query param (|| 20) - Replace Math.random() with deterministic hash for stable engagement counts - Remove unused _market param from isTrendingMarket - Use proper KalshiEvent type import instead of inline import() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use 'isCenter' in item narrowing pattern consistent with 'active' check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
apps/kalshi-feed/lib/types/market.ts
Outdated
| | 'science' | ||
| | 'weather' | ||
| | 'tech' | ||
| | 'conspiracy' |
Contributor
There was a problem hiding this comment.
conspiracy category not supported by backend — category-mapper.ts only maps to 8 categories listed in SCHEMA.md (politics, sports, crypto, economics, entertainment, science, weather, tech)
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/kalshi-feed/lib/types/market.ts
Line: 10
Comment:
`conspiracy` category not supported by backend — `category-mapper.ts` only maps to 8 categories listed in `SCHEMA.md` (politics, sports, crypto, economics, entertainment, science, weather, tech)
How can I resolve this? If you propose a fix, please make it concise.Address Greptile review comment: conspiracy category was defined in MarketCategory and FeedCategory types but never mapped by the backend category-mapper. Remove it from types and label map. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Chrome Extension (
apps/kalshi-feed)SCHEMA.mddocuments the exact API contract for the backendBackend Service (
apps/kalshi-scraper)SCHEMA.mdGET /feedwith category filtering + cursor pagination,POST /scrapefor cron-triggered refreshDesign
Hybrid API + Browserbase Scraper. A Bun/Hono service combines Kalshi's public API for structured data with Browserbase + Playwright scraping for curated rankings the API doesn't expose. Both pipelines run in parallel, merge results, compute feed scores, and upsert to Supabase.
New files
Test plan
bun run apps/kalshi-scraper/scripts/test-api.tsto verify API fetching.env, runbun run apps/kalshi-scraper/src/index.tsPOST /scrapewithx-scrape-secretheader triggers ingestionGET /feed?category=trendingreturns ranked marketsGET /feed?category=politics&limit=5returns filtered results🤖 Generated with Claude Code