Skip to content

Aarav-J/bridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

55 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Bridge - Political Debate Platform

View on Devpost

Breaking down political echo chambers through structured, AI-powered debates

Next.js React TypeScript Socket.IO OpenAI

๐ŸŒ‰ About Bridge

In an era of increasing political polarization, Bridge creates a space for meaningful dialogue across ideological divides. Our platform pairs users with opposing viewpoints for structured, video-based political debates enhanced by AI-powered features.

The Problem

  • Social media algorithms create echo chambers by showing only aligned content
  • Controversial content dominates diverse perspectives
  • No platforms exist for quick, structured political debates
  • Users seeking genuine debate often encounter trolls or bad-faith actors

Our Solution

Bridge provides a structured environment where:

  • Users are matched with those holding opposing political views
  • AI ensures fact-based discussions with real-time analysis
  • Turn-based speaking prevents chaos and promotes respect
  • Video requirements humanize interactions and reduce toxicity

โœจ Key Features

๐Ÿ” User Authentication & Profiles

  • Secure Signup/Login: Full Supabase integration with email verification
  • Comprehensive Profiles: Username, email, age, full name with secure password requirements
  • Political Spectrum Analysis: Detailed breakdown across 5 categories (Economic, Social, Foreign Policy, Governance, Cultural)

๐Ÿง  Intelligent Political Assessment

  • 20-Question Quiz: Based on Pew Research Political Typology methodology
  • Multi-Dimensional Scoring: Liberal-Conservative scale (-100 to +100) across multiple domains
  • Persistent Data: Quiz results stored securely in Supabase database
  • Smart Matching: Results drive our matchmaking algorithm

โšก Advanced Matchmaking System

  • Opposition-Based Pairing: Matches users with opposing political views (minimum 45-point ideological gap)
  • Real-Time Queue: Socket.IO-powered waiting system with live status updates
  • Topic Intelligence: AI analyzes user differences to select optimal debate topics
  • Fallback Matching: Long-waiting users get prioritized after timeout threshold

๐ŸŽฏ Structured Debate Format

6-Phase Timed System:

  1. Opening Statement - User 1 (30s)
  2. Opening Statement - User 2 (30s)
  3. Main Argument - User 1 (120s)
  4. Main Argument - User 2 (120s)
  5. Closing Statement - User 1 (60s)
  6. Closing Statement - User 2 (60s)

๐Ÿค– AI-Powered Features

  • Real-Time Fact-Checking: OpenAI GPT-4 analyzes political claims during debates
  • Topic-Specific Facts: AI generates relevant supporting information for debate topics
  • Sentiment Analysis: Monitors debate tone and emotional indicators
  • Pre-Debate Briefing: AI-generated fact sheets provide context before debates start

๐Ÿ“น Advanced Video System

  • WebRTC Peer-to-Peer: High-quality video calling with Google STUN servers
  • Turn-Based Controls: Automatic muting system enforces speaking order
  • Volume Analysis: Real-time audio level monitoring and visualization
  • Camera Enforcement: Video required during speaking turns to maintain civility

๐Ÿ—๏ธ Technical Architecture

Frontend Stack

  • Framework: Next.js 15.5.3 with App Router
  • UI Library: React 19.1.0 with TypeScript
  • Styling: Tailwind CSS 4 for responsive design
  • State Management: Zustand for user data and session handling
  • Real-Time: Socket.IO Client for live communication

Backend Stack

  • Runtime: Node.js with Express 5.1.0
  • WebSocket: Socket.IO 4.8.1 for real-time features
  • AI Integration: OpenAI GPT-4 for fact-checking and analysis
  • Database: Supabase (PostgreSQL) for user data and authentication

Communication Layer

  • Video: WebRTC for peer-to-peer video calls
  • Signaling: Socket.IO for WebRTC signaling and matchmaking
  • Real-Time Updates: Live user counts, debate status, and queue management

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 18+ and npm
  • Supabase account and project
  • OpenAI API key

Environment Setup

Backend (.env)

OPENAI_API_KEY=your_openai_api_key_here
PORT=3000
NODE_ENV=development
CORS_ORIGIN=*

Frontend (.env.local)

NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
NEXT_PUBLIC_SOCKET_URL=http://localhost:3000
NEXT_PUBLIC_OPENAI_API_KEY=your_openai_api_key_here

Installation & Running

Backend Server

cd server
npm install
npm start

Frontend Application

cd client/my-app
npm install
npm run dev

Application URLs

๐ŸŽฎ User Flow

For New Users

  1. Landing Page โ†’ Signup Form (Supabase authentication)
  2. Political Quiz โ†’ Results & Spectrum Analysis
  3. Main Dashboard โ†’ Matchmaking Queue
  4. Debate Room โ†’ Structured Video Debate

For Returning Users

  • Quiz Complete: Direct access to matchmaking and debates
  • Quiz Incomplete: Prompted to complete political assessment
  • Account Management: Profile viewing and spectrum analysis

