-
Step 1 of 6Collect
Poll every 5 minutes
A data collector fetches the active markets from Polymarket's Gamma API as soon as it starts, then every 5 minutes. It upserts each market's question, category and end date.
-
Step 2 of 6Store
Keep a price history
Every poll stores the market's current probability and 24-hour volume as a new point in SQLite through Prisma. An index on (marketId, timestamp) keeps the history lookups fast.
-
Step 3 of 6Edge case
Pick a fair baseline
To measure a move, the detector compares the newest price with the earliest one in the last 24 hours. If there isn't a day of history yet, it falls back to a shorter look-back window, then to the earliest known price.
-
Step 4 of 6Detect
Flag the move
Changes of 10% or more are saved as movements: minor from 10%, moderate from 15%, major from 25%. The same market isn't flagged twice within an hour, so the feed doesn't fill with duplicates.
-
Step 5 of 6Serve
Serve the feed
Next.js API routes serve the movements, filtered by significance, and each market's history. The feed refreshes itself, and a market page charts the price over 1h, 6h, 24h or 7d with Recharts.
-
Step 6 of 6Recap
The whole loop
Poll, store, compare against a 24-hour baseline, classify and serve. The threshold and look-back window are environment settings, so the same code can watch for smaller or larger moves.
Tip: the ← and → keys work too.