Design a high-level system that allows users to practice coding problems, submit solutions, view problem discussions, and participate in contests. The system should handle multiple programming languages, provide real-time code execution, and scale to millions of users.
Functional Requirements (FR)
User Management
•Users can register/login using email, social login, or OAuth.
•Maintain user profiles, progress, and achievements.
Problem Management
•Store coding problems with metadata: title, description, difficulty, tags, constraints, examples.
•Categorize problems by topics and difficulty levels.
Code Submission & Execution
•Users can submit code in multiple programming languages.
•Execute code securely in isolated sandboxes.
•Validate outputs against test cases and provide feedback.
Leaderboards & Contests
•Support online coding contests with rankings.
•Maintain daily/weekly/monthly leaderboards.
Discussion & Collaboration
•Users can discuss problems, share hints, and solutions.
•Optional: Upvote and comment on solutions.
Analytics & Progress Tracking
•Track user performance and problem completion.
•Provide insights like weak areas, solved problems, and streaks.
Search & Recommendations
•Search problems by difficulty, tags, or popularity.
•Recommend problems based on user performance or history.
Non-Functional Requirements (NFR)
•Scalability: Support millions of users and thousands of problems.
•High Availability: Platform should be operational 24/7.
•Low Latency: Fast problem load times and code submission feedback.
•Security: Secure code execution, protect user data, prevent plagiarism.
•Extensibility: Support addition of new programming languages, problem types, or contest formats.
Core Components
API / Application Layer
•Handles user requests for problems, submissions, discussions, and contests.
User Service
•Manage user profiles, authentication, achievements, and progress tracking.
Problem Service
•Store and retrieve coding problems, metadata, and test cases.
Code Execution / Sandbox Service
•Execute user code in isolated environments.
•Validate output against predefined test cases.
•Handle multiple programming languages.
Submission & Evaluation Service
•Queue submissions for execution.
•Maintain submission history and status (Accepted, Wrong Answer, Time Limit Exceeded, etc.).
Leaderboard / Contest Service
•Track contest submissions and rankings in real-time.
•Support time-based scoring and streaks.
Discussion / Comment Service
•Manage problem discussions, solution sharing, and comments.
Database / Storage Layer
•Store user profiles, problem data, submissions, contest data, and discussions.
Search & Recommendation Service
•Search problems by tags, difficulty, or popularity.
•Recommend problems based on user history or skill level.
Monitoring & Logging
•Track platform usage, code execution metrics, and errors.
High-Level Data Flow
1.User selects a problem → API Layer → Problem Service → Return problem details and test cases.
2.User submits code → Submission Service → Execution Sandbox → Validate outputs → Update submission status → Update user progress.
3.Contest submission → Submission Service → Real-time scoring → Leaderboard Service → Update rankings.
4.User searches/recommendations → Search Service → Query DB → Return problem list.
5.User discussion → Discussion Service → Store & fetch comments and upvotes.
Design Considerations
•Use isolated sandboxes for secure code execution (Docker or VM-based).
•Use queues to handle high volume of submissions asynchronously.
•Cache frequently accessed problems for low-latency reads.
•Partition databases for scalability across users and problem sets.
•Implement rate limiting to prevent abuse of code execution resources.
•Support multi-language compilation and execution with proper security.
✅ This is a complete HLD Problem Statement for a LeetCode-like Online Coding Platform, covering modules, data flow, code execution, contests, and scalability considerations.