Skip to content

Development Guide

Day-to-day hacking on NextJudge.

You’ve run ./dev-deploy.sh web. This page is for the second hour onward.

ToolVersionFor
Docker20.10+Compose stacks
Go1.21+Data layer
Node / Bun18+Web
Python3.10+Judge + Tavern tests
GitanyPRs
NextJudge/
├── compose/ # docker-compose.*.yml
├── src/
│ ├── data-layer/src/ # Go handlers (users.go, problems.go, …)
│ ├── judge/ # languages.toml, nsjail, app.py
│ ├── web/src/app/ # Next.js routes
│ ├── cli/ # nextjudge command
│ └── docs/ # you're here
├── deploy.sh # prod-ish local stack
├── dev-deploy.sh # hot reload + SEED_DATA
└── fully-reset.sh # scorched earth
TaskStart here
API bug / new endpointsrc/data-layer/src/*.go, then tests/test_data_layer.tavern.yaml
Wrong verdict / TLEsrc/judge/src/, languages.toml
UI / editorsrc/web/src/app/, src/web/src/components/
Types shared with APIsrc/web/src/lib/types.ts
Schema changesrc/data-layer/src/models.go, maybe schema_updates.sql

Data layer (must be running on :5000):

Terminal window
cd src/data-layer
pip install -r tests/requirements.txt
pytest tests/ -p no:warnings

Tavern tests hit real HTTP. They assume auth is relaxed or configured like CI. Failures print the stage name; search that in test_data_layer.tavern.yaml.

Judge:

Terminal window
cd src/judge && python -m pytest tests/
# or ./tests.sh

Web:

Terminal window
cd src/web && npm run lint && npm test

Path-filtered jobs in .github/workflows/ci.yml:

Change inRuns
src/web/**lint, Docker build
src/data-layer/**Go tests, API Tavern tests
src/judge/**Judge tests, image build
src/docs/**Docs build

Touch one service, you usually only wait on that job. Nice when judge Python and web TypeScript aren’t coupled.

  1. Handler in the right *.go file
  2. Route registration in the same file’s add*Routes
  3. AuthRequired, AdminRequired, or AtLeastJudgeRequired
  4. Tavern stage in tests/
  5. API reference update

See Judge service: Add a language. Rebuild basejudge:dev or prod target after Dockerfile changes.

Edit models.go. AutoMigrate on next data layer start. Destructive change? Add SQL to schema_updates.sql, test with ./fully-reset.sh locally before prod.

ServiceTry
Data layergo run src/main.go -d -p 5000
Judgedocker logs $(docker ps -qf name=judge)
WebDevTools + terminal running npm run dev
Postgresdocker exec -it $(docker ps -qf name=postgres) psql -U postgres nextjudge
RabbitMQhttp://localhost:15672 (creds from .env.dev)

Env sources: config.go, judge app.py, web .env.example.

Go: gofmt, early returns. TS: strict, no any. Python: PEP 8, type hints on new code.

Branch from main, test locally, PR. CONTRIBUTING.md for the social stuff.

Build all images: docker buildx bake -f docker-bake.hcl