Skip to content

A 1 v 1 competitive programming platform with questions available

Notifications You must be signed in to change notification settings

YashSensei/AlgoWars

Repository files navigation

AlgoWars

A real-time 1v1 competitive programming platform where users compete head-to-head solving algorithmic problems.

AlgoWars

Features

  • 1v1 Real-time Matches - Battle against opponents in timed coding challenges
  • Rating System - Elo-based ranking (+5/-5 per win/loss)
  • AI-Powered Judge - Code evaluated by Claude AI (MegaLLM)
  • Monaco Editor - VS Code-like coding experience with syntax highlighting
  • Resizable Panels - Customize your workspace layout
  • Live Updates - Real-time opponent status via WebSockets

Tech Stack

Backend

  • Runtime: Bun (faster than Node.js)
  • Framework: Hono (lightweight, fast)
  • Database: PostgreSQL + Drizzle ORM
  • Real-time: Socket.IO
  • Auth: JWT + bcrypt

Frontend

  • Framework: Next.js 16 (App Router)
  • Styling: Tailwind CSS v4
  • Editor: Monaco Editor
  • State: Zustand
  • UI Components: shadcn/ui

Getting Started

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/YashSensei/AlgoWars.git
    cd AlgoWars
  2. Start the database

    docker compose up -d
  3. Setup backend

    # Install dependencies
    bun install
    
    # Setup environment
    cp .env.example .env
    # Edit .env with your database URL and API keys
    
    # Run migrations
    bun run db:migrate
    
    # Ingest problems from scraped Codeforces data
    bun run db:ingest
    
    # Start development server
    bun run dev
  4. Setup frontend

    cd frontend
    
    # Install dependencies
    npm install
    
    # Start development server
    npm run dev
  5. Open the app

Environment Variables

Backend (.env)

DATABASE_URL=postgresql://user:password@localhost:5432/algowars
JWT_SECRET=your-secret-key-min-16-chars
MEGALLM_API_KEY=your-megallm-api-key

Frontend (.env.local)

NEXT_PUBLIC_API_URL=http://localhost:8080

Project Structure

algowars/
├── src/                    # Backend source
│   ├── routes/            # API routes
│   ├── services/          # Business logic
│   ├── db/                # Database schema
│   ├── socket/            # WebSocket handlers
│   └── lib/               # Utilities
├── frontend/              # Next.js frontend
│   ├── src/app/          # App router pages
│   ├── src/components/   # React components
│   ├── src/lib/          # API client, utilities
│   └── src/stores/       # Zustand state
└── drizzle/              # Database migrations

Available Scripts

Backend

bun run dev          # Start with hot reload
bun run build        # Build for production
bun run start        # Run production build
bun run lint         # Lint with Biome
bun run typecheck    # TypeScript check
bun run db:generate  # Generate migrations
bun run db:migrate   # Apply migrations
bun run db:ingest    # Ingest problems from scraped data
bun run db:studio    # Open Drizzle Studio

Frontend

npm run dev          # Start dev server
npm run build        # Build for production
npm run lint         # ESLint check
npm run typecheck    # TypeScript check

Gameplay

  1. Find a Match - Click "Find Match" to enter the queue
  2. Wait for Opponent - Matched with players within ±100 rating
  3. Solve the Problem - Read the problem, write your solution
  4. Submit - Code is judged by AI for correctness
  5. Win or Learn - First to solve wins, rating updates instantly

Rating System

Event Rating Change
Win +5
Loss -5
Timeout -5 (both)

Starting rating: 1000

Screenshots

The platform features a dark cyberpunk-inspired design with:

  • Glass panel effects
  • Animated backgrounds
  • Japanese text accents
  • Red accent colors

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License.

Acknowledgments

About

A 1 v 1 competitive programming platform with questions available

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors