![Logo](https://private-user-images.githubusercontent.com/109282492/338852789-90d1dbfb-5542-485d-a1f5-2e347248c07d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM1NTY2ODMsIm5iZiI6MTcyMzU1NjM4MywicGF0aCI6Ii8xMDkyODI0OTIvMzM4ODUyNzg5LTkwZDFkYmZiLTU1NDItNDg1ZC1hMWY1LTJlMzQ3MjQ4YzA3ZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODEzJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgxM1QxMzM5NDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02N2FmOWFhYmJlOWUxMmQzYTNiODhiZjFlZjYxMGQ5MDBlZDExYzY4MGIyNTQ3ZWJmNDJmM2UzN2I3YTFiZjYwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.2QXrg6BziUruqYIocoXNFN2ke5axKsNd82rtPIB_XW0)
Algocode is a DSA practice platform just like Leetcode!
Read the blog ยป
Algocode Auth Service .
Code Manager Service .
RCE Engine Service
Algocode is an online data structure and algorithm practice backend built in microservices architecture.
Algocode currently has three services: Algocode Auth Service . Code Manager Service . and RCE Engine Service
Code Manager Service
is responsible to interact with client side to handle code submission requests
and manage code execution
in the RCE Engine Service.
To learn more about Algocode and the architecture, please READ-THE-BLOG-URL
or visit Algocode here.
A. Rate Limit Alert
The API endpoint to submit solution to the Algocode platfrom (Implemented using Token Bucket Algorithm Rate Limit Middleware ) is rate limited to
1 request per 20 seconds
.POST https://codemanager.algocode.site/api/v1/code/submit/
B. Documentation
Please visit the documentation page for the detailed guide on Algocode Code Manager Service.
However, all the APIs are referenced in the API Reference section below.
C. Deployment
The service is deployed in AWS EC2 Ubuntu 22.04 server.
D. About Algocode
This is Code Manager Service specific guideline.
Please visit Algocode to learn the mircroservices architecture of Algocode and more in-depth guideline how to submit a solution to Algocode platform.
The Algocode Code Manager Services uses the following services to serve the request during Production Stage.
a. Nginx as webserver.
b. Nginx Proxy Manager to manage Nginx.
c. Portainer to manage and monitor docker container in Code Manager Service.
d. Gunicorn as application server.
e. RabbitMQ for asynchronous message processig.
f. Django as backend.
g. Django Rest Framework for API.
h. PostgreSQL for Algocode questions/problems database.
i. Redis for cache.
j. MongoDB to store code execution result.
k. Docker to containerize the service.
The Code Manager Service is deployed in AWS EC2 Ubuntu 22.04 Server.
Code Manager Service acts as middleman between the clients and the RCE Engine Service to handle code submission
and code execution
.
The client can not directly interact with the RCE Engine Service as it is a secure and isolated environment to actually execute the user submitted code
in the Algocode platform. Code Manager acts as the connecting dots between the client and the RCE Engine service from solution submission
to result persistence
process.
The user submits the solution of the problem they want to submit through the code submission API
. The API processes the data and publishes the data in aRabbitMQ instance
. The RCE Engine Service consumes the message and executes the user submitted code
and generates a result
comparing the testcases
and the output of the user submitted code
.
Once a result is generated, the RCE Engine publishes the code execution result
to a unified result queue
, Code Manager Services listens to the unified result queue
.
Code Manger processes the message from the unified result queue
, caches it in Redis
and stores the result in MongoDB
database for persistence.
- Watch from
16:30
for code execution begin and18:30
for code submission result.
- Watch from
09:30
for code execution begin and11:30
for code submission result.
To learn about the Problems in Algocode without calling API, Please visit Algocode Problem Lists to get all the available problems.
I have used notion page to host the available problems in Algocode as I am focusing on advanced backend engineering, and as there is no client app for Algocode at the time I am writing this Readme.
If you want to contribute to build a client app for the Algocode, pelase do not hesitate to email here:
To learn more on Algocode and the microservices architecture of Algocode; and more detailed guide on how to submit a solution, please visit algocode here.
POST https://codemanager.algocode.site/api/v1/code/submit/
Parameter | Type | Value/Description |
---|---|---|
problem_id |
string |
Required. The problem_id of the problem you are submitting the solution. |
lang |
string |
Required. cpp . Currently cpp is supported. java RCE Engine is under development. |
code |
string |
Required. Your solution for the problem in JSON format. |
The queue
is based on the programming language
of the solution.
Here's an example payload for one of a problem in Algocode Sqrt(X)
. The problem is same as this Leetcode Problem.
Example Payload
{
"problem_id": "f17f511a-8c53-41d3-b750-7673d25835af",
"lang": "cpp",
"code": "#include <iostream>\n\nint mySqrt(int x) {\n if (x == 0) return 0;\n int left = 1, right = x, result = 0;\n while (left <= right) {\n
int mid = left + (right - left) / 2;\n if (mid <= x / mid) {\n result = mid;\n left = mid + 1;\n } else {\n right = mid - 1;\n }\n
}\n return result;\n}\n\nint main() {\n int t;\n std::cin >> t;\n while (t--) {\n int x;\n std::cin >> x;\n std::cout << mySqrt(x) <<
std::endl;\n }\n return 0;\n}\n"
}
The second API of the Code Manager service is to check the result of an code submission
to the Algocode platform.
The API is a Short Polling API
. It checks the data in cache
, then in MongoDB Database
and if the data could not be found, it waits for 5 seconds
for the availability of the data.
GET https://codemanager.algocode.site/api/v1/result/check/<submission_id>/
Parameter | Type | Description |
---|---|---|
submission_id |
string |
Required. The submission_id of your solution as per the API Guideline - Code Submission in Algocode section. |
The API response is paginated with 10 results.
POST https://codemanager.algocode.site/api/v1/problem/all/
Any specific problem using problem id
.
POST https://codemanager.algocode.site/api/v1/problem/<uudi:id>/
Parameter | Type | Description |
---|---|---|
id |
string |
Required. The id of the problem/question. |
GET https://codemanager.algocode.site/api/v1/common/healthcheck/
Please visit the documentation page for more details.
Please fork
and clone
this development branch of Algocode Code Manager Service, and follow along with the envs-examples
.
cd
to src
and create a virtual environment
. Activate the virtual environment.
Run make docker-up
and the development setup will start running. Please install make
in your host machine.
If you use Windows
Operating System, please run the respective docker commands
from the dev.yml
docker compose file.
You are always welcome to contribute to the project. Please open an issue
or raise a PR
on the project.