Building a Leetcode clone backend

Kibicho Murage
2 min readNov 29, 2024

--

How I built an online judge system for remote code execution

LeetArxiv is Leetcode for implementing Arxiv papers — not silly data structures. This article highlights our backend architecture. Please share your feedback on Twitter.

This is the table of contents.

  1. Introduction to Online Judges and Remote Code Execution.
  2. Failed attempts at building a backend.
  3. LeetArxiv’s current backend. (as of December 1st 2024 with one solo programmer)
LeetArxiv homepage

1. Introduction to Online Judges and Remote Code Execution

An Online Judge is a code compilation system that permits programmers to submit and test code online.

Remote Code Execution refers to running code on somebody else’s computer — not yours.

Some common Online Judge and Remote Code Execution systems include Leetcode, CodeChef, Judge0 and now, LeetArxiv.

LeetArxiv Remote Code Execution Frontend

2. Failed attempts at building an Online Judge backend

Here are 3 different approaches that failed.

  1. Using open-source Online Judges.
  2. Using Replit as a backend.
  3. Using WASM based compilers.

2.1. Why Open-Source Online Judges Failed

This sections showcases the shortcomings of different Online Judges we encountered.

  1. Judge0 — Difficult to extend supported languages.
  2. DMOJ Judge — AGPL license issues.
  3. QingDaoU Online Judge — Documentation is in Chinese.

2.2. Why Replit failed

We attempted to use Replit as our code execution backend. However, they changed their plans.

Before one could make unlimited REPLS. Now, one is limited to only 3 REPLS. Therefore, only 3 languages can be supported by Replit at any given time.

Screenshot showing REPLIT limitations

2.3. Using WASM based compilers

Our final approach was using WASM based compilers. This was our rational.

“Perhaps we should compile code to WASM and run it inside the programmer’s browser”

This was difficult. We found browser-based compilers for Zig, Go, Python and Java. However, we lacked the bandwidth to create compilers for languages like Haskell and Holy C. This approach did not align with our goal to support obscure languages.

3. LeetArxiv’s Current Backend

Our current backend is this Docker image. It’s an Ubuntu image with lots of different compilers. We host the image on Heroku and queue tasks with RabbitMQ.

--

--

Kibicho Murage
Kibicho Murage

Written by Kibicho Murage

AI Researcher at Fileforma. Twitter : murage_kibicho

No responses yet

Write a response