Code execution platform
AlgoForge
I built a code judge that queues submissions in BullMQ, runs each one in a disposable Docker container, and sends the verdict back to the browser.
By Krrish Kumar
Run code you did not write, in four languages, on your own hardware, without letting it escape, without blocking the API, and deliver the verdict to the user the moment it exists.
Request path
- Clientsubmit code
- SubmissionFastify · saved as pending
- BullMQSubmissionQueue on Redis
- Evaluatorfresh Docker container per run
- Socket.IOverdict pushed, no polling
Four services, two queues. The API path never executes code; everything slow or dangerous happens behind a queue, inside a container.
Why it's built this way
Queues on both sides of execution
Work and results both travel as BullMQ jobs, so either side can restart without dropping a submission, and load on the evaluator never reaches the API.
A container per submission
Every run gets a disposable container with memory and time limits. Isolation is structural, not a best-effort check inside a shared process.
Push, don't poll
A dedicated Socket Service maps users to sockets in Redis, so verdicts arrive as they land and the API is not hammered by status polling.
When something fails
If the Submission service restarts, finished verdicts wait in EvaluationQueue instead of being dropped. A runaway program hits the 2 s timeout inside its own container, never an API worker.
Outcome
End-to-end judge pipeline across four independently deployable services, with queue monitoring through Bull Board and structured logs through Winston.
Full request path, step by step
- 01The client submits code to the Submission Service (Fastify).
- 02Submission fetches the problem's stubs and test cases from the Problem Service, saves the submission as pending, and returns an ID immediately.
- 03The job goes onto SubmissionQueue (BullMQ on Redis). The Evaluator consumes it and runs the code in a fresh Docker container with a 256 MB memory cap and a 2 s timeout.
- 04The verdict is published to EvaluationQueue and the container is removed.
- 05Submission consumes the result, updates MongoDB, and notifies the Socket Service, which pushes the verdict to the user's socket.