AI-powered debate platform that simulates multi-perspective discussions on Polymarket prediction markets. Watch different AI models debate market outcomes with real-time text-to-speech narration.
- AI Debates - Multiple AI models debate prediction market outcomes in real-time
- Market Integration - Direct integration with Polymarket API for live market data
- Text-to-Speech - Audio narration of debates using ElevenLabs voices
- Real-time Updates - Server-Sent Events (SSE) for live debate streaming
- User Authentication - Secure email-based authentication with JWT tokens
- Favorites System - Bookmark and track your favorite markets
- Multi-Model Support - Support for 100+ AI models via OpenRouter API
- Responsive UI - Modern interface built with Next.js and Tailwind CSS
Backend:
- Flask 3.0.0, SQLite + SQLAlchemy
- JWT authentication with bcrypt
- OpenRouter API (Claude, GPT-4, Gemini, etc.)
- ElevenLabs TTS, Gmail SMTP
- Python 3.8+
Frontend:
- Next.js 16.0.3, TypeScript
- Tailwind CSS 4.0
- Radix UI, Framer Motion
- React Context API
- Node.js 18+
- Python 3.8+
- Node.js 18+
- API Keys: OpenRouter, ElevenLabs, Gmail App Password
# Clone repository
git clone https://github.com/yourusername/polydebate.git
cd polydebate
# Backend setup
cd backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
# Frontend setup
cd ../frontend
npm installCopy .env.example to .env and configure:
OPENROUTER_API_KEY=your_key_here
ELEVENLABS_API_KEY=your_key_here
GMAIL_USER=your_email@gmail.com
GMAIL_APP_PASSWORD=your_app_password
JWT_SECRET_KEY=your_secret_key# Terminal 1 - Backend
cd backend
python app.py
# Terminal 2 - Frontend
cd frontend
npm run devOpen http://localhost:3000
polydebate/
├── backend/
│ ├── app.py # Flask app entry point
│ ├── config.py # Configuration
│ ├── models/ # SQLAlchemy models
│ ├── routes/ # API endpoints
│ ├── services/ # Business logic
│ └── requirements.txt
├── frontend/
│ ├── src/
│ │ ├── app/ # Next.js pages
│ │ ├── components/ # React components
│ │ ├── contexts/ # State management
│ │ └── lib/api.ts # API client
│ └── package.json
└── storage/ # Database & audio files
| Doc | Description |
|---|---|
| ROADMAP.md | Project roadmap and stages |
| STAGE_1.md | Current stage implementation plan |
| API_SPECIFICATION.md | Full API documentation |
| specification.md | Original project specification |
| frontend/docs/design.md | Frontend design system |
| frontend/docs/implementation_plan.md | Frontend implementation details |
Authentication:
POST /api/auth/signup/request-code- Request signup codePOST /api/auth/signup/verify-code- Verify and create accountPOST /api/auth/login/request-code- Request login codePOST /api/auth/login/verify-code- Verify and loginGET /api/auth/me- Get current user
Markets:
GET /api/markets- List marketsGET /api/markets/:slug- Market detailsGET /api/categories- Categories
Debates:
POST /api/debates- Create debateGET /api/debates/:id- Get debateGET /api/debates/:id/stream- SSE stream
Favorites:
GET /api/favorites- List favoritesPOST /api/favorites- Add favoriteDELETE /api/favorites/:id- Remove favorite
The platform uses Server-Sent Events (SSE) to stream debates in real-time:
How it works:
- Client creates a debate via
POST /api/debates - Client connects to SSE endpoint:
GET /api/debates/:id/stream - Backend streams events as AI models generate responses:
debate_started- Debate initializationmodel_response- Each AI model's argument with predictionsround_complete- Round finisheddebate_complete- All rounds finished with final summaryerror- Any errors during debate
| Variable | Description | Required |
|---|---|---|
OPENROUTER_API_KEY |
OpenRouter API key | Yes |
ELEVENLABS_API_KEY |
ElevenLabs API key | Yes |
GMAIL_USER |
Gmail address | Yes |
GMAIL_APP_PASSWORD |
Gmail app password | Yes |
JWT_SECRET_KEY |
JWT secret | Yes |
FRONTEND_URL |
Frontend URL | No |
PORT |
Backend port | No |
Backend won't start:
- Check Python version:
python --version(3.8+) - Verify
.envfile exists with required keys - Ensure port 5001 is available
Frontend won't start:
- Check Node version:
node --version(18+) - Clear and reinstall:
rm -rf node_modules && npm install
Audio not generating:
- Verify ElevenLabs API key is valid
- Check API quota not exceeded
- Ensure
storage/audiodirectory exists
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
MIT License
- Polymarket - Market data API
- OpenRouter - Multi-model AI access
- ElevenLabs - Text-to-speech
Built for the prediction market community