Skip to content

XXY-CH/CodeNexus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

543 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

CodeNexus Banner

πŸ“„ Read in Chinese / δΈ­ζ–‡θ―΄ζ˜Ž

CodeNexus

CodeNexus is a modern, multi-tenant, and multi-role online judge and competitive programming platform tailored for educational institutions. It provides a secure, sandboxed environment for compiling and executing student submissions in runtime-configurable programming languages, offering a comprehensive experience for students, teachers, and administrators.

Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Frontend      β”‚ REST  β”‚   API Server     β”‚ Redis β”‚    Judge Worker    β”‚
β”‚ React + Vite     │◄─────►│ Axum + domains   │◄─────►│ cgroups + seccomp  β”‚
β”‚ Port 5173 / 80   β”‚ WS    β”‚ Port 3000        β”‚ HTTP  β”‚ Compile & run      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚            β”‚            β”‚
                 β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚PostgreSQL β”‚ β”‚ Redis 7  β”‚ β”‚ Feature Gateway β”‚
                 β”‚16         β”‚ β”‚ Queue    β”‚ β”‚ Port 3001       β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                  β”‚
                                           β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
                                           β”‚ LLM Worker  β”‚
                                           β”‚ AI analysis β”‚
                                           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Core Data Flow: Users submit code via the frontend, the API server publishes judge tasks to Redis Streams, the Judge Worker consumes these tasks and compiles/runs them inside a secure Linux sandbox, and then posts the results back to the API server, which pushes real-time updates to the frontend via WebSocket.

Core Features

  • Runtime-Configurable Languages β€” The judge supports language runtimes through per-language settings; deployments can enable only the compilers/interpreters installed in the worker image.
  • Secure Sandboxing β€” Three layers of isolation using Linux cgroups (CPU/memory limits), chroot (filesystem isolation), and seccomp (system call filtering) to ensure security and prevent hostile executions.
  • Multi-Tenant & Multi-Role β€” Built for multi-campus operations. Features a 6-level role hierarchy (Root, CampusAdmin, GradeAdmin, Teacher, TeachingAssistant, Student) with strict RBAC boundary checks.
  • Real-Time Updates β€” Real-time push notifications, submission status, leaderboard updates, and contest chatrooms using WebSocket.
  • Contest Subsystem β€” Create contests with custom problems, real-time leaderboards (with configurable freeze periods), and live chatrooms.
  • Classroom & Homework β€” Teachers can create classes, manage student enrollment, assign homework, and review comprehensive submission reports.
  • Discussions & Blogs β€” Problem-specific discussion areas, community technical blogs, and nested comment systems.
  • Code Plagiarism Detection β€” Integrated plagiarism scanner analyzing code similarity, configurable from the admin control panel.
  • Direct Messaging β€” One-to-one conversations with message history, sending, and unread badge indicators.
  • Feature Gateway & AI Worker β€” Runtime feature flags control optional capabilities such as LLM-assisted analysis, teaching cards, recommendations, and plagiarism graph features.
  • Learning Roadmap β€” Student-facing knowledge topology that links visible skill nodes back into problem discovery.
  • Full-Text Search β€” Global search indexing across problems, discussions, blogs, and users.
  • Import/Export β€” Batch problem ZIP and user CSV import/export for seamless library migration and user provisioning.

Tech Stack

Component Technology Version
Frontend Framework React + TypeScript + Vite React 19, TypeScript 5.9, Vite 7
Styling / Icons Tailwind CSS v4 + shadcn + Lucide Icons β€”
State Management Zustand (Client) + TanStack React Query (Server) β€”
Form Validation React Hook Form + Zod β€”
Code Editors Monaco Editor (Code submission) + CodeMirror (Markdown) β€”
API Server Rust + Axum + SQLx Rust 2021 Edition, Axum 0.7, SQLx 0.8
Feature Gateway Rust + Axum + SQLx Scoped feature flags, standalone service
LLM Worker Rust worker AI task processing behind feature flags
Judge Worker Rust + Redis Streams + cgroups/seccomp Rust 2021 Edition
Database PostgreSQL 16
Cache & Message Broker Redis 7
Containerization Docker Compose β€”

