# vnoi-admin/judge-server architecture

> Architecture diagram of the GitHub repository vnoi-admin/judge-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vnoi-admin/judge-server
- Repository: https://github.com/vnoi-admin/judge-server

## Overview

##### Main Components
- Judge Server Core – This is the heart of the project (look at files like dmoj/main.py, dmoj/judge.py, dmoj/control.py). It manages connections to the submission server (DMOJ site interface), submission dispatching, and overall judge behavior.
- Executor Layer – Under dmoj/executors, you have numerous language-specific executors (e.g. for C/C++, Java, Python, etc.) that compile, execute, and sandbox each submission. Also note the common logic (base_executor.py, script_executor.py, etc.) and mixins.
- Checker/Grader Module – Modules in dmoj/checkers and dmoj/graders provide support for comparing outputs, processing interactive tasks, and handling signature-graded submissions.
- Sandbox/Isolation Component – The dmoj/cptbox directory contains several C/C++ components that interface with system-level functions to strictly isolate the judging process, ensuring secure sandboxed execution.
- Configuration & CLI Tools – The existence of the “dmoj” and “dmoj-cli” executables, complemented by configuration (config.py) and command dispatchers (dmoj/commands), show that the project also supports both full server operation and local testing.
- Docker & Deployment – The .docker directories (including tier1, tier2, etc.) hint at Docker images and scripted deployment. Use these to represent the external containerized environments that provide runtime isolation and preconfigured runtime environments.

##### Relationships & Interactions
- Data Flow: Clearly indicate that submissions flow from the online judge (DMOJ site) into the Judge Server.
- The Judge Server receives a submission, selects the appropriate executor based on language (via its executors module), and triggers the sandbox isolation (via cptbox) to compile/run submissions inside a secure environment.
- Once execution is complete, the output is validated by the checker and grading modules.
- Finally, the result (pass/fail, runtime errors, etc.) is reported back to the online judging server via API or CLI interfaces.
- For local testing or administrative tasks, the dmoj-cli acts as a simplified front-end, yet still relies on many of the same internal modules.

##### Architectural Patterns & Design Principles
- Security & Isolation Layer: Emphasize the sandboxing approach using both Docker (as deployment and runtime isolation) and system-level sandbox mechanisms (via cptbox).
- Command Pattern & CLI Utilities: Separate CLI utilities (dmoj-cli) from the main server function.
- Testing and Continuous Integration: The extensive testsuite and the CI/CD configuration (GitHub workflows, FreeBSD and Linux builds) indicate that automated tests and validation are key in this system.

##### Relevant Technologies
- Python is used for the core server, CLI, and many modules.
- C/C++ components for low-level system isolation and performance (cptbox, checkers in C/C++).
- Docker is used for containerized runtime environments (with multiple “tier” Dockerfiles).
- Various scripting languages and build/test configurations (Makefiles, GitHub workflows, etc.) support CI/CD.

## Diagram (Mermaid)

```mermaid
flowchart TD
    ext["DMOJ Online Judge"]:::external
    JSCore["Judge Server Core"]:::python
    Executors["Executor Modules"]:::python
    Sandbox["Sandbox & Isolation"]:::c
    Checker["Checker/Grader"]:::python
    CLI["CLI & Configuration"]:::cli
    Docker["Docker Deployment Env"]:::docker
    Result["Result Reporting"]:::external

    ext -->|"submits"| JSCore
    JSCore -->|"dispatches"| Executors
    Executors -->|"executes in"| Sandbox
    Sandbox -->|"output validated by"| Checker
    Checker -->|"reports to"| Result

    CLI -->|"configures"| JSCore
    Docker -->|"supports"| Sandbox

    click JSCore "https://github.com/vnoi-admin/judge-server/blob/master/dmoj/main.py"
    click JSCore "https://github.com/vnoi-admin/judge-server/blob/master/dmoj/judge.py"
    click JSCore "https://github.com/vnoi-admin/judge-server/blob/master/dmoj/control.py"

    click Executors "https://github.com/vnoi-admin/judge-server/tree/master/dmoj/executors"

    click Checker "https://github.com/vnoi-admin/judge-server/tree/master/dmoj/checkers"
    click Checker "https://github.com/vnoi-admin/judge-server/tree/master/dmoj/graders"

    click Sandbox "https://github.com/vnoi-admin/judge-server/tree/master/dmoj/cptbox"

    click CLI "https://github.com/vnoi-admin/judge-server/blob/master/dmoj/config.py"
    click CLI "https://github.com/vnoi-admin/judge-server/blob/master/dmoj/cli.py"
    click CLI "https://github.com/vnoi-admin/judge-server/tree/master/dmoj/commands"

    click Docker "https://github.com/vnoi-admin/judge-server/blob/master/.docker"

    classDef python fill:#AED6F1,stroke:#2980B9,stroke-width:2px;
    classDef c fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef external fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
    classDef docker fill:#D5F5E3,stroke:#28B463,stroke-width:2px;
    classDef cli fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
```
