How to extend the system, particularly around the web dashboard.
┌────────────────────────────┐
│ Multi-Agent System │
│ (Data, Sentiment, Gaps, │
│ Reporting) │
└────────────┬───────────────┘
│
v
┌──────────────┐
│ PostgreSQL │
└──────────────┘
The dashboard (FastAPI + vanilla JS) is already built and running. This guide covers extending it further or building a proper frontend on top.
If you want something more than the built-in vanilla JS dashboard:
┌────────────────────────────┐
│ Multi-Agent System │
└────────────┬───────────────┘
v
┌──────────────┐
│ PostgreSQL │ <── FastAPI (already exists)
└──────────────┘ │
v
┌──────────────────┐
│ React/Vue App │
└──────────────────┘
The FastAPI backend already has endpoints. You'd just build a frontend that talks to them.
These are already live at http://localhost:8000:
GET /api/gapswith confidence/type filtersGET /api/gaps/exportfor CSVGET /api/contractsfor top contractsGET /api/sentiment/{contract_id}for sentiment historyGET /api/cyclesfor pipeline run historyGET /api/sourcesfor data source statusGET /api/backtestfor backtesting resultsGET /api/alertsfor new gap notifications
frontend/
├── src/
│ ├── components/
│ │ ├── GapCard.jsx
│ │ ├── GapList.jsx
│ │ ├── SentimentChart.jsx
│ │ └── Dashboard.jsx
│ ├── services/
│ │ └── api.js
│ └── App.jsx
├── package.json
└── tailwind.config.js
If you want live updates instead of polling, add a WebSocket endpoint:
# src/api/routes/websocket.py
from fastapi import WebSocket, WebSocketDisconnect
class ConnectionManager:
def __init__(self):
self.active_connections = []
async def connect(self, websocket):
await websocket.accept()
self.active_connections.append(websocket)
def disconnect(self, websocket):
self.active_connections.remove(websocket)
async def broadcast(self, message):
for conn in self.active_connections:
await conn.send_json(message)Then broadcast new gaps from the detection loop.
# In main.py, the API server already starts alongside the agents
# For a separate frontend dev server:
cd frontend && npm start
# Frontend at :3000, API at :8000- Live gaps feed with filters by confidence, type, category
- Contract explorer with historical odds charts
- Sentiment trends broken down by source (RSS vs Bluesky vs Grok etc)
- Performance metrics tracking prediction accuracy over time
- Analytics showing gap frequency, confidence distribution, category breakdown
Docker setup:
services:
postgres:
image: postgres:14
environment:
POSTGRES_DB: polymarket_gaps
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- ./data:/var/lib/postgresql/data
detector:
build: .
environment:
- DATABASE_URL=postgresql://postgres:${DB_PASSWORD}@postgres:5432/polymarket_gaps
depends_on:
- postgres
api:
build: .
command: uvicorn src.api.server:app --host 0.0.0.0
ports:
- "8000:8000"
depends_on:
- postgres- Alerting: Telegram/email for high-confidence gaps. The bot infra already exists in other projects.
- ML sentiment: FinBERT or similar to reduce LLM costs for bulk sentiment work.
- Redis caching if query volume gets high.
- Better indexes on the PostgreSQL tables as data grows.
Cross-market arbitrage is built in. The gap detector searches Kalshi and Manifold for matching contracts, with semantic inversion detection so it doesn't false-flag markets with flipped wording. Config in .env:
ENABLE_KALSHI=true
ENABLE_MANIFOLD=true
ARBITRAGE_MIN_EDGE=0.10- JWT auth on API endpoints
- Rate limiting
- Input validation
- HTTPS
- DB connection pooling (already in place)