SkillAgentSearch skills...

Algocode

Algocode, coding context and practice platform, is a Django based microservices architecture backend for online judge platforms just like Leetcode.

Install / Use

/learn @Mahboob-A/Algocode

README

<br/> <div align="center"> <a href="https://github.com/Mahboob-A/algocode"> <img src="https://github.com/Mahboob-A/algocode/assets/109282492/cd5d981f-1928-49a1-a4d8-0a5b21b92171" alt="Logo" width="700" height="400"> </a> <h3 align="center">Algocode - The Leetcode for Hackers</h3> <p align="center"> Algocode is a DSA practice platform just like Leetcode! <br/> <br/> <a href="https://imehboob.medium.com/my-experience-building-a-leetcode-like-online-judge-and-how-you-can-build-one-7e05e031455d" target="_blank" ><strong>Read the blog »</strong> </a> <br/> <br/> <a href="https://github.com/Mahboob-A/algocode-auth">Algocode Auth Service .</a> <a href="https://github.com/Mahboob-A/code-manager">Code Manager Service .</a> <a href="https://github.com/Mahboob-A/rcee/">RCE Engine Service</a> </p> </div> <h3 align="center">General Information</h3>

Algocode is an online data structure and algorithm practice backend built in microservices architecture.

Algocode currently has three services: <a href="https://github.com/Mahboob-A/algocode-auth">Algocode Auth Service .</a> <a href="https://github.com/Mahboob-A/code-manager">Code Manager Service .</a> and <a href="https://github.com/Mahboob-A/rcee/">RCE Engine Service</a> <br/> <br/>

  • <a href="https://github.com/Mahboob-A/algocode-auth">Algocode Auth Service </a> Auth Service handles user management.

  • <a href="https://github.com/Mahboob-A/code-manager">Code Manager Service </a> Code Manager Service handles code submission, code exec event creation to Message Queue, and saving and caching code executing result to Database.

  • <a href="https://github.com/Mahboob-A/rcee/">RCE Engine Service</a> RCE Engine Service contains the C++ code execution Judge. The Judge is completely isolated and it is only accessible using events. <br/> RCE Engine service for Java Judge and Python Judge are under development. <br/> <br/>

The C++ Judge of <a href="https://github.com/Mahboob-A/rcee/">RCE Engine </a> can execute C++ codes and run test cases against the code output. It can currently handle the below events:

a. AC (Accepted) 
b. WA (Wrong Answer)
c. Compilation Error 
d. Time Limit Exceed 
e. Memory Limit Exceed 
f. Segmentation Fault

NOTE

A. The C++ Judge in <a href="https://github.com/Mahboob-A/rcee/">RCE Engine </a> is a pure docker implementation and no other 3rd party API or service has been used.

Please refer to the respective services to learn more about it. You will find rich and detailed documentation in the respective service's github repository, I promise!

B. Rate Limit Alert

The API endpoint to submit solution to the Algocode platfrom (API in <a href="https://github.com/Mahboob-A/code-manager">Code Manager Service </a>) is rate limited to 1 request per 20 seconds.

    POST https://codemanager.algocode.site/api/v1/code/submit/

You can learn more on this in the API Guideline - Code Submission in Algocode section.

C. Documentation

All the services have dedicated documentation page. Please visit the respective service repository to learn more.

<details> <summary><h3 align="center">Architecture and Workflow</h3></summary>

Architecture of Algocode

image

Algocode Services

The Algocode platform is comprised of 3 services. <br/> <a href="https://github.com/Mahboob-A/algocode-auth">Algocode Auth Service</a> For user management.
<a href="https://github.com/Mahboob-A/code-manager">Code Manager Service</a> For interacting with client, data processing and event creation for RCE Engine.
<a href="https://github.com/Mahboob-A/rcee/">RCE Engine Service</a> For executing the code submitted by the user and produce result for Code Manager Service to consume. <br/>

The mentioned RCE Engine is responsible to execute C++ code. The RCE Engine for Java and Python is under development.

<br/> <br/>
Workflow of Algocode - The Workflow below is Sequential How Algocode Works (See the Diagram)

A. <a href="https://github.com/Mahboob-A/algocode-auth">Algocode Auth Service</a>

  • The access to the Algocode begins from the Auth Service.

  • Algocode Auth Service is responsible for user management.

  • The user creates an account or logs in into the Algocode platform to complete the authentication/authorization process.

  • PostgreSQL database is used for user management. The database is self-hosted and capable of backup and restore data periodically.

<br/>

B. <a href="https://github.com/Mahboob-A/code-manager">Code Manager Service</a>

  • The Code Manager service is the true manager which is responsible to interact with users to submit the code submission request and return them the answer of their solution.

  • The user sends a POST request to the

    POST https://codemanager.algocode.site/api/v1/code/submit/

