Skip to content

slegarraga/polydive

Repository files navigation

Polydive

Polydive

The open-source intelligence layer for Polymarket

Real-time analytics, whale tracking, AI-powered analysis, and smart money signals for 25,000+ prediction markets.

Live App  ·  Features  ·  Get Started  ·  API  ·  Architecture  ·  Contributing


What is Polydive?

Polydive is a free, open-source analytics platform built on top of Polymarket — the world's largest prediction market. It gives traders the tools they need to find edge: real-time market data, whale trade tracking, AI-powered analysis, and signal detection across thousands of markets.

No signup required. No paywalls. 100% free.

Features

Markets & Data

  • Market Scanner — Browse 25,000+ active prediction markets with real-time prices, volume, and liquidity
  • Market Detail — Deep dive into any market with order book data, price history charts, and outcome analysis
  • Price History — Custom-built price snapshots taken every 15 minutes for historical chart data
  • Resolution Calendar — See which markets are resolving soon, organized by date

Whale Tracking & Smart Money

  • Whale Alerts — Real-time feed of large trades ($5,000+) detected via WebSocket and cron jobs
  • Smart Money Tracker — See what the top PnL traders are buying and selling right now
  • Trader Leaderboard — Rankings of 1,000+ traders by profit, volume, and win rate
  • Trader Profiles — Detailed stats for any wallet: positions, trade history, category breakdown, weekly activity

Analysis & Signals

  • AI Market Analysis — Perplexity-powered analysis with latest news, sentiment, key factors, and risk assessment
  • Edge Finder — Algorithmic scanner that identifies potentially mispriced markets (thin liquidity, unusual activity, volume surges, contested markets)
  • Signal Detection — Automated alerts for price moves (>10%), volume spikes (>50%), and high activity ratios
  • Market Trends — Aggregate view of what's moving across all markets

More

  • Portfolio Tracker — Paste any wallet address to see full position breakdown and PnL
  • Market Compare — Side-by-side comparison of multiple markets
  • Watchlist — Save markets you're following (stored locally)
  • Keyboard Shortcuts — Power-user navigation (Cmd+K search, etc.)
  • Embeddable Widgets — Embed any market card on external sites
  • Developer API — Free API endpoints for all market data

Getting Started

Prerequisites

1. Clone the repository

git clone https://github.com/slegarraga/polydive.git
cd polydive

2. Install dependencies

npm install

3. Set up environment variables

cp .env.example .env

Open .env and fill in your values. At minimum you need:

Variable Required Description
SUPABASE_URL Yes Your Supabase project URL
SUPABASE_ANON_KEY Yes Supabase anonymous (public) key
SUPABASE_SERVICE_KEY Yes Supabase service role key (for cron jobs/writes)
VITE_SUPABASE_URL Yes Same URL, exposed to frontend via Vite
VITE_SUPABASE_ANON_KEY Yes Same anon key, exposed to frontend via Vite
PERPLEXITY_API_KEY No Enables AI-powered market analysis
DUNE_API_KEY No Enables on-chain trader data from Dune
UPSTASH_REDIS_REST_URL No Enables analysis caching
UPSTASH_REDIS_REST_TOKEN No Redis auth token
VITE_POSTHOG_KEY No PostHog analytics (optional)

4. Set up the database

Create these tables in your Supabase SQL editor:

Database schema (click to expand)
-- Markets table (synced from Polymarket every 5 min)
CREATE TABLE markets (
  id TEXT PRIMARY KEY,
  slug TEXT UNIQUE,
  question TEXT,
  description TEXT,
  image TEXT,
  icon TEXT,
  active BOOLEAN DEFAULT true,
  closed BOOLEAN DEFAULT false,
  archived BOOLEAN DEFAULT false,
  outcome_prices TEXT,
  outcomes TEXT,
  best_bid DECIMAL,
  best_ask DECIMAL,
  spread DECIMAL,
  volume DECIMAL DEFAULT 0,
  volume_24hr DECIMAL DEFAULT 0,
  liquidity DECIMAL DEFAULT 0,
  market_type TEXT,
  group_item_title TEXT,
  category TEXT,
  end_date TIMESTAMPTZ,
  clob_token_ids TEXT,
  condition_id TEXT,
  created_at TIMESTAMPTZ DEFAULT now(),
  updated_at TIMESTAMPTZ DEFAULT now(),
  synced_at TIMESTAMPTZ DEFAULT now()
);

-- Whale trades (detected via WebSocket + cron)
CREATE TABLE whale_trades (
  id TEXT PRIMARY KEY,
  wallet TEXT,
  username TEXT,
  market_question TEXT,
  side TEXT,
  outcome TEXT,
  amount DECIMAL,
  price DECIMAL,
  traded_at TIMESTAMPTZ,
  created_at TIMESTAMPTZ DEFAULT now()
);

-- Price snapshots (taken every 15 min)
CREATE TABLE price_snapshots (
  id BIGSERIAL PRIMARY KEY,
  market_id TEXT NOT NULL,
  yes_price DECIMAL,
  volume_24hr DECIMAL,
  snapshot_at TIMESTAMPTZ DEFAULT now(),
  UNIQUE(market_id, snapshot_at)
);

-- Market signals (auto-detected)
CREATE TABLE market_signals (
  id BIGSERIAL PRIMARY KEY,
  market_id TEXT,
  market_slug TEXT,
  signal_type TEXT,
  signal_value DECIMAL,
  description TEXT,
  created_at TIMESTAMPTZ DEFAULT now()
);

