Skip to main content

Evaluator Architecture

SimuCode uses a robust, fault-isolated architecture to execute and validate robotics code.

Execution Flow

  1. API Request: The frontend sends the user's code to the backend container via /api/problems/submit.
  2. Job Queue: The backend pushes a new job into a BullMQ queue (backed by Redis).
  3. Worker: The worker container picks up the job. It handles code orchestration, including:
    • Creating a temporary workspace.
    • Scaffolding ROS2 packages (if necessary).
    • Writing solution.py / solution.cpp.
  4. Docker-in-Docker (DinD): The worker spawns a short-lived child container (simucode-ros2:humble) to run the code.
    • Isolation: The child container has 1GB RAM limit and no network access.
    • Resource Control: CPU and memory limits are strictly enforced.
  5. Validation: A test_runner.py (supplied by the problem definition) runs inside the child container to check the robot's behavior.
  6. Cleanup: The child container is destroyed, and the results are reported back to the user.

Key Components

  • Redis: Acts as the message broker for the job queue.
  • Worker (worker.js): The heart of the execution engine. It manages the lifecycle of the simulation jobs.
  • Docker Socket: The worker shares the host's /var/run/docker.sock to manage containers.