How vnoi-admin/oj works
Main Components
• Web Frontend & Presentation Layer:
– This includes all the Django templates (in the “templates” directory) and static assets (e.g., resources, django_ace/static).
– It serves the user interfaces for problem submission, contests, blog posts, account management, and the administration dashboard.
• Django Backend Application:
– Core Django projects are found in “dmoj” (settings, URL routing, WSGI, celery, etc.) and “judge” (which contains models, views, administration, middleware, and a number of management commands).
– This layer handles requests, interacts with the database, and dispatches tasks.
• Judging Engine / Evaluation Subsystem:
– The “judge” directory also contains submodules including “balancer”, “bridge”, and “contest_format” that coordinate the actual code evaluation and submission grading processes.
– Files like “runbalancer” and “runbridged”, in addition to celery integration (e.g., “dmoj/celery.py”), indicate asynchronous processing of judging tasks.
• Task Queue and Background Workers:
– Celery is configured for background processing, as seen via “celery.py” files and the “judge/tasks” scripts.
– This component handles asynchronous jobs (e.g., problem evaluation, sending notifications, updating caches) and may interact with message brokers.
• Caching & Data Storage:
– The configuration (described in the README) suggests the use of caching systems like Redis or Memcached for performance and synchronization between the judge server and the web backend.
• External Integrations & Services:
– Modules like “throttle_discord_webhook.py” and “throttle_mail.py” indicate integrations for notifications, while the instructions around “testlib.h” show external dependencies for compiling submissions.
• Real-Time Communication:
– The “websocket” directory (with its daemon.js and queue.js) implies a mechanism for real-time data (for status updates, judging progress, or live notifications).
Relationships & Interactions
• The user sends a request via the browser (rendered using Django templates and static resources).
– The Web Frontend communicates with the Django Backend (HTTP layer – forms, APIs, etc.).
• The Backend processes submissions and contest interactions, updates the database, and enqueues judging tasks to the Task Queue.
• The Task Queue processes jobs:
– Asynchronous workers pick up tasks (such as judging a submission) via Celery.
– The Judging Engine picks up these tasks (through components in “judge/balancer” and “judge/bridge”) and performs compilation, execution and evaluation.
• Once evaluated, results flow back via the queue to update the Django application, which in turn updates the user interfaces (scoreboards, submission status, notifications, etc.).
• Additionally, external services (Discord, email servers) are triggered to send notifications.
Architectural Patterns and Design Principles
• Modular Design: The system is split into multiple apps (e.g., “dmoj”, “judge”, “django_ace”), making it easier to maintain and scale individual components.
• Asynchronous Processing: Heavy tasks such as judging code submissions are handled in the background using Celery and dedicated judging daemons.
• MVC Pattern: Django’s structure facilitates a clear separation of concerns between models (in “judge/models”), views (in “judge/views”), and templates (in “templates”).
• Extension and Plugin Mechanism: The “contest_format” and “bridge” modules support multiple formats and judging strategies that can be extended for different contest rules or languages.
Technology, Frameworks & Libraries to Highlight
• Django (Core framework, URL routing, ORM, templating, and middleware).
• Celery for asynchronous task processing.
• Redis/Memcached for caching (as recommended in the README).
• Websocket components for real-time communications.
• Various front-end tools/libraries (e.g., Prettier, flake8, and static assets like SCSS/JS files in resources).
• Integration with external libraries (like testlib for compiling submissions).