๐Ÿ“Š Project Structure

bridge/
โ”œโ”€โ”€ client/my-app/                    # Next.js frontend
โ”‚   โ”œโ”€โ”€ src/app/                     # App router structure
โ”‚   โ”‚   โ”œโ”€โ”€ page.tsx                 # Dynamic landing page with matchmaking
โ”‚   โ”‚   โ”œโ”€โ”€ signup/page.tsx          # User registration
โ”‚   โ”‚   โ”œโ”€โ”€ quiz/page.tsx            # Political spectrum quiz
โ”‚   โ”‚   โ”œโ”€โ”€ account/page.tsx         # User profile
โ”‚   โ”‚   โ”œโ”€โ”€ debate/page.tsx          # Video debate interface
โ”‚   โ”‚   โ””โ”€โ”€ components/              # React components
โ”‚   โ”‚       โ”œโ”€โ”€ QuizQuestion.tsx     # Quiz interface
โ”‚   โ”‚       โ”œโ”€โ”€ Video.tsx            # Video components
โ”‚   โ”‚       โ”œโ”€โ”€ ControlPanel.tsx     # Debate controls
โ”‚   โ”‚       โ”œโ”€โ”€ SpeechRecognition.tsx # AI transcription
โ”‚   โ”‚       โ”œโ”€โ”€ FactCheckDisplay.tsx # AI fact-checking
โ”‚   โ”‚       โ”œโ”€โ”€ SentimentAnalysis.tsx # AI sentiment tracking
โ”‚   โ”‚       โ””โ”€โ”€ PoliticalFacts.tsx   # AI-generated facts
โ”‚   โ”œโ”€โ”€ src/utils/
โ”‚   โ”‚   โ”œโ”€โ”€ factCall.ts              # OpenAI API integration
โ”‚   โ”‚   โ””โ”€โ”€ supabaseClient.ts        # Database client
โ”‚   โ””โ”€โ”€ src/store/
โ”‚       โ””โ”€โ”€ useStore.ts              # Zustand state management
โ””โ”€โ”€ server/                          # Express + Socket.IO backend
    โ”œโ”€โ”€ server.js                    # Main server with matchmaking
    โ””โ”€โ”€ services/
        โ””โ”€โ”€ aiService.js             # AI service integration

๐Ÿ”ง Core Components

Matchmaking Algorithm

  • Ideological Opposition: Minimum 45-point gap on political spectrum
  • Queue Management: Real-time waiting system with disconnect handling
  • Topic Selection: AI analyzes user differences to choose debate subjects
  • Room Management: Supports multiple concurrent debates

Debate System

  • Phase Management: Automated transitions through 6 debate phases
  • Speaker Control: Turn-based audio with automatic muting
  • Timer System: Real-time countdowns with phase progression
  • Emergency Handling: Graceful disconnection and room cleanup

AI Features

  • Fact-Checking: Real-time analysis of political claims
  • Context Generation: Topic-specific supporting information
  • Sentiment Monitoring: Emotional tone analysis during debates
  • Pre-Debate Briefing: AI-generated fact sheets for preparation

๐Ÿ› ๏ธ Development Highlights

Technical Achievements

  • Full-Stack Integration: Seamless connection between React frontend and Node.js backend
  • Real-Time Architecture: Socket.IO handling matchmaking, signaling, and live updates
  • WebRTC Implementation: Peer-to-peer video calling with advanced controls
  • AI Integration: OpenAI GPT-4 for fact-checking and political analysis
  • Database Design: Comprehensive Supabase schema for user data and quiz results

Challenges Overcome

  • Supabase Integration: Complex authentication and database setup
  • P2P Networking: WebRTC connection establishment across local networks
  • State Management: User data persistence across route changes
  • Real-Time Synchronization: Managing multiple concurrent debates and matchmaking

๐ŸŽฏ Future Roadmap

Immediate Priorities

  • Enhanced AI Moderation: Real-time content filtering and toxicity detection
  • Advanced Matching: Historical performance and preference-based algorithms
  • Mobile Optimization: Responsive design improvements for mobile devices

Long-Term Vision

  • Scale-Up Features: Support for large-scale debate events and tournaments
  • Advanced Analytics: Debate performance metrics and user engagement insights
  • Platform Expansion: Integration with external video services (Twilio, Daily.co)
  • Content Recording: Debate archival and replay functionality

๐Ÿ† Built With

  • Frontend: Next.js, React, TypeScript, Tailwind CSS, Zustand
  • Backend: Node.js, Express, Socket.IO
  • Database: Supabase, PostgreSQL
  • AI: OpenAI GPT-4
  • Communication: WebRTC, Socket.IO
  • Authentication: Supabase Auth

๐Ÿ“„ License

This project is available under the MIT License. See the LICENSE file for more details.


Bridge - Connecting minds across the political divide

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors