{"id":23263797,"url":"https://github.com/theinit01/labexamsystem-backend","last_synced_at":"2025-10-27T08:31:33.858Z","repository":{"id":268148011,"uuid":"902973094","full_name":"theinit01/LabExamSystem-Backend","owner":"theinit01","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-14T17:06:51.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-14T18:19:47.647Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theinit01.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-13T16:48:50.000Z","updated_at":"2024-12-14T17:06:54.000Z","dependencies_parsed_at":"2024-12-14T18:19:49.541Z","dependency_job_id":"16aa5dd9-881a-49e4-9c96-d5ddd756f2de","html_url":"https://github.com/theinit01/LabExamSystem-Backend","commit_stats":null,"previous_names":["theinit01/labexamsystem-backend"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theinit01%2FLabExamSystem-Backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theinit01%2FLabExamSystem-Backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theinit01%2FLabExamSystem-Backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theinit01%2FLabExamSystem-Backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theinit01","download_url":"https://codeload.github.com/theinit01/LabExamSystem-Backend/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238470181,"owners_count":19477790,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-19T14:27:36.987Z","updated_at":"2025-10-27T08:31:28.537Z","avatar_url":"https://github.com/theinit01.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **Code Runner System**\n\n## **1. Project Overview**\n\nThis project allows users to submit and execute code written in **Python** and **C** through pre-warmed Docker containers. A **proxy server** routes incoming requests to the appropriate backend container based on the specified programming language.\n\n## **2. Directory Structure**\n```project-root/\n├── python-runner/          # Service to execute Python code\n│   ├── app.py              # Flask app to execute Python code\n│   ├── Dockerfile          # Dockerfile for Python runner\n├── c-runner/               # Service to execute C code\n│   ├── app.py              # Flask app to compile and execute C code\n│   ├── Dockerfile          # Dockerfile for C runner\n├── proxy-server/           # Proxy server to route requests\n│   ├── app.py              # Flask app acting as the proxy\n│   ├── Dockerfile          # Dockerfile for Proxy server\n├── docker-compose.yml      # Compose file to spin up all services\n```\n## **3. Services**\n### **Python Runner**\n\n-   **Description**: Executes Python code sent from the frontend.\n-   **Endpoint**: `POST /execute`\n-   **Port**: `5001` (containerized)\n-   **Request Format** (JSON):\n    \n   ```json\n   { \n\t   \"code\": \"for i in range(5): print(i)\" \n}\n   ```\n   **Response**:\n\n```json\n{ \n\t\"output\": \"0\\n1\\n2\\n3\\n4\\n\", \n\t\"error\": \"\" \n}\n```\n### **Proxy Server**\n\n-   **Description**: Routes incoming requests to the appropriate runner container (Python or C) based on the **language** specified in the request.\n-   **Endpoint**: `POST /execute`\n-   **Port**: `5000` (accessible from host)\n-   **Request Format** (JSON):\n    \n  ```json\n{ \n\t\"language\": \"python\", \n\t\"code\": \"for i in range(5): print(i)\"\n}\n```\n    \n-   **Response**:\n ```json\n{ \n\t\"output\": \"0\\n1\\n2\\n3\\n4\\n\", \n\t\"error\": \"\" \n}\n```\n\n## **4. How to Run the Project**\n\n1.  **Prerequisites**\n    \n    -   Install **Docker** and **Docker Compose** on your machine.\n2.  **Build and Run the Services**\n    \n    -   Navigate to the project root directory.\n    -   Run the following command to build and start all containers:\n        `docker-compose up --build` \n        \n3.  **Access the Proxy Server**\n    \n    -   The proxy server will be accessible at:        \n        `http://localhost:8080/execute` \n        \n4.  **Example Requests**\n    \n    -   Use tools like **Postman** or `curl` to send POST requests to the proxy server.\n    \n    **Python Code Example:**\n\n    `curl -X POST http://localhost:8080/execute \\\n    -H \"Content-Type: application/json\" \\\n    -d '{\n        \"language\": \"python\",\n        \"code\": \"for i in range(5): print(i)\"\n    }'` \n    \n    **C Code Example:**\n\n    `curl -X POST http://localhost:8080/execute \\\n    -H \"Content-Type: application/json\" \\\n    -d '{\n        \"language\": \"c\",\n        \"code\": \"#include \u003cstdio.h\u003e\\nint main() {\\n   printf(\\\"Hello, World!\\\\n\\\");\\n   return 0;\\n}\"\n    }'`\n\n## **5. Notes**\n\n-   Ensure that **ports 5000, 5001, and 5002** are free on your host machine.\n-   The proxy server is the single entry point for code execution.\n\n----------\n\n## **6. Cleanup**\n\nTo stop and remove the containers, run:\n`docker-compose down` \n\n----------\n\n### **7. Future Improvements**\n\n-   Add support for additional programming languages.\n-   Implement authentication to restrict access.\n-   Use Kubernetes for container orchestration in production.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheinit01%2Flabexamsystem-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheinit01%2Flabexamsystem-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheinit01%2Flabexamsystem-backend/lists"}