This API is a robust, scalable remote code execution engine designed for online coding platforms. It securely runs code submissions in a sandboxed environment, evaluates them against pre-defined test cases, and provides instant feedback on performance and correctness. The API leverages modern technologies like RabbitMQ for efficient task queuing, Redis for rapid result caching, and Docker for isolated execution.
The API currently supports code submissions in:
- C
- C++
- Python 3
Ensure the following services are up and running before starting the API:
- RabbitMQ - For managing the queuing of code submissions.
- Redis - For caching results to improve response times.
- MongoDB - For storing and managing test cases.
- Docker - For running code in a secure, isolated environment.
Clone the repository using the following command:
git clone https://github.com/sharvil-lade/Remote-Code-Execution-Engine.git
node Server/server.js
node Judge/config/rabbitMQ.js
The challenge lies in handling submissions at scale. While the API can handle small-scale operations (10-15 submissions simultaneously) without queuing, scaling up requires a robust solution to manage higher loads. Rate limiting could address this, but it introduces unfair delays in competitive environments. By using message queuing, submissions are handled asynchronously, ensuring fairness and reliability even under heavy load.
Security is paramount when running untrusted code. Docker provides a controlled environment that isolates each code execution. If a user attempts to run malicious code—such as a fork bomb or rm -rf command—Docker's containerization ensures the broader system remains unaffected. This isolation is crucial for maintaining the integrity and security of the hosting environment.
API Documentation: Postman
All requests must include the following header:
{"Content-type" : "application/json"}
To add a test case for a specific question, send a POST request to:
http://localhost:3000/testCase/:questionID
Where :questionID
is the unique ID of the question.
The Body for Posting Testcases should be in the following format:
{
inputSRC : "Input of the respective testcase"
outputSRC : "Expected output for the above input"
}
To delete all test cases for a specific question, send a DELETE request to:
http://localhost:3000/testCase/delete-all/:questionID
To retrieve a specific test case, send a GET request to:
http://localhost:3000/testCase/:questionID/:testcaseNumber
Where :testcaseNumber
is the index of the desired test case.
Although the Testcases are posted individually, a submitted program will be tested against all the testcases.
To submit a code solution, send a POST request to:
http://localhost:3000/submit/
The body of the Post should include:
{
questionID: "Question ID of the question for whom the submission is supposed to be"
language: "Language Code of the Submission as per given below"
timeOut: "Time Limit for Execution"
src: "Source code of Submission"
}
The language Code of the languages are given below:
- C: 'C'
- C++: 'C++'
- Python: 'python3'
When Successfully Queued, the API Sends the Following response:
{
status: "InQueue"
submissionID: "The submission ID assigned by the API to the respective submission"
}
To check the status of a submission, send a GET request to:
http://localhost:3000/result/:submissionID
Where :submissionID
is the ID assigned during submission.
The following responses indicate the outcome of a submission:
- AC: All Correct
- WA: Wrong Answer
- CE: Compilation Error
- timeOut: Time Limit Exceeded
- Online Coding Contests
- Technical Interviews
- Online Assesments and Coding Tests