How vinkentli/online-judge works
Main Components
• Server Component:
• server.js – This is the main entry point for the Node.js server that initializes the service.
• judge.js – Likely responsible for handling the judging process (invoking isolate and comparing output against expected testcases).
• Problems Management:
• The “problems” directory contains several helper scripts (getProblems.js, getServer.js, submit.js) and individual directories for each problem.
• Inside each problem folder (e.g., “problems/test”), you have frontend files (index.html, script.js, style.css) which provide a user interface for each problem.
• Each problem folder has a “testcases” subdirectory containing input/output pairs formatted consistently.
• There is also a “submissions” folder within problems/test where user submissions are stored.
• External Dependencies:
• “isolate” tool – Mentioned in the README, used for sandboxed execution. This is a crucial external service that must be depicted in the architecture.
Relationships and Data Flow
• Client/Browser:
• Users access a problem’s frontend pages (HTML/CSS/JavaScript) which display problem statements.
• Node.js Server:
• The server (server.js) receives HTTP requests. It is responsible for routing these requests to various components such as problem retrieval and submission processing.
• The server utilizes getProblems.js to organize available problems and getServer.js to configure or determine which problem server is running.
• Judge Module:
• When a submission is made, the process (likely triggered through submit.js on the frontend and handled by the server) calls judge.js, which then uses the external “isolate” tool to run the submission safely.
• The results are compared against expected outputs found in the “testcases” subdirectories.
• Data Flow:
Architectural Patterns and Technologies
• Layered Architecture:
• The separation between frontend assets (HTML/CSS/JS in each problem directory) and backend logic (server.js, judge.js) should be clearly depicted.
• Component-based Separation:
• Isolate the “Problems Module” (all scripts within the “problems” folder) which encapsulates problem content, testcases, and submission processes.
• Integration with External Services:
• Dependency on the external “isolate” tool; highlight that it runs via a system service (isolate.service mentioned in the README) on Linux.
• Environment Constraints: