SimpleOJ is an interactive online platform for coding enthusiasts. It allows users to solve programming challenges and run code snippets in C, C++, Java, and Python.
You can use @ah_naf/runcode npm package to run C, C++, Python and Java code.
For a visual demonstration of SimpleOJ in action, check out our video demo.
- Authentication: Users can log in using Google authentication, powered by PassportJS.
- Problem Management: Authenticated users can add, edit, and delete programming problems, complete with custom test cases.
- Code Execution: All users can run their code on the problem page. Code submissions and verifications are available for signed-in users.
- Submission Feedback: After submitting code, users receive immediate feedback on whether their solution is accepted, incorrect, or has timed out (TLE).
- History: Users can view their past submissions for each problem and view their code.
- Status: Users can see everyones recent submissions.
SimpleOJ uses Node.js child processes to execute C, C++, Java and Python code. The execution is managed in the backend, ensuring secure and isolated runtime environments for each code snippet.
- Frontend: Developed with ReactJS for a dynamic user interface.
- Backend: Built on NodeJS with Express, offering a robust server-side framework.
- Database: MongoDB is used for data storage, providing flexibility and scalability.
- Authentication: PassportJS manages user authentication, ensuring secure logins.
- Concurrency Management: Bull Queue is utilized to handle concurrent code execution requests efficiently.
- Containerization: Docker is used for containerizing the application, ensuring a consistent environment across different machines.
- Complexity Analysis: I aim to incorporate memory complexity analysis for running code. Resources and learning are underway for this implementation.
To get SimpleOJ up and running on your local machine, follow these instructions:
- Ensure Docker is installed on your machine.
- Node.js and npm should be installed for managing dependencies.
-
Install Docker: If you haven't already, install Docker following the instructions here.
-
Clone Repository: Clone this repository to your local machine using
git clone [repository-url]
. -
Install Dependencies:
- Navigate to the
client
directory in the terminal and runnpm install
to install all client-side dependencies. - Similarly, go to the
server
directory and runnpm install
for server-side dependencies.
- Navigate to the
-
Set Up Environment Variables:
- In the
server
directory, create a.env
file. - Add the following environment variables:
Replace
GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret
your_google_client_id
andyour_google_client_secret
with your actual Google client ID and secret.
- In the
-
Start the Application:
- From the root directory of the project, run
docker compose up
in the terminal. This will set up the necessary Docker containers. - Optionally, you can run the client and server separately by navigating to their respective directories and executing
npm start
in each.
- From the root directory of the project, run
-
Accessing SimpleOJ:
- Once everything is up and running, your local instance of SimpleOJ should be accessible. The client will typically run on
http://localhost:3000
, and the server will run onhttp://localhost:5000
.
- Once everything is up and running, your local instance of SimpleOJ should be accessible. The client will typically run on
- If you encounter any issues during the setup, ensure all the environment variables are correctly set and that Docker is running properly.
- For any dependency-related issues, try removing the
node_modules
folder in the client and server directories, and runnpm install
again. gi
For any assistance or inquiries, feel free to connect with me on LinkedIn.