Compare commits
5 Commits
16620111cf
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 0e35d086b0 | |||
| 917de3e401 | |||
| 2e089e192d | |||
| 38cf325e22 | |||
| fff316d5ec |
43
Readme.md
43
Readme.md
@@ -1,5 +1,6 @@
|
|||||||
# Monaco Code Execution Engine
|
# Monaco Code Execution Engine
|
||||||
|
|
||||||
|
Test 1
|
||||||
Monaco is a secure, containerized code execution engine that allows you to run code in multiple programming languages through a simple REST API and WebSocket connections for real-time terminal interaction.
|
Monaco is a secure, containerized code execution engine that allows you to run code in multiple programming languages through a simple REST API and WebSocket connections for real-time terminal interaction.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
@@ -57,6 +58,7 @@ Monaco consists of several components:
|
|||||||
```bash
|
```bash
|
||||||
git clone https://github.com/arnab-afk/monaco.git
|
git clone https://github.com/arnab-afk/monaco.git
|
||||||
cd monaco/backend
|
cd monaco/backend
|
||||||
|
```
|
||||||
|
|
||||||
2.Install Go dependencies:
|
2.Install Go dependencies:
|
||||||
|
|
||||||
@@ -65,11 +67,13 @@ Monaco consists of several components:
|
|||||||
```
|
```
|
||||||
|
|
||||||
3.Build the application:
|
3.Build the application:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go build -o monaco
|
go build -o monaco
|
||||||
```
|
```
|
||||||
|
|
||||||
4.Run the service
|
4.Run the service
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./monaco
|
./monaco
|
||||||
```
|
```
|
||||||
@@ -77,22 +81,27 @@ go build -o monaco
|
|||||||
The backend service will start on port 8080 by default.
|
The backend service will start on port 8080 by default.
|
||||||
|
|
||||||
### Frontend Setup
|
### Frontend Setup
|
||||||
|
|
||||||
1. Navigate to the Frontend directory:
|
1. Navigate to the Frontend directory:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd Frontend
|
cd Frontend
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Install dependencies:
|
2. Install dependencies:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install
|
npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Set up environment variables: Create a ```.env``` or ```.env.local.``` file with:
|
3. Set up environment variables: Create a `.env` or `.env.local.` file with:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
VITE_API_URL=http://localhost:8080
|
VITE_API_URL=http://localhost:8080
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Start the development server:
|
4. Start the development server:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run dev
|
npm run dev
|
||||||
```
|
```
|
||||||
@@ -102,9 +111,11 @@ The frontend will be available at http://localhost:5173 by default.
|
|||||||
### API Reference
|
### API Reference
|
||||||
|
|
||||||
### REST Endpoints
|
### REST Endpoints
|
||||||
```POST /submit```
|
|
||||||
|
`POST /submit`
|
||||||
|
|
||||||
Submits code for execution
|
Submits code for execution
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"language": "python",
|
"language": "python",
|
||||||
@@ -114,15 +125,17 @@ Submits code for execution
|
|||||||
```
|
```
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"id": "6423259c-ee14-c5aa-1c90-d5e989f92aa1"
|
"id": "6423259c-ee14-c5aa-1c90-d5e989f92aa1"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
```GET /status?id={submissionId}```
|
`GET /status?id={submissionId}`
|
||||||
|
|
||||||
Checks the status of submission:
|
Checks the status of submission:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"id": "6423259c-ee14-c5aa-1c90-d5e989f92aa1",
|
"id": "6423259c-ee14-c5aa-1c90-d5e989f92aa1",
|
||||||
@@ -134,11 +147,12 @@ Checks the status of submission:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
```GET /result?id={submissionId}```
|
`GET /result?id={submissionId}`
|
||||||
|
|
||||||
Gets the execution result of a submission.
|
Gets the execution result of a submission.
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"id": "6423259c-ee14-c5aa-1c90-d5e989f92aa1",
|
"id": "6423259c-ee14-c5aa-1c90-d5e989f92aa1",
|
||||||
@@ -155,10 +169,11 @@ Response:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
```GET /queue-stats```
|
`GET /queue-stats`
|
||||||
Gets the statistics about the job queue.
|
Gets the statistics about the job queue.
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"queue_stats": {
|
"queue_stats": {
|
||||||
@@ -171,7 +186,8 @@ Response:
|
|||||||
```
|
```
|
||||||
|
|
||||||
### WebSocket Endpoints
|
### WebSocket Endpoints
|
||||||
```ws://localhost:8080/ws/terminal?id={submissionId}```
|
|
||||||
|
`ws://localhost:8080/ws/terminal?id={submissionId}`
|
||||||
|
|
||||||
Establishes a real-time connection for terminal interaction.
|
Establishes a real-time connection for terminal interaction.
|
||||||
|
|
||||||
@@ -180,6 +196,7 @@ Establishes a real-time connection for terminal interaction.
|
|||||||
- Connection automatically closes when execution completes or fails.
|
- Connection automatically closes when execution completes or fails.
|
||||||
|
|
||||||
### Terminal Input Handling
|
### Terminal Input Handling
|
||||||
|
|
||||||
The system supports interactive programs requiring user input:
|
The system supports interactive programs requiring user input:
|
||||||
|
|
||||||
1. The frontend detects possible input prompts by looking for patterns
|
1. The frontend detects possible input prompts by looking for patterns
|
||||||
@@ -191,7 +208,6 @@ The system supports interactive programs requiring user input:
|
|||||||
- Buffer is cleared for next input.
|
- Buffer is cleared for next input.
|
||||||
5. The input is processed by the running program in real-time.
|
5. The input is processed by the running program in real-time.
|
||||||
|
|
||||||
|
|
||||||
Troubleshooting tips:
|
Troubleshooting tips:
|
||||||
|
|
||||||
- Ensure WebSocket connection is established before sending input
|
- Ensure WebSocket connection is established before sending input
|
||||||
@@ -200,40 +216,49 @@ Troubleshooting tips:
|
|||||||
- Ensure newline characters are properly appended to input.
|
- Ensure newline characters are properly appended to input.
|
||||||
|
|
||||||
### Language Support
|
### Language Support
|
||||||
|
|
||||||
### Python
|
### Python
|
||||||
|
|
||||||
- **Version**: Python 3.9
|
- **Version**: Python 3.9
|
||||||
- **Input Handling**: Direct stdin piping
|
- **Input Handling**: Direct stdin piping
|
||||||
- **Limitations**: No file I/O, no package imports outside standard library
|
- **Limitations**: No file I/O, no package imports outside standard library
|
||||||
- **Resource Limits**: 100MB memory, 10% CPU
|
- **Resource Limits**: 100MB memory, 10% CPU
|
||||||
|
|
||||||
### Java
|
### Java
|
||||||
|
|
||||||
- **Version**: Java 11 (Eclipse Temurin)
|
- **Version**: Java 11 (Eclipse Temurin)
|
||||||
- **Class Detection**: Extracts class name from code using regex.
|
- **Class Detection**: Extracts class name from code using regex.
|
||||||
- **Memory Settings**: 64MB min heap, 256MB max heap
|
- **Memory Settings**: 64MB min heap, 256MB max heap
|
||||||
- **Resource Limits**: 400MB memory, 50% CPU
|
- **Resource Limits**: 400MB memory, 50% CPU
|
||||||
C
|
C
|
||||||
- **Version**: Latest GCC
|
- **Version**: Latest GCC
|
||||||
- **Compilation Flags**: Default GCC settings
|
- **Compilation Flags**: Default GCC settings
|
||||||
- **Resource Limits**: 100MB memory, 10% CPU
|
- **Resource Limits**: 100MB memory, 10% CPU
|
||||||
|
|
||||||
### C++
|
### C++
|
||||||
|
|
||||||
- **Version**: Latest G++
|
- **Version**: Latest G++
|
||||||
- **Standard**: C++17
|
- **Standard**: C++17
|
||||||
- **Resource Limits**: 100MB memory, 10% CPU
|
- **Resource Limits**: 100MB memory, 10% CPU
|
||||||
|
|
||||||
### Security Considerations
|
### Security Considerations
|
||||||
|
|
||||||
All code execution happens within isolated Docker containers with:
|
All code execution happens within isolated Docker containers with:
|
||||||
|
|
||||||
- No network access (```--network=none```)
|
- No network access (`--network=none`)
|
||||||
- Limited CPU and memory resources
|
- Limited CPU and memory resources
|
||||||
- Limited file system access
|
- Limited file system access
|
||||||
- No persistent storage
|
- No persistent storage
|
||||||
- Execution time limits (10-15 seconds)
|
- Execution time limits (10-15 seconds)
|
||||||
|
|
||||||
### Debugging
|
### Debugging
|
||||||
|
|
||||||
Check backend logs for execution details
|
Check backend logs for execution details
|
||||||
Use browser developer tools to debug WebSocket connections
|
Use browser developer tools to debug WebSocket connections
|
||||||
Terminal panel shows WebSocket connection status and errors
|
Terminal panel shows WebSocket connection status and errors
|
||||||
Check Docker logs for container-related issues.
|
Check Docker logs for container-related issues.
|
||||||
|
|
||||||
### Contributing
|
### Contributing
|
||||||
|
|
||||||
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
||||||
Contributions are welcome! Please feel free to submit a Pull Request :).
|
Contributions are welcome! Please feel free to submit a Pull Request :).
|
||||||
|
|||||||
Reference in New Issue
Block a user