A full-stack application that aggregates and analyzes prediction market data from platforms like Polymarket. Built with a modern tech stack featuring a FastAPI backend, Next.js frontend, and PostgreSQL (Supabase) for data persistence.
Prediction markets are platforms where users trade on the outcomes of future events, with prices reflecting the crowd's probability estimates. This project provides:
- Real-time data aggregation from the Polymarket API
- Normalized market data with standardized pricing across different outcome types
- RESTful API for querying and filtering markets
- Modern dashboard UI displaying market probabilities and metadata
- Persistent storage with PostgreSQL via Supabase
- FastAPI — High-performance async Python web framework
- asyncpg — Async PostgreSQL driver for connection pooling
- httpx — Async HTTP client for API requests
- Pydantic — Data validation and serialization
- Supabase (PostgreSQL) — Cloud-hosted database
- Next.js 16 — React framework with App Router
- React 19 — UI library
- TypeScript — Type-safe JavaScript
- Tailwind CSS 4 — Utility-first styling
- Terraform — Infrastructure as Code (AWS provider configured)
prediction-market-analyzer/
├── backend/
│ ├── app/
│ │ ├── main.py # FastAPI application entry point
│ │ ├── routers/
│ │ │ └── markets.py # Market API endpoints
│ │ ├── schemas/
│ │ │ └── market.py # Pydantic models
│ │ └── services/
│ │ ├── db_service.py # Database connection pool & queries
│ │ └── polymarket_service.py # Polymarket API integration
│ └── scripts/
│ └── sync_polymarket.py # Data sync script
├── frontend/
│ └── app/
│ ├── page.tsx # Main dashboard page
│ ├── layout.tsx # Root layout
│ └── globals.css # Global styles
├── infra/
│ └── aws/
│ └── main.tf # Terraform AWS configuration
└── docs/
- Polymarket API integration with async data fetching
- Normalized market data extraction (handles Yes/Up/Win/Pass outcomes)
- PostgreSQL database with connection pooling
- RESTful API endpoints (
GET /markets,GET /markets/{id}) - CORS configuration for local development
- Health check endpoint
- Next.js dashboard with market listing
- Responsive UI with Tailwind CSS
- Data sync script for batch market ingestion
- Price history tracking and trend analysis
- AI-powered market summaries
- Kalshi integration (multi-provider support)
- Market filtering and search
- Individual market detail pages
- Real-time WebSocket updates
- AWS deployment via Terraform
- Python 3.11+
- Node.js 18+
- PostgreSQL database (or Supabase account)
-
Navigate to the backend directory:
cd backend -
Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install fastapi uvicorn asyncpg httpx python-dotenv pydantic
-
Configure environment variables: Create a
.envfile in the project root:SUPABASE_DSN=postgresql://user:password@host:port/database
-
Run the sync script to populate data:
python -m scripts.sync_polymarket
-
Start the API server:
uvicorn app.main:app --reload
The API will be available at
http://localhost:8000
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Start the development server:
npm run dev
The dashboard will be available at
http://localhost:3000
| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Health check |
GET |
/markets |
List all markets |
GET |
/markets/{market_id} |
Get market details with price history |
{
"id": "poly-12345",
"provider": "polymarket",
"title": "Will Bitcoin reach $100k by end of 2025?",
"url": "https://polymarket.com/market/btc-100k",
"current_price": 0.63,
"last_updated": "2025-11-29T09:00:00Z"
}CREATE TABLE prediction_markets (
id TEXT PRIMARY KEY,
provider TEXT NOT NULL,
title TEXT NOT NULL,
current_price DECIMAL,
last_updated TIMESTAMP WITH TIME ZONE
);┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Next.js │────▶│ FastAPI │────▶│ Supabase │
│ Frontend │ │ Backend │ │ PostgreSQL │
└─────────────┘ └─────────────┘ └─────────────┘
│
▼
┌─────────────┐
│ Polymarket │
│ API │
└─────────────┘
MIT
Built as a portfolio project demonstrating full-stack development with modern async Python, React, and cloud database integration.