Skip to content
elvisdragonmaoPublic

About

emjudge - Frontend assignment submission and automated grading

Resources

Code of conduct

Contributing

Security policy

Stars

13 stars

Watchers

0 watching

Forks

emjudge logo

emjudge

Frontend assignment submission and automated grading for HTML, CSS, JavaScript, and React projects.

Crowdin GitHub issues License

emjudge demo

Overview

emjudge is a monorepo application for managing frontend coursework. Students upload assignments, the platform evaluates them inside isolated Docker containers with Playwright, and teachers can review scores, screenshots, logs, and submission history from a web interface.

The system is organized into separate web, API, and worker applications so grading can scale independently from the user-facing product.

Highlights

  • React web app for students, teachers, and admins
  • Fastify API with authentication, class management, assignments, and submissions
  • Dedicated judge worker that polls grading jobs from PostgreSQL
  • Docker-based isolated execution for submitted projects
  • Playwright-driven grading with screenshots, logs, and structured test results
  • Shared workspace packages for types, schemas, permissions, and config
  • Multi-language web UI with Traditional Chinese, Simplified Chinese, and English

Quick Start

Deploy on Zeabur

You can deploy to Zeabur with one click, but since Zeabur doesn't supports Docker-in-Docker yet so judge still needs to be run somewhere else.

Start the full stack

docker compose up --build
  • App: http://localhost:8080
  • API health: http://localhost:8080/api/health
  • MinIO API: http://localhost:9000
  • MinIO Console: http://localhost:9001
  • PostgreSQL: localhost:5432

Default local credentials

  • Admin username: admin
  • Admin password: admin123
  • MinIO access key: minio
  • MinIO secret key: minioadmin

Stop the full stack

docker compose down

To also remove named volumes:

docker compose down -v

Local Development

Choose one of these local workflows:

  • docker-compose.dev.yml - only PostgreSQL and MinIO, for running app processes with pnpm dev
  • docker-compose.yml - full stack in Docker, including API, web, reverse proxy, and worker

1. Install dependencies

pnpm install

2. Start local infrastructure

docker compose -f docker-compose.dev.yml up -d

This starts local PostgreSQL and MinIO for development.

3. Create environment file

cp .env.example .env

At minimum, update these values before real usage:

  • JWT_SECRET
  • DEFAULT_ADMIN_PASSWORD

4. Initialize the database

pnpm db:migrate
pnpm db:seed

5. Build shared schemas

pnpm --filter @judge/shared build

6. Start the API and web app

pnpm dev

7. Start the judge worker in another terminal

pnpm dev:worker

8. Build the judge runner image

docker build -t judge-runner:latest docker/judge-runner/

Full Local Docker Deployment

If you want to run everything locally with one command, use the root docker-compose.yml.

What it starts

  • postgres - PostgreSQL database
  • minio - object storage
  • minio-init - creates the required buckets
  • api - Fastify backend
  • web - React frontend served by Nginx
  • caddy - local reverse proxy entrypoint
  • worker - judge worker with Docker socket access

Notes

  • The worker uses /var/run/docker.sock to launch isolated judge containers from inside the compose stack
  • The worker auto-builds judge-runner:latest from docker/judge-runner/ if the image does not exist yet
  • The API container runs database migration and admin seeding on startup
  • For real deployments, replace the default secrets in docker-compose.yml

Repository Layout

emjudge/
├── apps/
│   ├── api/          # Fastify backend
│   ├── web/          # React + Vite frontend
│   └── worker/       # Judge worker process
├── docker/
│   ├── api.Dockerfile
│   ├── web.Dockerfile
│   ├── worker.Dockerfile
│   ├── caddy/
│   ├── nginx/
│   ├── worker/
│   └── judge-runner/ # Playwright runner image
├── packages/
│   ├── shared/       # Shared types, schemas, constants, templates
│   └── config/       # Shared TypeScript config
├── docker-compose.yml      # Full local stack
├── docker-compose.dev.yml  # Infra-only dev stack
└── pnpm-workspace.yaml

Architecture

Applications

  • apps/web - React frontend for authentication, classes, assignments, grading results, and administration
  • apps/api - Fastify API for auth, user management, classes, assignments, submissions, storage access, and job creation
  • apps/worker - background judge worker that consumes queued grading jobs and writes results back to PostgreSQL

Shared Packages

  • packages/shared - shared Zod schemas, domain types, permissions, constants, and built-in Playwright test templates
  • packages/config - shared TypeScript configuration used across apps

Infrastructure

  • PostgreSQL for application data and job queue state
  • MinIO for uploaded submission files and grading artifacts
  • Docker for isolated grading execution

How Grading Works

  1. A student uploads an assignment through the web app.
  2. The API stores files in MinIO and creates submission and job records in PostgreSQL.
  3. The worker claims a pending job using PostgreSQL locking.
  4. The worker downloads files, prepares the grading workspace, and runs the submission inside the judge-runner Docker image.
  5. Playwright executes the assignment's test script.
  6. The worker stores logs, screenshots, and structured results, then updates submission status and score.

Tech Stack

Area Stack
Frontend React, Vite, React Router, React Query, Tailwind CSS
Backend Fastify, PostgreSQL, Zod, JWT
Worker Node.js, PostgreSQL, MinIO, Docker
Testing Runtime Playwright
Tooling pnpm workspaces, TypeScript

