5 Commits

Author SHA1 Message Date
0e35d086b0 test1 2025-12-05 00:43:36 +05:30
917de3e401 test1 2025-12-05 00:39:46 +05:30
2e089e192d Merge branch 'main' of https://git.csi-kjsce.org/Arnab-Afk/monaco 2025-12-05 00:37:51 +05:30
38cf325e22 gitea test 2025-12-05 00:36:15 +05:30
fff316d5ec test1 2025-12-05 00:34:39 +05:30

View File

@@ -1,5 +1,6 @@
# 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.
## Features
@@ -57,6 +58,7 @@ Monaco consists of several components:
```bash
git clone https://github.com/arnab-afk/monaco.git
cd monaco/backend
```
2.Install Go dependencies:
@@ -65,11 +67,13 @@ Monaco consists of several components:
```
3.Build the application:
```bash
go build -o monaco
```
4.Run the service
```bash
./monaco
```
@@ -77,22 +81,27 @@ go build -o monaco
The backend service will start on port 8080 by default.
### Frontend Setup
1. Navigate to the Frontend directory:
```bash
cd Frontend
```
2. Install dependencies:
```bash
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
VITE_API_URL=http://localhost:8080
```
4. Start the development server:
```bash
npm run dev
```
@@ -102,9 +111,11 @@ The frontend will be available at http://localhost:5173 by default.
### API Reference
### REST Endpoints
```POST /submit```
`POST /submit`
Submits code for execution
```json
{
"language": "python",
@@ -114,15 +125,17 @@ Submits code for execution
```
Response:
```json
{
"id": "6423259c-ee14-c5aa-1c90-d5e989f92aa1"
}
```
```GET /status?id={submissionId}```
`GET /status?id={submissionId}`
Checks the status of submission:
```json
{
"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.
Response:
```json
{
"id": "6423259c-ee14-c5aa-1c90-d5e989f92aa1",
@@ -155,10 +169,11 @@ Response:
}
```
```GET /queue-stats```
`GET /queue-stats`
Gets the statistics about the job queue.
Response:
```json
{
"queue_stats": {
@@ -171,7 +186,8 @@ Response:
```
### WebSocket Endpoints
```ws://localhost:8080/ws/terminal?id={submissionId}```
`ws://localhost:8080/ws/terminal?id={submissionId}`
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.
### Terminal Input Handling
The system supports interactive programs requiring user input:
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.
5. The input is processed by the running program in real-time.
Troubleshooting tips:
- Ensure WebSocket connection is established before sending input
@@ -200,12 +216,16 @@ Troubleshooting tips:
- Ensure newline characters are properly appended to input.
### Language Support
### Python
- **Version**: Python 3.9
- **Input Handling**: Direct stdin piping
- **Limitations**: No file I/O, no package imports outside standard library
- **Resource Limits**: 100MB memory, 10% CPU
### Java
- **Version**: Java 11 (Eclipse Temurin)
- **Class Detection**: Extracts class name from code using regex.
- **Memory Settings**: 64MB min heap, 256MB max heap
@@ -216,24 +236,29 @@ C
- **Resource Limits**: 100MB memory, 10% CPU
### C++
- **Version**: Latest G++
- **Standard**: C++17
- **Resource Limits**: 100MB memory, 10% CPU
### Security Considerations
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 file system access
- No persistent storage
- Execution time limits (10-15 seconds)
### Debugging
Check backend logs for execution details
Use browser developer tools to debug WebSocket connections
Terminal panel shows WebSocket connection status and errors
Check Docker logs for container-related issues.
### Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Contributions are welcome! Please feel free to submit a Pull Request :).