A full-stack online code execution platform supporting 30+ programming languages with WASM-first execution, intelligent fallback, real-time collaboration, and comprehensive admin panel.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TryCode.run Architecture β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββ βββββββββββββββββββββββ βββββββββββββββββββββββ β
β β Frontend ββββββΆβ Backend API ββββββΆβ Executor Pool β β
β β (React+Vite)β β (Rust+Axum) β β (2x gVisor) β β
β ββββββββββββββββ βββββββββββββββββββββββ βββββββββββββββββββββββ β
β β β β β
β βΌ βΌ βΌ β
β ββββββββββββββββ βββββββββββββββββββββββ βββββββββββββββββββββββ β
β β Monaco β β PostgreSQL + Redis β β Debian 12 + 30 β β
β β Editor + β β (1panel-network) β β Languages + gVisor β β
β β Yjs Collab β β β β β β
β ββββββββββββββββ βββββββββββββββββββββββ βββββββββββββββββββββββ β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Observability Stack (VictoriaLogs + VictoriaMetrics)β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Tier 1 (WASM-native): Python (Pyodide), JavaScript/TypeScript (QuickJS), HTML/CSS/JS (Browser), Rust (wasmer), Lua, SQL
- Tier 2 (Native compiled): Go, Rust, C/C++, Java, C#, PHP, Ruby, Swift, Kotlin, Scala, R, Dart, Zig, Julia, Haskell, Fortran, Objective-C, VB.NET, F#, Groovy
- Tier 3 (Shell): Bash, PowerShell, SQL
- 5-second timeout for WASM execution in browser
- Automatic fallback to backend on timeout, OOM, missing runtime, compile errors
- Preloading of common language runtimes (Python, JS, TS)
- Resource quotas per user/language (CPU time, memory, disk, wall time)
- Yjs CRDT for conflict-free concurrent editing
- WebSocket awareness (cursors, selections, user presence)
- Permission system: Owner, Editor, Viewer roles
- Persistence to PostgreSQL with incremental sync
- JWT (15min access + 30d refresh, HttpOnly cookies)
- Argon2id password hashing (configurable parameters)
- Email verification with 6-digit codes
- CAPTCHA (trycap.dev self-hosted, Turnstile/hCaptcha/reCAPTCHA fallback)
- GitHub OAuth with domain restrictions
- Rate limiting (IP, user, API key tiers)
- gVisor (ptrace platform) for strong sandbox isolation
- System monitoring: Users, executions, success rates, language stats
- User management: Roles, status, locking, execution quotas
- Execution logs: Filtering, WASM fallback tracking
- Dynamic config: Hot-reload via PostgreSQL NOTIFY
- System tests: SMTP, CAPTCHA, OAuth, Database
- Audit logs: All admin actions tracked
- Virtual filesystem with folders, files, rename, move, delete
- Sharing: Time-limited, password-protected, permission-controlled links
- Forking: Full project copy with history
- Templates: Language-specific starter templates
- Code explanation (brief/standard/detailed)
- Code review (security, performance, readability, bugs)
- Test generation (pytest, jest, cargo test, etc.)
- Chat with code context
- Configurable endpoint, model, temperature
# docker-compose.yml - 3 services only!
services:
backend: # Rust API + VictoriaMetrics + VictoriaLogs + Vector (s6-overlay)
exec-worker-1: # Debian 12 + 30 languages + gVisor
exec-worker-2: # Debian 12 + 30 languages + gVisorExternal dependencies (on 1panel-network):
- PostgreSQL (
pgdocker:5432) - Redis (
redisdocker:6379)
Resource budget (4 CPU cores):
| Container | CPU | Memory |
|---|---|---|
| backend | 1.5 cores | 1.5 GB |
| exec-worker-1 | 1.0 core | 768 MB |
| exec-worker-2 | 1.0 core | 768 MB |
- Docker & Docker Compose
- PostgreSQL & Redis (on
1panel-network) - Domain with SSL (OpenResty terminates TLS)
# On server (run once)
sudo systemctl start trycode-init-secrets
# Or manually:
mkdir -p /opt/trycode/secrets
openssl rand -hex 32 > /opt/trycode/secrets/jwt_secret.txt
openssl rand -hex 24 > /opt/trycode/secrets/pg_password.txt
# ... etc (see scripts/init-secrets.sh)cp /opt/trycode/config/backend.toml.example /opt/trycode/config/backend.toml
# Edit with your SMTP, CAPTCHA, OAuth, AI settingscd /opt/trycode
TAG=v1.0.0 docker compose pull
TAG=v1.0.0 docker compose up -d --remove-orphans# Visit https://trycode.run/admin
# First visit creates super admin accounttrycode.run/
βββ docker-compose.yml # 3-container orchestration
βββ config/
β βββ backend.toml # Backend config (hot-reload)
β βββ vector.toml # Vector log collector config
β βββ vm-scrape.yml # VictoriaMetrics scrape config
β βββ trycode.run.conf # OpenResty template
βββ backend/
β βββ Cargo.toml # Rust workspace
β βββ Dockerfile.all-in-one # s6-overlay multi-process image
β βββ migrations/ # SQLx migrations (PostgreSQL)
β βββ trycode-backend/ # Main binary
β βββ trycode-core/ # Shared config, DB, metrics
β βββ trycode-auth/ # JWT, Argon2id, CAPTCHA, OAuth
β βββ trycode-execution/ # Queue, scheduler, gVisor, limits
β βββ trycode-collab/ # Yjs WebSocket broker
β βββ trycode-projects/ # Projects, files, sharing
β βββ trycode-admin/ # Admin panel, config, tests
β βββ trycode-ai/ # AI gateway (OpenAI-compatible)
βββ executor/
β βββ Dockerfile # Debian 12 + 30 langs + gVisor
β βββ entrypoint.sh # Metrics exporter entrypoint
β βββ Cargo.toml # Executor daemon (metrics)
βββ frontend/
β βββ package.json # React + Vite + TS
β βββ vite.config.ts
β βββ tailwind.config.js
β βββ src/
β βββ components/ # Editor, Terminal, FileTree, Collab, AI
β βββ pages/ # Editor, Project, Auth, Admin, Share
β βββ hooks/ # useAuth, useTheme, useCollab
β βββ stores/ # Zustand (editor, execution, UI)
β βββ utils/ # API client, language config
βββ scripts/
β βββ init-secrets.sh # Secret generator
β βββ trycode-init-secrets.service # systemd oneshot
βββ .github/workflows/ # CI/CD (build, test, deploy)
βββ README.md
[server]
host = "0.0.0.0"
port = 3000
[database]
url = "postgres://trycode:pass@pgdocker:5432/trycode"
[redis]
host = "redisdocker"
port = 6379
[smtp]
host = "smtp.example.com"
port = 587
username = "noreply@trycode.run"
password = "secret" # From Docker Secret
from = "TryCode <noreply@trycode.run>"
tls = "starttls"
[captcha]
provider = "trycap"
site_key = "your-site-key"
secret_key = "secret" # From Docker Secret
verify_url = "http://trycap:8080/api/v1/verify"
enabled = true
actions = ["register", "login", "execute"]
[oauth.github]
enabled = true
client_id = "github-client-id"
client_secret = "secret" # From Docker Secret
redirect_url = "https://trycode.run/api/auth/oauth/github/callback"
[ai]
enabled = true
base_url = "https://api.openai.com/v1"
api_key = "sk-..." # From Docker Secret
default_model = "gpt-4o-mini"
[execution]
global_max_concurrent = 4
per_user_max_concurrent = 2
queue_timeout_secs = 60
default_cpu_time_secs = 30
default_memory_mb = 256VITE_API_BASE=/api
VITE_WS_BASE=ws://localhost:3000cd backend
cargo test --workspace
cargo run --bin trycode-backend servecd frontend
npm install
npm run dev
# http://localhost:5173docker compose -f docker-compose.yml up -d
# Backend: http://localhost:3000
# Frontend: http://localhost:5173 (dev)
# Metrics: http://localhost:8428
# Logs: http://localhost:9428- Metrics: VictoriaMetrics at
:8428(PromQL, 30d retention) - Logs: VictoriaLogs at
:9428(LogSQL, 7d/30d retention) - Vector collects Docker logs β VictoriaLogs
- Health:
GET /health(checks PG, Redis, VM, VL, executors)
- gVisor ptrace platform (kernel 7.x compatible)
- No network in execution containers (
network_mode: none) - Read-only rootfs, tmpfs for workspace
- Resource limits: CPU, memory, pids, disk
- Secrets: Docker Secrets (JWT, DB, SMTP, CAPTCHA, AI, OAuth)
- Rate limiting: Per-IP, per-user, per-API-key
- CSP, HSTS, X-Frame-Options via OpenResty
MIT License - see LICENSE file for details.
- Fork the repository
- Create feature branch
- Run tests:
cargo test --workspace/npm test - Submit PR
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@trycode.run