Skip to content

Commit 2216021

Browse files
committedFeb 6, 2025
readme
1 parent be1f269 commit 2216021

File tree

2 files changed

+80
-12
lines changed

2 files changed

+80
-12
lines changed
 

‎README.md

+76-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,79 @@
1-
# Remote Code Execution Engine - CodeBlaster_3000
1+
# 🚀 CodeBlaster_3000 - Remote Code Execution Engine
22

3-
## Tech Stack
4-
- NodeJs
5-
- Docker
6-
- Redis - Message Broker
7-
- BullMQ - Message Queue
3+
## 🛠️ Tech Stack
4+
- **Node.js** - Backend API & Worker
5+
- **Docker** - Containerization
6+
- **Redis** - Message Broker
7+
- **BullMQ** - Message Queue for job processing
88

9-
## Design
9+
---
10+
11+
## 📜 Architecture
12+
13+
![Design](./images/design.png)
14+
15+
---
16+
17+
## ⚡ Installation
18+
19+
1. **Clone the Repository**
20+
```sh
21+
git clone https://github.com/vr-varad/CodeBlaster_3000.git
22+
cd CodeBlaster_3000
23+
```
24+
25+
2. **Start Services with Docker Compose**
26+
```sh
27+
docker compose up -d
28+
```
29+
30+
This starts 4 services:
31+
- `code_blaster_3000_server` - API server (Port: `3000`)
32+
- `code_blaster_3000_worker` - Worker for code execution & result storage
33+
- `code_blaster_3000_redis` - Redis as the message broker
34+
- `code_blaster_3000_mongo` - MongoDB for storing results
35+
36+
---
37+
38+
## 🚀 Usage
39+
40+
### 1️⃣ Submit Code
41+
Submit code for execution by making a `POST` request to `/submit`.
42+
43+
**Request Body:**
44+
```json
45+
{
46+
"code": "print(1)",
47+
"language": "python"
48+
}
49+
```
50+
51+
**Response:**
52+
```json
53+
{
54+
"status": "success",
55+
"jobId": "123456"
56+
}
57+
```
58+
59+
### 2️⃣ Fetch Execution Result
60+
Retrieve the execution result by making a `GET` request to `/result`.
61+
62+
**Request Body:**
63+
```json
64+
{
65+
"jobId": "123456"
66+
}
67+
```
68+
69+
**Response Example:**
70+
```json
71+
{
72+
"status": "completed",
73+
"output": "1",
74+
"jobId": "123456"
75+
}
76+
```
77+
78+
---
1079

11-
<img src="./images/design.png" alt="design">

‎worker/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const worker = new Worker('code_submission', async (job) => {
1515
response
1616
})
1717
} catch (error) {
18+
console.log(`Job with id ${job.id} giving Error.`)
1819
await Code_Response.create({
1920
jobId: job.id,
2021
status: "Error",
@@ -30,10 +31,9 @@ const prePullDockerImages = async () => {
3031
'node:20'
3132
];
3233

33-
for (const image of images) {
34-
console.log(`Pulling image: ${image}`);
35-
await execShellCommand(`docker pull ${image}`);
36-
}
34+
console.log('Pulling Docker Images')
35+
36+
await Promise.all(images.map((image) => execShellCommand(`docker pull ${image}`)))
3737

3838
console.log('All images pulled successfully!');
3939
};

0 commit comments

Comments
 (0)
Please sign in to comment.