API to submit their code solution.

  • Code Manager verifies the authenticity of the user, processes the submitted data, publishes the data in a RabbbitMQ instance and the queue is based on the programming language the solution is written, and returns a submission_id to the client.

  • Code Manager also listens to event produced by RCE Engine. The RCE Engine executes the solution and publishes the result to an unified result queue.

  • Once message is consumed by Code Manager from result queue, Code Manager caches the result in Redis and stores the result in MongoDB database.

  • The client can send a GET request to the result check

    GET  https://codemanager.algocode.site/api/v1/result/check/<submission_id>/

API to get the code execution result. The API is a short polling request for 5 seconds.

  • The GET request checks the cache first for the result, then checks in database and if the result is still not found, then the API process waits for 5 seconds for availability of the data.

  • If the data is available within the5 seconds wait time, it returns the result, otherwise, the below response will be returned.

| Response Key | Type | Value/Description | | :-------- | :------- | :------------------------- | | status | string | pending | | data | string | null |

<br/>

C. <a href="https://github.com/Mahboob-A/rcee/">RCE Engine Service</a>

  • The RCE Engine comprises either C++ Judge, or Java Judge, or Python Judge.

  • The RCE Engine consumes messages from respective queue. Each RCE Engine consumes data based on the programming language queue type i.e. RCE Engine for C++ Judge consumes data from C++ queue.

  • The RCE Engine processes the consumed data, prepares the data for execution and passes the data to the Judge.

  • The Judge creates a secure and unprivileged docker container to run the user submitted code.

  • The Judge stores the output of the code in a file after the code execution is completed.

  • Once the code execution by the Judge is completed, the RCE Engine compares the output with testcases.

  • After the output comparison with testcases, the RCE Engine formats the result data and publish the result data to an unified result queue in a RabbitMQ instance which is consumed by Code Manager Service.

  • In case, you want to learn more about the Judge Engine, please check <a href="https://github.com/Mahboob-A/online-judge/">Online Judge</a> - a light-weight solution to test the Judge locally.

<br/> <br/> </details> <details> <summary><h3 align="center">Watch In Action</h3></summary>

A. Long Video (Describes all the features and architecture)

  • Watch from 16:30 for code execution begin and 18:30 for code submission result.
<a href="https://www.youtube.com/watch?v=TbiRWL-11Fo&t=990s" target="_blank"> <img src="https://img.youtube.com/vi/TbiRWL-11Fo/0.jpg" alt="Watch the video"> </a>

B. Short Video (Only core features)

  • Watch from 09:30 for code execution begin and 11:30 for code submission result.
<a href="https://www.youtube.com/watch?v=EgtAEjH53BA&t=571s" target="_blank"> <img src="https://img.youtube.com/vi/EgtAEjH53BA/0.jpg" alt="Watch the video"> </a> </details> <details> <summary><h3 align="center">Deployment and Tech Stack</h3></summary>

Deployment Information

<a href="https://github.com/Mahboob-A/code-manager">Code Manager Service </a> is deployed on AWS EC2 in Ubuntu 22.04 server. <br/>

<a href="https://github.com/Mahboob-A/algocode-auth">Algocode Auth Service </a> and <a href="https://github.com/Mahboob-A/rcee/">RCE Engine Service</a> are deployed on Azure VM in Ubuntu 22.04 server.
<br/> The DNS for the platform www.algocode.site is hosted on Cloudflare.

Tech Stack

1. Proxy and Monitoring:
a. Nginx as webserver.
b. Nginx Proxy Manager to manage Nginx.
c. Portainer to manage and monitor docker container in Auth Service.

2.  Backend and Server:
b. Gunicorn as application server.
e. Celery to process tasks asynchronously.
f. Flower to monitor celery worker.
g. Resend for email service.
h. Django as backend.
i. Django Rest Framework for API.

3. Databases and Cache:
j. PostgreSQL for user management database.
k. MondoDB for code execution result backend.
l. Redis for celery backend and cache.

4. Containerization and Code Execution:
m. Docker for containerization. 
n. Sibling Docker for secure foreign code execution.
o. RabbitMQ for asynchronous processing. 
p. Rate Limit (Token Bucket Algorighm, Django Middleware) for rate limit code submission API.

5. Deployment and Testing:
q. AWS EC2 instance for deployment
r. Cloudflare for DNS hosting. 
s. Postman for API testing.
</details> <details> <summary><h3 align="center">Problem Lists

Related Skills

View on GitHub
GitHub Stars9
CategoryDevelopment
Updated1mo ago
Forks3

Security Score

90/100

Audited on Feb 23, 2026

No findings