codetrail

CodeTrail

Practice coding and prompting with friends, battle other developers live, climb the rankings and build community games.

CodeTrail is an open-source project (AGPL-3.0). It runs the public site at codearena.co and you can host your own copy. Source: github.com/codearena-oss/codearena.

What is in the box

Quick start

You need Node 20 or 22, and a Judge0 server to run player code safely. For development you can skip Judge0 and run code directly on your machine (not safe for anything public).

# backend
cd backend
cp .env.example .env            # set JWT_SECRET; everything else is optional
npm ci
CODEARENA_RUNNER=local npm run dev   # http://localhost:3001

# frontend, in another terminal
cd frontend
cp .env.example .env.local
npm ci
npm run dev                     # http://localhost:3000

To run player code in a real sandbox, start Judge0 and point the backend at it:

# edit judge0.conf first and change both passwords
docker compose -f docker-compose.judge0.yml up -d
# in backend/.env
JUDGE0_URL=http://localhost:2358

Judge0 CE on RapidAPI also works: set RAPIDAPI_KEY instead of JUDGE0_URL.

Configuration

Everything is read from environment variables; backend/.env.example and frontend/.env.example list them with comments. The short version:

Variable Needed for
JWT_SECRET Everything. Generate a long random string.
JUDGE0_URL or RAPIDAPI_KEY Running player code (battles, practice).
CODEARENA_RUNNER=local Development only: runs code on the host with no sandbox. Refused in production.
ANTHROPIC_API_KEY Prompt battles, prompt practice, agent battles, complexity feedback, CreatorArena generation.
OPENAI_API_KEY, GEMINI_API_KEY, DEEPSEEK_API_KEY Extra prompt battle models (optional). backend/.env.example lists the model settings.
CODEARENA_AGENT_BATTLES=1 Turns agent battles on (also needs ANTHROPIC_API_KEY).
RESEND_API_KEY Email: verification, password reset, notifications.
GOOGLE_CLIENT_ID, GITHUB_CLIENT_ID/_SECRET Social sign-in.
STRIPE_* Legacy billing records only. New CodeTrail purchases are retired; leave unset for new deployments.
CODEARENA_PRIVATE_PROBLEMS_DIR Extra problems a hosted instance keeps out of git (see below).
CODEARENA_DAILY_*, CODEARENA_GLOBAL_DAILY_* Fair-use limits per user and per server, in UTC days.

Self-hosted copies send no telemetry. Sentry and Mixpanel only activate when you set their keys.

Problems

The problem set lives in backend/arena/problems, one JSON file per problem, with JavaScript, Python and Java reference solutions in backend/arena/solutions. A problem is accepted only when all three references pass every test:

cd backend
npm run validate:problems

Adding a problem is the best first contribution. backend/arena/docs/problems.md explains the format. Problems must be your own work.

Everything in this repository is public, including tests, so a determined player could hard-code answers. If you run ranked battles, keep an extra private set in a directory laid out like backend/arena/ and set CODEARENA_PRIVATE_PROBLEMS_DIR to it. The bots will find solutions there too.

Supported languages: JavaScript, Python, TypeScript and Java. Adding another language means adding a driver in backend/arena/runner/harness.js and a reference solution for every problem. C++ and Go are open for contributors (#2, #3).

How it is built

Contributing

See CONTRIBUTING.md. Maintainers: MAINTAINING.md covers deploys, reviews, costs and what to do when something breaks. Bug reports and problem submissions are the most useful things you can bring. Please report security issues privately as described in SECURITY.md.

License

GNU Affero General Public License v3.0. You can run, study, change and share CodeTrail, including commercially; if you run a modified version as a service, you must offer its source to your users under the same license.

Credits

CodeTrail was built by Sennai Kaffl with Tanish Thumbraguddi, Vincent Lo, Bradley Tsou, Teoman Yavuzkurt, Evan Xie, Soham Goswami and Ethan Massey, plus everyone who played, tested and reported bugs along the way. CONTRIBUTORS.md has each person’s commits, lines and areas; the commit history credits each author’s files. Parts of the code were written with AI coding assistants. Thanks to the Judge0 project for the sandbox that makes the battles possible.