Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Distributed Online Code Executor

A scalable, web-based Python code execution platform. You type Python code in the browser, hit Run, and a backend execution engine safely runs it inside an isolated Docker container, returning the output to your screen.

This project demonstrates how modern code playgrounds (like LeetCode or HackerRank) work under the hood, showcasing a distributed architecture that separates the web-facing API from the actual code execution workers.

How It Works

The platform is designed for security, scalability, and asynchronous processing:

  1. Frontend: A clean, responsive, single-page interface (HTML/JS/CSS). When you submit code, it sends a request to the backend and begins polling for a response.
  2. Web API & Database: The Spring Boot backend receives the code, saves a PENDING record in a PostgreSQL database, and publishes a message to an Apache Kafka topic.
  3. Execution Worker: A Kafka listener picks up the job and safely spins up an isolated Docker container (using the docker-java ZeroDep client). It executes the user's Python code, captures the stdout/stderr, and destroys the container within a strict time limit.
  4. Result Delivery: The worker updates the database record with the final output and a COMPLETED status. The polling frontend detects the change and displays the result to the user.

Screenshots

Screenshot 2026-06-08 183559 Screenshot 2026-06-08 183815

Tech Stack

  • Backend Framework: Java 17, Spring Boot 3.1
  • Message Broker: Apache Kafka
  • Database: PostgreSQL (via Spring Data JPA)
  • Execution Engine: Docker (Docker Java API Client)
  • Frontend: Vanilla HTML, CSS, JavaScript (No frameworks)

Prerequisites

To run this project locally, you must have installed:

  • Java 17
  • Maven
  • Docker Desktop (must be running in the background)

Running Locally

  1. Start the Infrastructure (Database & Kafka) The project includes a docker-compose.yml file to easily start PostgreSQL and Kafka.

    docker-compose up -d
  2. Start the Spring Boot Application Run the backend application using Maven:

    mvn spring-boot:run
  3. Open the App Once the server starts, navigate to http://localhost:8080 in your web browser.

API Endpoints

POST /api/submit Accepts a JSON body with the source code. It immediately returns a PENDING submission record containing the unique submissionId.

{
  "problemId": "playground",
  "sourceCode": "print('hello world')",
  "language": "python"
}

GET /api/submission/{id} Retrieves the current status of a submission by its ID. Used by the frontend to poll for the final COMPLETED or FAILED execution result.

About

A Spring Boot backend service that safely executes Python code in real-time using Java ProcessBuilder.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages