Source Code : https://github.com/zakariamaaraki/Problem-Solving-Platform
The idea of the platform, is to let programmers to practice algorithms and data structures problems.
So the user can read the problem, think about the solution, and write the code, then submit it.
The platform needs to run the code on some test cases then return the verdict to the user (Accepted, Wrong answer, Runtime error, Compilation error, Time limit excceded, or Memory limit excceeded).
Architecture
Remote Code Compiler
There are two main components (microservices), the first one is the remote code compiler https://github.com/zakariamaaraki/RemoteCodeCompiler, it's an online code compiler written using Java (Spring Boot) for Java, C, C++ and Python, for competitive programming and coding interviews.
Supports Rest Calls, Apache Kafka and Rabbit MQ Messages.
This service execute your code remotely using docker containers to separate the different environements of executions.
Example of an input
{
"input": "9",
"expectedOutput": "0 1 2 3 4 5 6 7 8 9",
"sourceCode": "public class Test1 {\npublic static void main(String[] args) {\nint i = 0;\nwhile (i < 10) {\nSystem.out.println(i++);\n}}}",
"language": "JAVA",
"timeLimit": 15,
"memoryLimit": 500
}
Example of an ouput
{
"output": "0 1 2 3 4 5 6 7 8 9",
"expectedOutput": "0 1 2 3 4 5 6 7 8 9",
"status": "Accepted",
"date": [2021,12,1,22,10,24,311828000]
}
Examples of Executions
{
"output": "0\n1\n2\n3\n",
"expectedOutput": "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n",
"status": "Wrong Answer",
"date": [2021,12,2 ,22,10,24,311828000]
}
{
"output": "",
"expectedOutput": "test compiler\n",
"status": "Compilation Error",
"date": [2021,12,1 ,22,10,24,311828000]
}
{
"output": "",
"expectedOutput": "test\ntest\ntest\n",
"status": "Time Limit Exceeded",
"date": [2021,12,3 ,22,10,24,311828000]
}
{
"output": "abc\n",
"expectedOutput": "abc\n",
"status": "Accepted",
"date": [2021,12,4 ,22,10,24,311828000]
}
Problem Solving Platform
The second Microservice is written using C# (.Net core), and Razor as a template engine for the UI.
This component communicates with the Remote code compiler to run the user solution on test cases. It uses MongoDB as its document database.
I chose MongoDB as a database because of it's scalability and because it's a CP system (it provides Consistency and Partition Tolerence).
For dev env
The service provides a Swagger page :
How to run it
First you'll need to build the docker image of the project https://github.com/zakariamaaraki/RemoteCodeCompiler.
cd RemoteCodeCompiler
docker build . -t compiler
Then clone the Platform source code https://github.com/zakariamaaraki/Problem-Solving-Platform/ and run the following command
docker-compose up --build
Discussion (0)