File tree 2 files changed +80
-12
lines changed
2 files changed +80
-12
lines changed Original file line number Diff line number Diff line change 1
- # Remote Code Execution Engine - CodeBlaster_3000
1
+ # 🚀 CodeBlaster_3000 - Remote Code Execution Engine
2
2
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
8
8
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
+ ---
10
79
11
- <img src =" ./images/design.png " alt =" design " >
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ const worker = new Worker('code_submission', async (job) => {
15
15
response
16
16
} )
17
17
} catch ( error ) {
18
+ console . log ( `Job with id ${ job . id } giving Error.` )
18
19
await Code_Response . create ( {
19
20
jobId : job . id ,
20
21
status : "Error" ,
@@ -30,10 +31,9 @@ const prePullDockerImages = async () => {
30
31
'node:20'
31
32
] ;
32
33
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 } ` ) ) )
37
37
38
38
console . log ( 'All images pulled successfully!' ) ;
39
39
} ;
You can’t perform that action at this time.
0 commit comments