An interactive platform to practice algorithms, data structures, and complexity.
Angular 20 + Node.js + MongoDB + C/C++ runner + local AI tutor with Ollama
Algo Arena has been developed by Mirko Distefano, Computer Science student at the Department of Mathematics and Computer Science, University of Catania, Italy.
Email: mirko.distefano@live.it
Algo Arena was born to turn classic algorithm exercises into interactive labs:
- build heaps and RB-trees step by step
- fill in DP tables and trace the optimal path
- simulate relaxations on graphs
- solve exercises in C/C++ with real compilation
The goal is not just to "give the right answer", but to understand the procedure.
Heap Arena: build max/min heap, extract, heapsort, tree visualisationRB-Tree Arena: guided insertions, recoloring, rotations, property checksGraph Lab: shortest path exercises with manual stepsHuffman Builder: tree construction and encodingsString DP Lab: LCS and Edit Distance with matrix and optimal pathHash Open Lab: open addressing hashing simulationMaster Lab: recurrences and the Master theorem
- exercises in
C/C++ - compilation and execution via a dedicated runner
- server-side validation on test cases
- atomic scoring, without trusting the client
- dashboard, user profile, and global leaderboard
- AI tutor integrated in the UI
server-sidevalidation of interactive labs- lab sessions persisted on MongoDB with authoritative server-side state
- step-by-step submission of every significant interaction
- anti-replay with
nonce + sequencerotated at each step - atomic point claiming to prevent double assignments
- challenge escalation with
Cloudflare Turnstileon suspicious flows - anomaly monitor with security event persistence
- browser/request guard on
Origin,Referer, andSec-Fetch-* - anti-automation heuristics for non-stealth headless / Puppeteer
Angular 20Angular MaterialTailwind CSSRxJSMonaco EditorJoint JS
Node.jsExpressMongoDB+MongooseJWTonhttpOnlycookies- custom security services
- isolated runner for
C/C++ Ollamafor the local AI tutor- PDF indexing for contextualised answers
Node.js20+npmMongoDB- optional:
DockerandDocker Compose
npm installStart from .env.example:
cp .env.example .envMinimum recommended configuration:
PORT=3001
MONGODB_URI=mongodb://127.0.0.1:27017/algo-arena
JWT_SECRET=change-me-with-a-strong-secret
TOKEN_EXPIRES_IN=7d
CLIENT_ORIGIN=http://localhost:4200,http://localhost:8080
RUNNER_URL=http://localhost:4000
AUTH_COOKIE_NAME=algo_arena_session
AUTH_COOKIE_SAME_SITE=lax
AUTH_COOKIE_SECURE=false
TURNSTILE_SITE_KEY=
TURNSTILE_SECRET_KEY=
TURNSTILE_EXPECTED_ACTION=security_challenge
SECURITY_CLEARANCE_COOKIE_NAME=algo_arena_clearance
SECURITY_CLEARANCE_TTL_MS=900000For all available options, see server/config.js.
If you have a local Mongo instance:
mongodOr just the database container:
docker compose up -d mongoIn three separate terminals:
npm run servernpm run runnernpm startMain endpoints in development:
- frontend:
http://localhost:4200 - API:
http://localhost:3001/api - runner:
http://localhost:4000
To start the full stack:
docker compose up --buildExposed services:
- frontend:
http://localhost:8080 - API:
http://localhost:3001/api - MongoDB:
mongodb://localhost:27017/algo-arena - runner:
http://localhost:4000 - Ollama:
http://localhost:11434
The stack includes:
mongoapirunnerwebollamaollama-initto download the initial models
The tutor integrated in the bottom right uses a local pipeline:
- embedding of PDFs in
pdfs/ - contextual retrieval
- response generated with
Ollama
Useful variables:
OLLAMA_URLOLLAMA_MODELOLLAMA_EMBED_MODELPDF_DIR
If you don't need the tutor, you can still use the app without touching this part.
| Command | Description |
|---|---|
npm start |
Start the Angular frontend |
npm run build |
Production build |
npm run watch |
Watch build in development |
npm test |
Angular/Karma tests |
npm run server |
Start the Express backend |
npm run server:dev |
Backend with nodemon |
npm run runner |
Start the C/C++ runner |
npm run github-build |
Build for GitHub Pages |
npm run github-deploy |
Deploy to GitHub Pages |
algo-arena/
βββ src/app/
β βββ core/ # services, guards, interceptors, models
β βββ features/ # interactive labs
β βββ pages/ # dashboard, auth, leaderboard, profiles
β βββ shared/ # reusable components, tutor, challenge
βββ server/
β βββ middleware/ # auth, browser guard
β βββ models/ # User, LabSession, SecurityEvent, ...
β βββ routes/ # auth, progress, code, chat, security
β βββ services/ # lab engine, scoring, security monitor
βββ runner/ # sandboxed execution of C/C++ exercises
βββ pdfs/ # documents indexed by the AI tutor
βββ public/ # static assets
βββ docker-compose.yml
- in
productionyou must set a realJWT_SECRET: the backend rejects the default - if you use cross-origin cookies,
CLIENT_ORIGINmust match the actual frontend Turnstileis optional: without keys, the hard block on the most aggressive patterns remains active
