A guide for maintainers: how the project fits together, how changes reach codearena.co, what to check before merging, and what to do when something breaks. Contributors should start with CONTRIBUTING.md.
| Part | Where | Notes |
|---|---|---|
| Backend | backend/ |
Node, Express, Socket.io, SQLite. server.js holds battles, matchmaking and sockets; routes/ the REST API; db.js schema, migrations and queries. |
| Code runner | backend/arena/ |
Builds a program from a player’s code plus a small driver, runs it on Judge0, compares results. One driver per language in runner/harness.js. |
| Problems | backend/arena/problems/ |
One JSON file per problem, with JavaScript, Python and Java reference solutions in arena/solutions/. |
| Frontend | frontend/ |
Next.js, React, Tailwind, Monaco. |
| Shared | shared/ |
Code both sides use, such as fair-use limits (codearenaProductMode.js). |
.github/workflows/ci.yml):
main deploys automatically:
railway.toml at the repo root. Keep the service’s Root Directory empty: the build and start commands already point into backend/.frontend.GET /health to pass before switching traffic, so a build that crashes on boot never replaces the running version.main is production. Merge only what you would deploy.
backend/.env.example (or frontend/.env.example). Optional features stay off when their variable is unset.migrations list in backend/db.js with the next id, recorded with npm run migrations:ledger. Never edit or reorder an existing migration: live databases have already run it.npm run validate:problems passes (both reference solutions pass every test), and it is the author’s own work.shared/codearenaProductMode.js.Application quotas limit normal use. Configure provider spending limits separately; application quotas do not protect against a stolen provider key.
| Service | Used for | Cap |
|---|---|---|
| Judge0 (RapidAPI) | Running player code | CODEARENA_GLOBAL_DAILY_CODE_EXECUTION_LIMIT runs per day, plus per-player daily limits |
| Anthropic | Claude models in prompt battles and other AI features | Workspace spend limit, plus CODEARENA_GLOBAL_DAILY_PROMPT_EVALUATION_LIMIT |
| OpenAI, Gemini, DeepSeek | Extra prompt battle models | Prepaid credit or free tier; each model hides itself when its key is unset |
| Resend | Key restricted to the codearena.co domain |
Pricier models count more against the daily prompt budget (Opus 5, Sonnet 3, the rest 1), in backend/services/promptBattleRunner.js.
The local browser suite does not verify production email delivery, provider credentials or hosting access. Before announcing a release, separately verify a new account’s registration, email verification, login and code execution on the deployed site.
Deploy support for these controls before enabling them:
CODEARENA_RUNNER=disabled keeps the API running but returns execution unavailable for code submissions and custom inputs. It overrides configured Judge0 credentials and never falls back to local execution. Practice and coding battles cannot complete normally while it is enabled.CODEARENA_AVATARS_DISABLED=1 rejects avatar uploads and deletions with HTTP 503 before processing images or contacting storage. Existing avatar URLs remain readable.These switches stop normal application calls; they do not protect credentials still present in the process from a server compromise. Remove affected provider secrets from the deployment and restart it to remove runtime access. Revoke old keys at the provider after all legitimate consumers have migrated. Old deployments may retain configuration, so do not roll back to a deployment containing retired credentials.
To restore service, configure dedicated provider credentials, remove the maintenance switches, redeploy, and verify a code submission and an avatar change.
https://api.codearena.co/health. It reports the running version (commit) and whether the database and websockets are up.main so the next push does not bring it back.GEMINI_MODEL, OPENAI_PREMIUM_MODEL, and so on); see backend/.env.example.The public battle-integrity implementation is developed independently for this project’s players. Do not import private assessment detection engines, proctoring modules, edit-trace analysis, calibration fixtures, scoring thresholds or their tests from another product. The publish guard checks known private module names and identifiers, including copies under renamed paths. Human review is still required; this is not a general detector of copied code.
Generic UI state, account security and community moderation can remain public. New community-developed integrity techniques are welcome when contributors have the right to publish them. Validate detection and false-positive behavior before enabling them for players.
The project’s license governs community contributions. Do not assume maintaining the project grants additional rights to incorporate others’ contributions into proprietary software. Before any such reuse, record the source revision, authors and dependencies, and obtain a legal review of the applicable licenses and any separate permissions. No contributor has granted extra rights merely because this guide describes that review.
sandbox="allow-scripts", no same-origin access), so a game cannot touch a player’s account.Act on reports promptly. Remove content that breaks the Terms.
CODEARENA_PRIVATE_PROBLEMS_DIR (see the README).good first issue.cd backend && npm test && npm run validate:problems
cd frontend && npm run lint && npm test
node scripts/check-boundary.js