-- Traders leaderboard
CREATE TABLE traders (
  wallet TEXT PRIMARY KEY,
  username TEXT,
  pseudonym TEXT,
  pnl DECIMAL DEFAULT 0,
  volume DECIMAL DEFAULT 0,
  amount DECIMAL DEFAULT 0,
  realized DECIMAL DEFAULT 0,
  unrealized DECIMAL DEFAULT 0,
  rank INTEGER,
  profile_image TEXT,
  positions_count INTEGER,
  markets_count INTEGER,
  markets_traded INTEGER,
  win_rate DECIMAL,
  best_trade DECIMAL,
  total_trades INTEGER,
  join_date TIMESTAMPTZ,
  largest_win DECIMAL,
  first_trade_date TIMESTAMPTZ,
  last_active TIMESTAMPTZ,
  x_username TEXT,
  verified BOOLEAN DEFAULT false,
  synced_at TIMESTAMPTZ DEFAULT now()
);

-- Indexes for performance
CREATE INDEX idx_markets_volume ON markets(volume_24hr DESC);
CREATE INDEX idx_markets_closed ON markets(closed);
CREATE INDEX idx_whale_trades_created ON whale_trades(created_at DESC);
CREATE INDEX idx_whale_trades_wallet ON whale_trades(wallet);
CREATE INDEX idx_price_snapshots_market ON price_snapshots(market_id, snapshot_at DESC);
CREATE INDEX idx_signals_created ON market_signals(created_at DESC);
CREATE INDEX idx_traders_pnl ON traders(pnl DESC);
CREATE INDEX idx_traders_volume ON traders(volume DESC);

5. Run the development server

npm start

This starts both the Vite dev server (port 5181) and the AI analysis server (port 3001) concurrently.

6. Seed initial data (optional)

Sync markets from Polymarket into your database:

SUPABASE_SERVICE_KEY=your-key node scripts/sync-markets.js

Architecture

polydive/
├── src/                    # React frontend (Vite)
│   ├── components/         # Reusable UI components
│   ├── hooks/              # Custom React hooks (realtime, API, alerts)
│   ├── pages/              # Page components (one per route)
│   └── utils/              # Formatting helpers
├── api/                    # Vercel serverless functions
│   ├── cron/               # Scheduled jobs (market sync, whale detection, etc.)
│   └── lib/                # Shared server utilities (caching)
├── scripts/                # One-off data scripts (backfill, import)
├── worker/                 # WebSocket worker for real-time whale detection
└── public/                 # Static assets

Data Flow

Polymarket APIs ──→ Vercel Cron Jobs ──→ Supabase (PostgreSQL)
                                              │
                                              ├──→ REST API (Vercel Functions) ──→ React Frontend
                                              └──→ Realtime Subscriptions ──→ React Frontend
  1. Cron jobs run on Vercel every 2-15 minutes to sync markets, detect whale trades, take price snapshots, and generate signals
  2. Supabase stores all data with real-time subscriptions enabled
  3. API endpoints serve data to the frontend with aggressive caching
  4. React frontend fetches data via API + subscribes to real-time updates for whale alerts and signals

Tech Stack

Layer Technology
Frontend React 19, React Router 7, Vite 7
UI/Animation Framer Motion, Recharts
Data Fetching TanStack React Query
Backend Vercel Serverless Functions
Database Supabase (PostgreSQL + Realtime)
Caching Upstash Redis
AI Analysis Perplexity API
Analytics PostHog
Deployment Vercel

API

Polydive exposes free API endpoints. All endpoints return JSON and support CORS.

Endpoint Description
GET /api/markets List markets with filtering, sorting, pagination
GET /api/whales Recent whale trades ($5K+ in last 20 min)
GET /api/whale-history Historical whale trades with wallet/market filters
GET /api/signals Market signals (price moves, volume spikes)
GET /api/leaderboard Trader leaderboard sorted by PnL or volume
GET /api/trader-stats?wallet=0x... Detailed stats for a specific trader
GET /api/smart-money What top traders are buying/selling now
GET /api/edge-finder Algorithmically detected market opportunities
GET /api/price-history-v2?market=ID Price history chart data
GET /api/activity?user=0x... Full trade history for a wallet
POST /api/analyze AI-powered market analysis

Example

# Get top markets by 24h volume
curl https://polydive.com/api/markets?limit=10&order=volume24hr

# Get recent whale trades
curl https://polydive.com/api/whales?limit=20&minSize=10000

# Get a trader's stats
curl https://polydive.com/api/trader-stats?wallet=0xd25c...

Deployment

Polydive is designed to deploy on Vercel:

  1. Push to GitHub
  2. Connect repo to Vercel
  3. Add environment variables in Vercel dashboard
  4. Deploy — cron jobs are automatically configured via vercel.json

Cron Jobs (auto-configured)

Job Schedule What it does
sync-markets Every 5 min Syncs all active markets from Polymarket
sync-whales Every 2 min Detects and logs whale trades
snapshot-prices Every 15 min Takes price snapshots for chart history
detect-signals Every 5 min Detects price moves and volume spikes
import-traders Every 2 hours Imports traders from leaderboards
enrich-traders Every 10 min Enriches trader profiles with PnL data
generate-analyses Every 6 hours Pre-generates AI analyses for top markets

Contributing

Contributions are welcome! Here's how to help:

  1. Fork the repository
  2. Create a branch for your feature (git checkout -b feature/my-feature)
  3. Commit your changes (git commit -m 'Add my feature')
  4. Push to the branch (git push origin feature/my-feature)
  5. Open a Pull Request

Guidelines

  • Never commit secrets or API keys — use environment variables
  • Test locally before opening a PR
  • Keep PRs focused on a single feature or fix

Security

If you discover a security vulnerability, please report it responsibly by opening a GitHub issue with the security label, or reach out directly.

Do not include real API keys, tokens, or credentials in issues, PRs, or code.

License

MIT — use it, fork it, build on it.


Built with data from Polymarket

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published