How lumonike/levis-judex works
Based on our analysis of the file tree and README, this project – Levis Judex – is a full-stack online judging platform (similar to CodeForces or Leetcode) that manages programming contests and problems (currently supporting Python). It comprises both client-facing pages (for browsing problems, contests, logging in/registering) and a back-end server (written in Node.js) that handles submissions, judging (using the isolate sandbox), user verification (with email), and uses MongoDB as its database.
Main Components
• Frontend Client:
• Pages such as index.html (home), problems/index.html, contests/index.html, login, register, and problem_creator.
• It includes supporting scripts like getProblems.js and getContests.js which (as per the additional instruction) are responsible for fetching data – i.e., those pages do not directly make requests but rely on these scripts.
• Static assets (HTML, CSS, JS) make up the interface.
• Backend Server:
• The Node.js server (server.js) which orchestrates the application logic.
• judge.js likely handles the execution/judging of submissions.
• It serves API endpoints that client scripts (like getProblems.js and getContests.js) consume.
• Responsible for interfacing with the sandboxing tool (‘isolate’) to safely execute submitted code.
• Database:
• MongoDB, as highlighted in the README and .env configuration, which stores user data, problem metadata, submission records, and contest details.
• External Services & Components:
• Isolate sandboxing tool (for securely running submitted Python code).
• Email service for account verification and notifications.
• Possibly additional services for hosting or even an optional online-judge service as described.
Relationships and Data Flow
• End Users interact with the Frontend UI (browsers load pages like problems/index.html, contests/index.html, login, register).
• The frontend pages utilize getProblems.js and getContests.js to make API requests to the Node.js server.
• The backend server (server.js) processes incoming requests by:
• Serving static pages.
• Handling submission requests via judge.js.
• Communicating with the MongoDB instance for user data, problem details, and submission statuses.
• Interfacing with the isolate service to run judge code in a secure sandbox environment.
• Sending out account verification emails using the provided email configuration.
Architectural Patterns and Design Principles
• Separation of Concerns: note the clear split between frontend and backend; the frontend is responsible for user interactions while the backend handles business logic and data management.
• Modular Design: problems, contests, login, and other functionalities are encapsulated in dedicated directories.
• Use of Middleware and Service Abstractions: the backend interacts with external tools (isolate, MongoDB) using service abstractions, ensuring that security and reliability are maintained.
• Clear API separation illustrated by how getProblems.js and getContests.js fetch data instead of embedding request logic directly in the HTML.
Including Relevant Technologies
• Node.js is the runtime for the server.
• MongoDB is the database system.
• Isolate is used for sandboxing Python code execution.
• The project relies on standard web technologies (HTML, CSS, JavaScript) for its user interface.
• The provided .env file and package.json indicate dependency management and environmental configuration practices that are part of the architecture.