Project Structure

Online_Judge/
β”œβ”€β”€ backend/                          # Rust Workspace (14 crates)
β”‚   β”œβ”€β”€ Cargo.toml                    # Workspace Root Config
β”‚   β”œβ”€β”€ rust-toolchain.toml           # Toolchain Lock (Rust 1.90.0)
β”‚   β”‚
β”‚   β”œβ”€β”€ api/                          # API Server (Axum HTTP & WebSockets Entry)
β”‚   β”œβ”€β”€ api-infra/                    # Shared Infrastructure Crate (Middleware, Auth, WS, Helpers)
β”‚   β”œβ”€β”€ shared/                       # Shared Models (Claims, Role, Permission, User)
β”‚   β”‚
β”‚   β”œβ”€β”€ domain-users/                 # User domain (Authentication, Registration, Profiles, Roles)
β”‚   β”œβ”€β”€ domain-problems/              # Problem domain (CRUD, Test cases, Visibility)
β”‚   β”œβ”€β”€ domain-submissions/           # Submission domain (Submissions, Retests, Verdicts)
β”‚   β”œβ”€β”€ domain-contests/              # Contest domain (Lifecycle, scoreboards, registration)
β”‚   β”œβ”€β”€ domain-classes/               # Classroom domain (Grades, Classes, Homework)
β”‚   β”œβ”€β”€ domain-community/             # Social domain (Discussions, Blogs, Comments)
β”‚   β”œβ”€β”€ domain-leaderboard/           # Ranking domain (Global/Contest/Class rankings)
β”‚   β”œβ”€β”€ domain-search/                # Search domain (Full-text search integration)
β”‚   β”œβ”€β”€ domain-imex/                  # Import/Export domain (Problem ZIP & User CSV)
β”‚   β”‚
β”‚   β”œβ”€β”€ judge-worker/                 # Independent Judge Worker (Redis Streams Consumer & Sandbox)
β”‚   └── migration-tool/               # Database Migration Tool (MySQL β†’ PostgreSQL)
β”‚
β”œβ”€β”€ frontend/                         # React Frontend Application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ pages/                    # Page components
β”‚   β”‚   β”œβ”€β”€ components/               # Shared UI elements
β”‚   β”‚   β”œβ”€β”€ services/                 # API Service Layer
β”‚   β”‚   └── store/                    # Zustand Stores
β”‚   └── Dockerfile                    # Nginx deployment config
β”‚
β”œβ”€β”€ docker-compose.yml                # Full-stack orchestrator
β”œβ”€β”€ scripts/                          # Bootstrap & utility scripts
└── LICENSE                           # Private License

Quick Start

For detailed step-by-step instructions, please read GETTING-STARTED.md.

Docker Compose Quick Run

docker compose up -d --build

Load demo seeds:

DATABASE_URL=postgresql://postgres:postgres@localhost:5432/online_judge \
  ./scripts/bootstrap_demo.sh

Service links:

Service URL
Frontend http://localhost:5173
API Server http://localhost:3000
Health Check http://localhost:3000/health

Documentation Index

Guide Description
GETTING-STARTED.md Local environment preparation, installation, and first run.
ARCHITECTURE.md Technical architecture, domain boundaries, and data flow details.
DEVELOPMENT.md Backend and frontend local development guidelines.
TESTING.md Unit, integration, E2E testing framework, and guidelines.
API.md Complete REST API endpoint reference.
CONFIGURATION.md Environment variables and runtime configurations.
DEPLOYMENT.md Production-grade deployment and operations guide.

License

This project is licensed under a Private License. See LICENSE for details. Unauthorized use, copying, modification, or distribution is strictly prohibited.

About

CodeNexus is an online judge platform that developed for school to connect teaching with AI. The AI connecting gateway is still in processing

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors