Code Monkey home page Code Monkey logo

idetwo's Introduction

IdeTwo

Screenshot of a C++ source code running successfully

A (very bare-bones) clone of Ideone - the online IDE, compiler and debugging tool. It supports C, C++, Java and Python 3 out of the box, but can be extended to be used with any language.

Architecture

The program consists of an Angular front-end and a Gin backend. The backend uses MongoDB for data storage, Faktory to queue up execution requests and Docker to containerize source code compilation and execution.

Whenever the user makes an execution request, the request will be placed in the default queue of Faktory to be handled sequentially by the FaktoryWorker. The worker compiles (for C/C++/Java sources) and executes each request in Docker containers with the following specification:

  • 1 CPU core
  • 1 GB of RAM
  • 30 second of run time

If the source code fails to compile, takes too long to compile or execute, or exits with a non-zero code, the job is canceled and the error log and exit code are stored in the database.

Installation

MongoDB, Faktory and Docker Engine are required to run this program. This can be easily achieved by installing Docker alone, then run a MongoDB and a Faktory container. Configuration to connect to these two services can be found in .env.

Since the front end is a separate project inside the views folder, you will need to compile the front end first before compiling and running the back end.

# Compile the front end.
cd views
npm install
ng build -c production
cd ..

# Compile the back end.
go build main.go

# The program uses Docket Engine's Golang SDK underneath, so we need to config
# environment variables as described in
# https://pkg.go.dev/github.com/docker/docker/client#FromEnv.
export DOCKER_HOST=tcp://localhost:2375

# Run in release mode. Skip this line if running in debug mode.
export GIN_MODE=release

# Start the server to listen to port 8080.
./main

Configuration

These field can be edited inside the file .env:

Field Description
IDETWO_EXECUTIONS_DIR The root temporary directory for executions. Usually there is no reason to configure this.
MONGODB_URI The URI to connect to the MongoDB instance.
MONGODB_DB The database name of the program.
FAKTORY_URL The address of the Faktory server.
FAKTORY_POOL_CAPACITY The number of Faktory connections to maintain.
FAKTORY_WORKER_CONCURRENCY The number of goroutine used to handle worker requests.

Support for other programming languages

FaktoryWorker uses the JobExecutor interface as an abstraction of the underlying compilation + execution logic for each programming language. By extending this interface, you can add support for any programming languages.

Detailed steps to add support for a new programming languages:

  1. Add the programming language to the ProgrammingLanguage enum inside source_code.go.
  2. Implement a new struct that implements the JobExecutor interface.
  3. Add the struct as a case inside the executeJob() function in FaktoryWorker.
  4. Add the programming language to the ProgrammingLanguage enum inside source_code.ts, plus editing related functions in the file.
  5. Profit ๐Ÿ’ฐ

Licence

MIT

idetwo's People

Contributors

tranhieudev23 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

dungbv99

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.