How duongnotnhan/themis-onlan-judge works
Main Components
• Web Server & PHP Execution Environment: The project is deployed on UniServerZ (Apache on Windows), which runs the PHP-based web application.
• Frontend/UI: Comprising various PHP pages (e.g., index.php, admin_dashboard.php, auth.php) along with assets (CSS, JS, fonts). This includes screens for user login, problem submission, viewing results, and the administrative dashboard.
• Backend/Business Logic: A set of PHP scripts that implement functionalities such as user authentication, problem management, submissions handling, ranking, and configuration.
• Database: MariaDB is used to store user accounts, problems, submission records, contest settings, etc. Files like config.php and .env contain configuration details for connecting to this database.
• Judge Worker/Queue Processor: A separate PHP script (judge_worker.php) is responsible for processing queued submissions. This worker likely interacts directly with submission data in the database and possibly with the file system (as indicated by “bài nộp” directory configurations mentioned in the README).
File Structure for Architectural Insights
• The PHP files at the root (e.g., index.php, auth.php, create_problem.php) indicate that the application is not split into a classic modern MVC structure but is organized around functional pages.
• The assets folder clearly separates static files (CSS and JS) for the presentation layer.
• Configuration files (.env, config.php) and the SQL database setup script (online-judge-setup-database.sql) hint at a simple but structured deployment and initialization process.
• Files for actions (like edit_problem.php, delete_submission.php, rejudge_submission.php) illustrate that the app performs CRUD-like operations across multiple contest features.
Interactions and Data Flow
• Clients (users and administrators) access the system via a web browser. Their requests (HTTP calls) are handled by the PHP pages served by Apache.
• The PHP pages interact with the MariaDB database to retrieve and update data. For instance, user authentication, contest configurations, and submission data are stored in the database.
• When a contestant submits a solution (via submit.php), the system places the submission into a queue (or marks it in the database) for processing.
• The judge worker (judge_worker.php) runs as a separate process, accessing submissions from the database, executing the judging logic, updating submission status, and recording the detailed results back into the database.
• The administrative functions (on the admin dashboard and related pages) allow for managing contest settings, rejudging submissions, and modifying problems.
Architectural Patterns & Design Principles
• Separation of Concerns: Although the PHP scripts are largely function-based, the project distinguishes between frontend (UI assets, presentation PHP pages) and backend (processing files, judge worker, configuration, database scripts).
• Client-Server Architecture: Clear separation between user-interface (client side) and server-side logic.
• Asynchronous Processing: By incorporating a judge worker that processes judging tasks separately from the immediate HTTP request cycle, the system effectively uses an asynchronous/queue-based approach for handling resource-intensive operations.