Code Sphere is an open-source online judge and contest platform built using various technologies, focusing on performance and security.
- Utilizes clean architecture with separated layers to ensure a clear separation of concerns.
- Implements the Mediator Pattern, CQRS Pattern, Fluent Validation, and provides a unified response for all endpoints.
This diagram represents the high-level structure of the system, showing interactions between components like frontend, backend services, judge engine, Docker, Redis, and Elasticsearch.
- Design and Architecture
- Technologies & Design
- Features
- Performance and Security
- Run Locally
- Errors and Solutions
- Utilizes clean architecture with separated layers to ensure a clear separation of concerns.
- Implements the Mediator Pattern, CQRS Pattern, Fluent Validation, and provides a unified response for all endpoints.
- Docker & Docker Compose
- Redis
- Elasticsearch
- SignalR
- .NET 8
- JWT Token
- WebRTC
- Supports multiple programming languages such as Python, JavaScript, C++, C#, and Go.
- Offers peer programming through real-time meetings with a shared editor, allowing all participants to collaborate on the same code and submit solutions.
- Provides real-time code execution with results indicating statuses like TL, WA, RTE, TLE, and CE.
- Hosts timed contests for competition among users, complete with a live leaderboard.
- Includes plagiarism detection to identify cheating during contests.
- Tracks submitted code by maintaining a leaderboard and a history of submissions.
- Supports Markdown for problem descriptions.
- Communicates with users via an email service for notifications and email confirmations.
- Uses Docker to run code in a
sandboxcontainer, executing it against all problem test cases in an isolated environment with limited resources such as memory and time, returning the results. - Implements
rate limiting, as executing code requires creating a sandbox container and running all test cases, making it a costly process; thus, it is limited to 3 requests per minute. - To handle the expected surge in requests during contests, problems are cached, and
Sorted Sets (ZSETs)which is a Redis data structure used to store leaderboards, which suits our needs for contest standings. - Since the primary search object is the problems, a robust searching strategy is essential; therefore,
Elasticsearchis employed to enable high-performance and fuzzy searching with easy and fast filtering.
- .NET 8
- Docker & Docker Compose
- Visual Studio
- SQL Server
- Clone the repository.
- Navigate to the directory containing the docker-compose file and execute the command:
This will pull the necessary Docker images specified in the compose file (if they don't already exist) and start the services, including Redis, Elasticsearch, and Kibana, on your local machine.
docker compose up
- Verify the database connection string for the SQL Server database.
- pull compilers images for the language you need to try
- for example :
docker pull gcc:latestfor c++python:3.8-slimfor python
- Open the
Package Manager Consoleand run:update-database
- You are now ready to run the project.
Ensure that the run_code.sh file uses LF line endings instead of CRLF for compatibility with Docker's default operating system (Linux).
- Right-click on This PC and select Properties.
- Navigate to Advanced system settings.
- Click on Environment Variables.
- Add a new variable:
- Variable Name:
DOCKER_HOST - Variable Value:
tcp://127.0.0.1:2375
- Variable Name:
- Open Docker Desktop.
- In the bottom-right corner, right-click on the Docker Desktop icon.
- Select Settings.
- Enable the option: Expose daemon on tcp://localhost:2375 without TLS.
