Skip to content

Repository files navigation

codebench-api

The CodeBench main API.

Requirements

  • NodeJS v16+
  • PostgreSQL (cf docker-compose.yml)

Linters

Run API

Dev with hot-reloading:

npm run dev

Prod:

npm start

Architecture

Submission jobs execution flow

ComponentAction
WorkerLaunch and maintain pool of X prebooted microVMs in the background
WorkerBind to RabbitMQ queue jobs_q on jobs_ex exchange and jobs_rk routing key
APIBind to RabbitMQ queue jobs_status_q on jobs_status_ex exchange and jobs_status_rk routing key
FrontPOST /submissions
FrontPoll GET /submissions/:id every 500 ms
APISend job to RabbitMQ on jobs_ex direct exchange with jobs_rk routing key.
WorkerReceive job, get ready microVM from pool, send job to agent in microVM
AgentCompile/Run code, return result
WorkerDuring two previous steps, send status of jobs on jobs_status_ex exchange with jobs_status_rk routing key
APIReceive each new status on jobs_status_q, and insert them into DB and in-memory cache, so that the polling can get the latest status.
FrontGet the final result, stop polling and display it.

Contribute

Manage database with TypeORM

Delete schema:

npm run db:drop

Run all migrations:

npm run db:migrate

Reset db (combination of drop and migrate)

npm run db:reset
npm run typeorm migration:generate -- -n xxx

Create migration:

# After editing or adding an Entity
npm run typeorm migration:generate -- -n AddNewEntity

Code Style

Available commands for eslint/prettier:

npm run lint:check
npm run lint:fix
npm run format:check
npm run format:fix

About

The CodeBench main API

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages