When you click Run or Submit in the code editor, your code travels through an asynchronous pipeline before results appear in the console. The pipeline is designed to handle execution outside the Next.js request/response cycle, keeping the UI responsive while potentially long-running test suites complete in the background.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Praashh/buildml/llms.txt
Use this file to discover all available pages before exploring further.
Run vs Submit
Run mode
Run provides fast feedback without persisting anything to the database. Results are stored in Redis under a short-lived key and discarded after retrieval.Trigger the mutation
Clicking RUN calls the
submission.run tRPC mutation with { problemId, code }. The server checks the run rate limit (5 req / 10 s) and, if allowed, generates a random runId (UUID).Publish to QStash
The server calls The mutation returns
qstash.publishJSON to enqueue a message to the /api/webhooks/process-submission endpoint. The message body is:{ runId } immediately to the client.Webhook processes the job
QStash delivers the message to the webhook handler, which calls the FastAPI executor at
EXECUTOR_URL/execute with the user’s code and the problem slug. The executor runs the problem’s test suite inside its Docker container.Result stored in Redis
The webhook writes the execution result to Redis under the key
run_result:{runId} as { status, output }.Submit mode
Submit is identical to Run in execution, but additionally creates and updates a permanentSubmission record in the database.
Trigger the mutation
Clicking SUBMIT calls the
submission.submit tRPC mutation with { problemId, code }. The server checks the submit rate limit (2 req / 30 s).Create a PENDING Submission row
A The mutation returns the full submission object (including
Submission record is inserted into the database immediately:id and status: "PENDING") to the client.Webhook executes and updates the DB
The webhook fetches the submission from the DB (to get
problemId and code), calls the executor, and then updates the Submission row with the final status and output.Submission Statuses
| Status | Meaning |
|---|---|
PENDING | The job has been queued to QStash but the executor has not yet returned a result. The console shows a pulsing animation. |
PASS | All test cases passed (passed === total && total > 0). The console header shows a green “ALL TESTS PASSED” indicator. |
FAIL | At least one test case failed. Output lists each test with a ✓ or ✗ prefix. |
ERROR | The executor returned a top-level error (e.g., a syntax error or an unhandled exception before tests ran). The full error message is displayed in red. |
Executor Interface
The FastAPI executor is called atEXECUTOR_URL/execute via HTTP POST, authenticated with an x-secret header:
Output Format
The executor response is converted to a human-readable string displayed in the console panel:- Summary line:
N/M tests passed - Per-test lines:
✓ <name>for passing tests;✗ <name>: <error>for failing tests - Stderr block (if present): appended after a
--- stderr ---divider
Polling Behavior
Thesubmission.getStatus tRPC query is enabled only when a runId or a PENDING submissionId is present. It uses refetchInterval to poll every 1000 ms and sets refetchInterval: false as soon as the returned status is no longer PENDING:
result state via a useEffect, and the console renders the final output.