This project is a Judge0 API Clone, which aims to replicate the functionality of the Judge0 API. It provides a powerful API endpoint that allows users to submit their code and receive the corresponding output. Additionally, the API ensure secure access.
- Code Submission: Users can submit their code snippets through the API for execution and evaluation.
- Language Support: The API supports multiple programming languages, allowing users to write code in their preferred language.
- Output Retrieval: The submitted code is executed, and the output is returned to the user.
- Authentication: A secure authentication mechanism is implemented to protect the API from unauthorized access.
- Scalability: The API is designed to handle a high volume of concurrent requests efficiently.
- Error Handling: Comprehensive error handling is implemented to provide meaningful feedback to users in case of issues.
Make sure you have the following software installed:
- Docker - Used for containerization of the application.
- Node.js - JavaScript runtime environment.
- MongoDB - Database
-
Clone the repository to your local machine:
git clone git@github.com:Paras0750/Judge0-Clone.git
-
Navigate to the project directory:
cd Judge0-Clone
-
Install the required dependencies:
npm install
-
Pull docker images:
docker pull node docker pull gcc docker pull rabbitmq
-
Start rabbitmq container on port 5672:
docker run --name rabitMQ -p 5672:5672 rabbitmq
-
Fill up environment variable (.env)
PORT = 3000 MONGO_URI = 'mongodb://localhost:27017/judge0-api' JWT_SECRET_KEY = 'secretKey'
POST /auth/register
: Register a new user account.POST /auth/login
: Login with user credentials.POST /code/submissions
: Create a new code submission.
To access the Judge0 API Clone, you need to authenticate yourself using the following steps:
-
Register a new user account by sending a POST request to the
/auth/register
endpoint with the required user details. -
Obtain an authentication token by sending a POST request to the
/auth/login
endpoint with your registered user credentials. -
Include the obtained authentication token in the
x-auth-token
header of your subsequent API requests.
-
Install loadtest using npm
npm i --save-dev loadtest
-
Test the server
-
Authenticate user and get the
x-auth-token
-
Make sure to replace
<token>
with the actual authentication token when you use the command.
loadtest -n 1000 -c 100 -H x-auth-token:<token> --data '{"userSubmittedCode": "let sum = 0; for(let i=0;i<10;i++){sum+=1} console.log(sum);", "codeLanguage": "js"}' -T 'application/x-www-form-urlencoded' -m POST http://localhost:3000/code/submissions
-
If you have any questions or suggestions regarding this project, please feel free to reach out to the project maintainer at nauriyalparas0@gmail.com.
Thank you for your interest in this Judge0 API Clone project!