#Online Code Runer
This project is a web-based code compilation and execution system designed to allow users to submit code via a client interface, which is then processed by a server and executed by an isolated worker. The results are communicated back to the client seamlessly. The project leverages Docker for containerization and Redis for message brokering.
- client/: Contains the frontend code for user interaction.
- server/: Contains the backend code for handling client requests and communicating with the worker.
- worker/: Contains the code execution environment. This service runs the submitted code and returns the output.
- Multi-language Support: Supports execution of code in various programming languages including Python, Node.js, C, and C++.
- Containerized Execution: Uses Docker to isolate the worker environment, ensuring secure and consistent execution.
- Asynchronous Processing: Utilizes Redis for queuing submissions and publishing results, allowing for scalable and efficient processing.
- Docker: Ensure Docker is installed on your system.
- Docker Compose: Used for orchestrating the multi-container setup.
- Node.js and npm: Required for building the client and server applications.
-
Clone the Repository:
git clone https://github.com/CODECZERO/OnlineCodeCompiler.git cd OnlineCodeCompiler -
Environment Variables: Provide env in dockerfile in there respect directory with the following variables:
# Redis REDIS_HOST=redis REDIS_PORT=6379 # Server Environment Variables ENV REDIS_HOST=redis ENV REDIS_PORT=6379 ENV SERVER_PORT=4060 # Client Environment Variables ENV VITE_WEBSOCKET_URLL=ws://loclahost:4060 ENV PORT=5173
ENV REDIS_HOST=redis
ENV REDIS_PORT=6379
ENV WORKER_PORT=4080
```
-
Build and Start the Containers:
docker-compose up --build
-
Access the Client: Open your browser and navigate to
http://localhost:5173to access the client interface.
- Client: Users can submit their code through a web interface.
- Server: Receives code submissions from the client, pushes them to Redis, and waits for the worker to process the code.
- Worker: Listens for new code submissions in Redis, executes the code, and publishes the results back to Redis.
To add support for a new programming language, you need to update the worker configuration to include the new language's compilation and execution commands.
Ensure that you write tests for any new features or languages added to the project. Use the existing structure and Docker setup to run your tests in an isolated environment.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make your changes and commit them (
git commit -m 'Add new feature'). - Push to the branch (
git push origin feature-branch). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
Thank you to all contributors and the open-source community for your support and contributions.