AI-powered debate platform for structured discourse
Create topics, contribute arguments, let AI synthesize understanding. The resilient platform for structured debate.
Debately is a fact-checked debate platform that uses Claude AI to synthesize arguments, verify claims, and provide evidence-based analysis. It enables users to engage in structured debates with automatic fact-checking, AI-powered synthesis, and intelligent argument matching.
- AI-Powered Synthesis - Claude Sonnet 4 generates comprehensive debate summaries, consensus views, and timelines
- Automatic Fact-Checking - Claude Haiku + Tavily verify arguments and assign 1-5 star validity scores
- Relevance Filtering - AI automatically rejects irrelevant arguments (no spam or off-topic content)
- Evidence-Based Scoring - Validity scores based on high-quality sources (relevance score > 0.5)
- Voting System - Users can upvote/downvote arguments to show support
- Argument Matching - AI identifies which pro arguments directly rebut con arguments
- Topic Metrics - View average validity scores, controversy levels, and argument counts
- Comments - Users can comment on arguments for deeper discussion
- Authentication - Secure user authentication via Supabase with Google OAuth
- Proposition Validation - AI validates and reformulates debate propositions for clarity
- Contribution Limits - Per-user contribution limits (25 topics + arguments combined) to ensure quality
- API Rate Limiting - Global API call limits (750 per service) to manage costs
- Framework: FastAPI (async Python framework)
- Database: PostgreSQL with psycopg2
- AI Models:
- Claude Sonnet 4 (
claude-sonnet-4-20250514) - Synthesis, matching, proposition validation - Claude Haiku (
claude-3-haiku-20240307) - Fast fact-checking
- Claude Sonnet 4 (
- APIs:
- Anthropic API - Claude AI integration
- Tavily API - Evidence search and fact verification
- Authentication: Supabase Auth with JWT tokens
- Security: Immutable configuration system, secure API key management
- Deployment: Docker support with docker-compose for development
- Framework: Next.js 16 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS 4.1.9
- UI Components: Shadcn/ui (Radix UI primitives)
- Authentication: Supabase SSR with middleware
- State Management: React Context API
- Visual Effects: Aurora background animations
- Analytics: Vercel Analytics
- Python 3.11+
- Node.js 18+
- PostgreSQL 15+ (or use Docker)
- Anthropic API key (Get one here)
- Tavily API key (Get one here)
- Supabase account (Get one here)
- Navigate to backend directory:
cd backend- Install dependencies:
pip install -r requirements.txt-
Set up environment variables:
Create a
.envfile in thebackenddirectory:
# Required: Anthropic API Key
ANTHROPIC_API_KEY=your_anthropic_key_here
# Required: Tavily API Key
TAVILY_API_KEY=your_tavily_key_here
# Required: Supabase Configuration
SUPABASE_URL=https://xxxxx.supabase.co
SUPABASE_ANON_KEY=your_anon_key_here
SUPABASE_JWT_SECRET=your_jwt_secret_here
# Required: Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=debate_platform
DB_USER=postgres
DB_PASSWORD=your_password
# Optional: CORS Configuration
ALLOWED_ORIGINS=http://localhost:3000- Set up PostgreSQL database:
# Create database
createdb debate_platform
# Or using psql
psql -U postgres
CREATE DATABASE debate_platform;-
Run database migrations: The database tables are automatically created on first run via
database.init_db(). -
Run the server:
uvicorn main:app --reloadBackend will be available at http://localhost:8000
Note: For detailed Supabase authentication setup, see SUPABASE_AUTH_SETUP.md
- Navigate to frontend directory:
cd frontend- Install dependencies:
npm install-
Set up environment variables:
Create a
.env.localfile in thefrontenddirectory:
NEXT_PUBLIC_SUPABASE_URL=https://xxxxx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key_here
NEXT_PUBLIC_API_URL=http://localhost:8000- Run the development server:
npm run devFrontend will be available at http://localhost:3000
For containerized development with PostgreSQL:
cd backend
docker-compose upThis will:
- Start PostgreSQL in a container
- Start the FastAPI backend with hot-reload
- Automatically sync code changes
- Sign In - Use Google OAuth to authenticate (configured via Supabase)
- Create a Debate - Click "Start a Debate" and enter a proposition
- Add Arguments - Submit pro and con arguments with sources
- Automatic Verification - Arguments are automatically fact-checked on submission
- View Analysis - Claude generates summaries, consensus views, and timelines automatically
- Vote - Upvote or downvote arguments to show support
- Comment - Add comments on arguments for deeper discussion
The platform uses a cost-optimized multi-model approach:
-
Claude Sonnet 4: Used for complex reasoning tasks
- Debate synthesis (overall summary, consensus view, timeline)
- Argument matching (identifying which pro arguments rebut con arguments)
- Proposition validation and reformulation
-
Claude Haiku: Used for fast, cost-effective tasks
- Fact-checking (10x cheaper, 2-3x faster than Sonnet)
- Relevance checking
- Claim extraction
- Extract Core Claim - Claude Haiku extracts the verifiable factual claim from the argument
- Search Evidence - Tavily API searches for evidence (filters sources with relevance score > 0.5)
- Analyze & Score - Claude Haiku analyzes evidence and assigns 1-5 star validity score
- Store Results - Validity score, reasoning, and key URLs are saved to the database
Before saving an argument, the system:
- Checks if the argument is relevant to the debate proposition
- Rejects irrelevant arguments (opinions, spam, off-topic content)
- Provides clear reasoning for rejection
- Global API call limit: 750 calls per service (Anthropic, Tavily)
- Tracks usage in
api_usagetable - Prevents excessive API costs
- Per-user limit: 25 contributions (topics + arguments combined)
- Enforced before expensive operations (fact-checking)
- Prevents abuse and ensures quality
POST /api/topics- Create a new debate topicGET /api/topics- Get all topics with metricsGET /api/topics/{topic_id}- Get topic with arguments and analysisPOST /api/topics/{topic_id}/arguments- Create an argumentPOST /api/arguments/{argument_id}/verify- Verify argument validityPOST /api/arguments/{argument_id}/upvote- Upvote an argumentPOST /api/arguments/{argument_id}/downvote- Downvote an argumentPOST /api/topics/validate-proposition- Validate and reformulate proposition
.
├── backend/ # FastAPI backend
│ ├── routes/ # API endpoint modules
│ │ ├── topics.py # Topic CRUD operations
│ │ ├── arguments.py # Argument CRUD operations
│ │ ├── summaries.py # AI synthesis endpoints
│ │ ├── fact_checking.py # Fact-checking endpoints
│ │ ├── voting.py # Voting and comments
│ │ └── auth.py # Authentication endpoints
│ ├── middleware/ # Middleware modules
│ │ └── auth.py # Supabase JWT authentication
│ ├── utils/ # Utility modules
│ │ └── user.py # User profile management
│ ├── database.py # Database operations and migrations
│ ├── claude_service.py # Claude Sonnet 4 integration
│ ├── fact_checker.py # Claude Haiku fact-checking
│ ├── validate_proposition.py # Proposition validation
│ ├── config.py # Immutable configuration system
│ ├── models.py # Pydantic request/response models
│ ├── main.py # FastAPI application entry point
│ ├── requirements.txt # Python dependencies
│ ├── Dockerfile # Production Docker image
│ └── docker-compose.yml # Development Docker setup
│
├── frontend/ # Next.js frontend
│ ├── app/ # Next.js App Router pages
│ │ ├── page.tsx # Home page
│ │ ├── browse/ # Browse debates page
│ │ ├── new/ # Create debate page
│ │ ├── topic/[id]/ # Topic detail page
│ │ └── auth/callback/ # OAuth callback handler
│ ├── components/ # React components
│ │ ├── Header.tsx # Navigation header
│ │ ├── AuroraBackground.tsx # Visual effects
│ │ ├── auth/ # Authentication components
│ │ └── ui/ # Shadcn/ui components
│ ├── contexts/ # React context providers
│ │ ├── AuthContext.tsx # Authentication state
│ │ └── AuroraContext.tsx # Aurora effects state
│ ├── lib/ # Library code
│ │ ├── supabase/ # Supabase client setup
│ │ └── utils.ts # Utility functions
│ ├── src/ # Source code
│ │ └── api.ts # API client functions
│ ├── public/ # Static assets
│ │ └── logo-icon.png # Application logo
│ ├── package.json # Node.js dependencies
│ └── tsconfig.json # TypeScript configuration
│
├── SUPABASE_AUTH_SETUP.md # Supabase authentication guide
└── README.md # This file
- user_profiles - User account information (linked to Supabase auth)
- topics - Debate topics/propositions
- arguments - Pro/con arguments with validity scores
- comments - Comments on arguments
- argument_matches - AI-identified pro/con argument relationships
- votes - User votes on arguments
- api_usage - API call tracking for rate limiting