Skip to content

Full fledged implementation of an online judge with codeforces problem parsing capabilities

Notifications You must be signed in to change notification settings

nubskr/codespace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎉 Codespaces

I was curious about how Codeforces worked, so created my own version! Welcome to Codespaces—your social problem solving playground! 🧑‍💻✨

aww

✨ Features

  • ✏️ Create Your Own Problems: Feeling creative? You can also create and manage your own coding problems! 🎨

  • 🔍 Codeforces Problem Scraping: Users can just enter a Codeforces problem link and watch the magic happen! The problem statement and test cases are automatically parsed and shared across all the users int the room. 🌟

  • 🚀 Code Evaluation: Evaluate code submissions on the fly!

  • 👩👨‍💻 Collaborative Coding: Team up with your friends and solve problems together in real-time with up to 10 users.

  • 🎤 Group Voice Chat: Integrated group voice chat for seamless collaboration using WebRTC.

  • 📦 Problem Packages: Easily store and manage problem packages.

  • 🧮🖼️ Math and Image Rendering: Supports rendering math equations and images (or any media) in problem statements.

  • ⚡ Caching: Lightning-fast caching for problem statements and packages using Redis.

Can be used to host contests completely locally(for the most part)

🎬 Demo

Check out the demo here. 🍿

Hosting is down at the moment cause I lost access to my EC2 instance :(

🏗️ System Architecture

Architecture

Here's a high-level architecture of our cute little system. 🥰

📝 Submission Handling

  • Every new submission triggers a new Docker container (Alpine Linux). 🐳
  • The container:
    • Compiles and runs the program.
    • Pulls the test data from the database if it’s not cached.
    • Compares the program output to the expected output.
    • Sends a verdict (AC/WA/CR/TLE/RTE).
  • Programs have a 2-second time limit; if they don't finish in time, they get a TLE (Time Limit Exceeded) verdict. ⏰

🔧 Implementation Details

  • 🎤 Group Voice Chat: Implemented using WebRTC to reduce server load. Chat with your whole group while you code!

  • 🐳 Docker API: Used to spawn containers on the fly for code evaluation.

  • 🤝 Collaborative Features: Utilized WebSockets (Socket.IO) for real-time collaboration.

  • ⛏ Web scraping: Used BeautifulSoup with a custom scraper to scrape problems from codeforces.

  • 📦 Problem Packages: Stored in MongoDB for easy management.

    • Includes:
      • Problem Statements (Interpreted)
      • Sample test data
      • Main test data (for evaluating submissions)
      • Expected outputs for the main tests
  • ⚡ Redis Caching: Cached problem packages and test data to limit database hits.

  • 🧮 Math Rendering: Used KaTeX for rendering math equations.

  • 🚫 Rate Limiting: Added to each compilation API call to prevent abuse.

🌐 Supported Languages

  • Only supports C++ for now. 🖋️

🚀 Usage

To use this project, follow these steps:

  1. Clone the repository:
    git clone https://github.com/nubskr/codespace.git
    cd codespace
  2. Install dependencies:
    npm install
  3. Start the server:
    npm start
  4. Open the application in your browser.

Prerequisites

  • You need Docker and Redis installed in the backend to use the submission functionality.
  • The ./Docker directory contains the Docker image I made to evaluate the submissions.

About

Full fledged implementation of an online judge with codeforces problem parsing capabilities

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published