Skip to content

dinesh-git17/debate-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Debate Lab

Watch the world's leading AI models debate any topic in real-time.

CI CodeQL Next.js 15 TypeScript License


FeaturesHow It WorksQuick StartTech StackDocumentation


✨ Features

🤖 Real AI Debates

Not scripted. Not simulated. Watch ChatGPT and Grok engage in genuine intellectual discourse with real reasoning, real arguments, and real-time responses.

⚖️ Neutral Moderation

Claude serves as an impartial moderator, ensuring balanced discussion, enforcing debate rules, and providing insightful interventions when needed.

🌍 Any Topic

From technology and politics to philosophy and ethics — you define the subject, and the AI models bring the discourse.

⚡ Real-Time Streaming

Experience debates as they unfold with live streaming responses. No waiting, no refreshing — just pure, uninterrupted AI discourse.

📊 Comprehensive Judging

Get detailed scoring, clash analysis, and educational insights from an AI judge that evaluates argumentation quality, evidence usage, and rhetorical effectiveness.

🔗 Share & Export

Generate shareable links, export full transcripts in multiple formats (Markdown, JSON, PDF), and embed debates anywhere.


🎯 How It Works

┌─────────────────────────────────────────────────────────────────────────┐
│                                                                         │
│    1. CHOOSE           2. WATCH              3. LEARN                   │
│                                                                         │
│    ┌─────────┐        ┌─────────────┐        ┌─────────────┐            │
│    │  Topic  │   ──►  │  Real-Time  │   ──►  │   Scoring   │            │
│    │  + Rules│        │   Debate    │        │   Summary   │            │
│    └─────────┘        └─────────────┘        └─────────────┘            │
│                                                                         │
│    Pick any topic      ChatGPT & Grok        Get detailed               │
│    and customize       argue while Claude    analysis and               │
│    debate rules        moderates             key insights               │
│                                                                         │
└─────────────────────────────────────────────────────────────────────────┘

🚀 Quick Start

Prerequisites

Installation

# Clone the repository
git clone https://github.com/dinesh-git17/debate-lab.git
cd debate-lab

# Install dependencies
npm ci

# Configure environment
cp .env.example .env.local
# Edit .env.local with your API keys

# Start development server
npm run dev

Open http://localhost:3000 and start your first debate.


🛠️ Tech Stack

Next.js
Next.js 15
App Router
TypeScript
TypeScript
Type Safety
Tailwind
Tailwind 4
Styling
React
React 19
UI Library

Architecture

Layer Technology Purpose
Frontend React 19, Framer Motion Interactive UI with fluid animations
Styling Tailwind CSS 4, CSS Variables Design system with dark/light themes
State Zustand, TanStack Query Client state + server cache
Real-time Pusher, SSE Live streaming updates
AI Providers OpenAI, Anthropic, xAI Multi-model orchestration
Validation Zod, React Hook Form Schema-first form handling
Testing Vitest, Playwright, MSW Unit, integration & E2E tests
Monitoring Sentry, Web Vitals Error tracking & performance

📁 Project Structure

src/
├── app/                    # Next.js App Router
│   ├── (debate)/           # Debate creation routes
│   ├── (fullscreen)/       # Immersive debate experience
│   ├── (marketing)/        # Landing & info pages
│   └── api/                # REST API endpoints
│
├── components/
│   ├── ui/                 # Design system primitives
│   ├── features/           # Feature-specific components
│   ├── debate/             # Debate UI components
│   ├── judge/              # Scoring & analysis views
│   └── summary/            # Post-debate summaries
│
├── services/
│   ├── llm/                # AI provider abstraction
│   ├── debate-engine.ts    # Core debate orchestration
│   ├── judge-service.ts    # Scoring & evaluation
│   └── turn-sequencer.ts   # Turn management
│
├── lib/
│   ├── security/           # Rate limiting, content filtering
│   ├── logging/            # Structured logging, metrics
│   ├── prompts/            # AI prompt templates
│   └── performance/        # Optimization utilities
│
├── hooks/                  # Custom React hooks
├── store/                  # Zustand state stores
└── types/                  # TypeScript definitions

⚙️ Configuration

Environment Variables

Create .env.local from the example and configure:

Variable Required Description
OPENAI_API_KEY OpenAI API key (GPT-4)
ANTHROPIC_API_KEY Anthropic API key (Claude)
XAI_API_KEY xAI API key (Grok)
SESSION_SECRET Session encryption secret
PUSHER_* Real-time event streaming
UPSTASH_* Redis for rate limiting
SUPABASE_* Persistence & abuse tracking
SENTRY_DSN Error monitoring

Feature Flags

ENABLE_CUSTOM_RULES=true     # Allow custom debate rules
MAX_DEBATE_TURNS=10          # Maximum turns per debate
TOKEN_BUDGET_PER_DEBATE=50000  # Token limit per debate
DEBATE_MODE=prod             # 'prod' or 'mock' for testing

📜 Available Scripts

Command Description
npm run dev Start development server with Turbopack
npm run build Create optimized production build
npm run start Start production server
npm run lint Run ESLint checks
npm run typecheck Run TypeScript compiler checks
npm run test Run unit tests with Vitest
npm run test:e2e Run E2E tests with Playwright
npm run format Format code with Prettier

🔒 Security

Debate Lab implements defense-in-depth security:

  • Rate Limiting — Configurable per-IP and per-session limits
  • Content Filtering — Multi-layer content moderation (regex + semantic + OpenAI moderation API)
  • Input Sanitization — XSS prevention and injection protection
  • Abuse Tracking — Privacy-preserving IP hashing with automatic bans
  • CSP Headers — Strict Content Security Policy enforcement
  • API Authentication — Secure admin endpoints with API key validation

📖 Documentation

Resource Description
Contributing Guide Branch strategy, commit conventions, PR process
Debate Rules Built-in debate rule definitions
API Routes REST API endpoint implementations

🤝 Contributing

Contributions are welcome! Please read the Contributing Guide for details on our development workflow, coding standards, and pull request process.

# Create a feature branch
git checkout -b feature/your-feature-name

# Make your changes and commit
git commit -m "feat(scope): description"

# Push and create a PR
git push -u origin feature/your-feature-name

📄 License

This project is licensed under the Elastic License 2.0.

✅ Free for personal and internal use ✅ Modify and distribute source code
❌ Cannot offer as a managed service ❌ Cannot circumvent license protections

For commercial SaaS licensing, please contact the repository owner.


Built with ❤️ for the AI research community

Report BugRequest Feature