Prerequisites

Tool Version
Node.js 22.13+
pnpm 11+
Docker 24+
PostgreSQL 15+
MinIO latest

Development Commands

Root

pnpm dev
pnpm dev:web
pnpm dev:api
pnpm dev:worker
pnpm build
pnpm db:migrate
pnpm db:seed
pnpm format

Per App

pnpm --filter @judge/web build
pnpm --filter @judge/api build
pnpm --filter @judge/worker build
pnpm --filter @judge/shared build

Environment Variables

The project uses a shared root .env for local development. See .env.example for the full reference.

Commonly used variables include:

  • DATABASE_URL
  • JWT_SECRET
  • DEFAULT_ADMIN_PASSWORD
  • CORS_ORIGIN
  • MINIO_ENDPOINT
  • MINIO_PORT
  • MINIO_ACCESS_KEY
  • MINIO_SECRET_KEY
  • MINIO_PUBLIC_BASE_URL
  • CACHE_ROOT_DIR
  • JUDGE_IMAGE
  • WORKER_ID

Frontend Internationalization

The web app uses react-i18next and ships with:

  • zh-TW
  • zh-CN
  • en

Translation sources live under apps/web/src/i18n/locales/, and crowdin.yml is configured for translation sync workflows.

API Documentation

Interactive API documentation is available through Swagger in the running API service: /api/docs.

Deployment

Build artifacts

pnpm --filter @judge/shared build
pnpm --filter @judge/web build
pnpm --filter @judge/api build
pnpm --filter @judge/worker build

Run services without Docker

node apps/api/dist/index.js
node apps/worker/dist/index.js

The frontend production bundle is generated in apps/web/dist and can be served by Nginx or any static file server.

Deploy standalone judge workers

The judge worker must run on a machine with Docker access because it launches isolated judge-runner containers through /var/run/docker.sock.

Create a .env file on the worker host with the remote database and MinIO settings:

DATABASE_URL=postgresql://...
MINIO_ENDPOINT=...
MINIO_PORT=443
MINIO_ACCESS_KEY=...
MINIO_SECRET_KEY=...
MINIO_USE_SSL=true

JUDGE_REACT_CPUS=1
JUDGE_HTML_CPUS=1
JUDGE_REACT_MEMORY=1g
JUDGE_HTML_MEMORY=512m
JUDGE_PLAYWRIGHT_WORKERS=1
JUDGE_DOCKER_PIDS_LIMIT=128

Build the judge image and start three worker instances:

docker build -t emjudge-judge:latest docker/judge-runner/
docker compose -f docker-compose.workers.yml up -d --build worker1 worker2 worker3

Each worker in docker-compose.workers.yml has a unique WORKER_ID and cache directory. With the default limits above, three concurrent React grading jobs use about three judge CPUs plus container overhead.

If the root docker-compose.yml stack is also running on the same host, stop its single worker service so you do not accidentally run a fourth worker:

docker compose stop worker
docker compose rm -f worker

Check worker status and resource usage:

docker ps
docker stats
docker logs -f emjudge-worker-1

The local Docker images used by docker-compose.yml are defined in docker/api.Dockerfile, docker/web.Dockerfile, and docker/worker.Dockerfile.

Production Notes

  • Use a strong JWT_SECRET
  • Rotate the seeded admin password after setup
  • Replace default PostgreSQL and MinIO credentials
  • Restrict CORS_ORIGIN to trusted domains
  • Enable SSL for MinIO in production where applicable
  • Build and publish the judge-runner image before enabling grading
  • Run API and worker processes under a supervisor such as systemd, PM2, or containers
  • Ensure Docker permissions and resource limits are reviewed before accepting untrusted submissions

Assignment Authoring

Assignments support two grading modes:

  • html-css-js
  • react

Teachers can define:

  • title
  • markdown description
  • assignment type
  • due date
  • whether multiple submissions are allowed
  • Playwright grading script

The web app also includes built-in Playwright test templates to speed up assignment authoring.

Data Model Summary

Core entities include:

  • users
  • classes
  • class members
  • assignments
  • assignment specs
  • submissions
  • submission files
  • submission runs
  • submission artifacts
  • judge jobs
  • password reset logs
  • bulk import jobs

The SQL schema lives in apps/api/src/db/schema.sql.

Typical Workflow

Admin

  1. Sign in with the seeded admin account.
  2. Create users individually or through bulk import.
  3. Create classes.
  4. Add students and teachers to classes.

Teacher

  1. Open a class.
  2. Create an assignment.
  3. Add instructions and a Playwright grading script.
  4. Review submissions, screenshots, logs, and scores.

Student

  1. Open a class.
  2. View assignment requirements.
  3. Upload files or a project folder.
  4. Wait for grading to complete.
  5. Review score, screenshots, logs, and test output.

Community Health

  • Code of Conduct: CODE_OF_CONDUCT.md
  • Contributing Guide: CONTRIBUTING.md
  • Security Policy: SECURITY.md
  • License: LICENSE

Contributing

If you extend the system, prefer keeping cross-app contracts in packages/shared, and keep user-facing API details documented in Swagger rather than duplicating them in Markdown. For contribution workflow, review CONTRIBUTING.md before opening an issue or pull request.

About

emjudge - Frontend assignment submission and automated grading

Resources

Code of conduct

Contributing

Security policy

Stars

13 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages