System Design: Online Coding Practice and Judging Platform
Context
You are designing an online coding practice and judging platform similar to LeetCode/HackerRank/Codeforces. The platform must scale, be secure, and provide a great developer experience for both users and administrators.
Requirements
Design the end-to-end system with the following capabilities:
-
Core features
-
User accounts, authentication, and roles (user, problem setter, admin).
-
Problem browsing, filtering by tags/difficulty, and full‑text search.
-
Multi-language submissions (e.g., C++, Java, Python, Go, JavaScript).
-
Compilation and execution in sandboxed environments with resource limits.
-
Distributed judge workers consuming jobs from a task queue.
-
Result aggregation and storage of submission history, per‑test outcomes, and logs.
-
Data and lifecycle
-
Test-data versioning: immutable test sets per version, problem versions, and mapping to submissions.
-
Re‑judging: trigger re‑evaluation of submissions when test data or judging logic changes.
-
Platform safeguards
-
Anti‑cheat and plagiarism detection.
-
Rate limiting and fair‑use controls.
-
Caching strategy for hot metadata, results, and artifacts.
-
Observability: metrics, logs, tracing, and alerting.
-
Security isolation: strong sandboxing, secrets management, and least privilege.
-
Deliverables
-
High-level architecture and component responsibilities.
-
APIs (major endpoints and request/response shapes, including streaming status if applicable).
-
Data models (key entities and relationships) and storage choices.
-
Execution pipeline for compilation and testing (including per‑language considerations).
-
Scaling strategy (stateless vs stateful, sharding/partitioning, autoscaling).
-
Failure handling and consistency model (queue semantics, retries, idempotency).
Assumptions: Make any reasonable scale assumptions (e.g., DAU, QPS, submissions/day) and state them explicitly. Call out trade-offs and alternatives when relevant.