A production-ready multi-language online compiler with Docker sandboxed execution, built with Next.js, Express, and Neon PostgreSQL.
- 8 Languages: Python, C, C++, JavaScript, PHP, Java, Assembly (NASM), and Binary mode
- Docker Sandboxed: Every execution runs in an isolated container with strict resource limits
- Secure: Network isolation (
--network none), non-root user, timeouts enforced - VS Code-style Editor: Monaco Editor with syntax highlighting, auto-completion, and themes
- Binary Mode: Convert binary strings to decimal, hex, octal, and ASCII
- Assembly Mode: Write and run NASM x86-64 assembly code
- Responsive UI: Works on desktop and mobile with dark SaaS design
- Persistent Storage: Neon PostgreSQL for execution logs and snippets
- Docker Compose: One-command deployment
┌─────────────┐ ┌─────────────┐ ┌──────────────────┐
│ Frontend │────▶│ Backend │────▶│ Docker Sandbox │
│ Next.js │ │ Express │ │ (Isolated per │
│ Monaco │◀────│ API │◀────│ execution) │
│ Tailwind │ │ │ │ │
└─────────────┘ └──────┬──────┘ └──────────────────┘
│
▼
┌──────────────┐
│ Neon │
│ PostgreSQL │
└──────────────┘
| Component | Technology |
|---|---|
| Frontend | Next.js 14, React 18, Tailwind CSS, Monaco Editor, Framer Motion |
| Backend | Node.js, Express, TypeScript, Dockerode |
| Database | Neon PostgreSQL (serverless) |
| Execution | Docker with resource limits, Network isolation |
| Languages | Python 3, GCC 13, G++ 13, Node.js 20, PHP 8.3, OpenJDK 21, NASM |
- Node.js 18+
- Docker
- npm or yarn
- A Neon PostgreSQL database (or any PostgreSQL)
- Clone and install dependencies
git clone <repo-url> codeforge
cd codeforge
# Install backend dependencies
cd backend && npm install && cd ..
# Install frontend dependencies
cd frontend && npm install && cd ..- Set up environment variables
cp .env.example .env
# Edit .env with your Neon PostgreSQL connection string- Build the execution Docker image
docker build -t codeforge-executor:latest ./execution- Run the backend
cd backend
npm run dev- Run the frontend (in a separate terminal)
cd frontend
npm run dev# Build and start all services
docker compose build --no-cache
docker compose up -d
# View logs
docker compose logs -f
# Stop services
docker compose downThe app will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:4000
Execute code in a sandboxed Docker container.
Request Body:
{
"language": "python",
"code": "print('Hello World')",
"input": "optional input"
}Response:
{
"output": "Hello World\n",
"error": "",
"exitCode": 0,
"executionTimeMs": 45,
"timedOut": false,
"memoryUsedKb": 8192,
"cpuTimeMs": 42
}Returns list of supported languages.
Convert a binary string to decimal, hex, octal, and ASCII.
Request Body:
{
"binary": "01001000 01101001"
}Health check endpoint.
Each code execution is sandboxed with:
| Restriction | Value |
|---|---|
| Network | Blocked (--network none) |
| User | Non-root (UID 1000) |
| Memory | Configurable (default 256MB) |
| CPU | Configurable (default 1 vCPU) |
| Timeout | Configurable (default 10s) |
| Output Limit | Configurable (default 64KB) |
| File System | Read-only root, temp bind mount |
| Process Limit | Max 50 PID |
| Variable | Default | Description |
|---|---|---|
DATABASE_URL |
- | Neon PostgreSQL connection string |
EXECUTION_TIMEOUT |
10 | Max execution time in seconds |
EXECUTION_MEMORY_LIMIT |
256 | Memory limit in MB |
EXECUTION_CPU_LIMIT |
1 | CPU cores limit |
EXECUTION_OUTPUT_LIMIT |
65536 | Max output size in bytes |
EXECUTION_MAX_FILE_SIZE |
65536 | Max code size in bytes |
CORS_ORIGIN |
http://localhost:3000 | Allowed CORS origin |
PORT |
4000 | Backend port |
NEXT_PUBLIC_API_URL |
http://localhost:4000 | API URL for frontend |
codeforge/
├── frontend/ # Next.js application
│ ├── src/
│ │ ├── app/
│ │ │ ├── page.tsx # Landing page
│ │ │ ├── layout.tsx # Root layout
│ │ │ ├── globals.css # Global styles
│ │ │ └── compiler/
│ │ │ └── page.tsx # Compiler page
│ │ ├── components/
│ │ │ ├── Editor.tsx # Monaco Editor wrapper
│ │ │ ├── OutputPanel.tsx # Output/terminal display
│ │ │ ├── InputPanel.tsx # Custom input panel
│ │ │ ├── LanguageSelector.tsx
│ │ │ ├── BinaryMode.tsx # Binary converter
│ │ │ ├── AssemblyMode.tsx # Assembly templates
│ │ │ ├── Navbar.tsx
│ │ │ └── Footer.tsx
│ │ └── lib/
│ │ ├── api.ts # API client
│ │ ├── types.ts # TypeScript types
│ │ └── templates.ts # Code templates
│ ├── next.config.js
│ └── tailwind.config.ts
├── backend/ # Express API
│ ├── src/
│ │ ├── index.ts # Entry point
│ │ ├── routes/
│ │ │ └── execute.ts # Execute, languages, binary endpoints
│ │ ├── services/
│ │ │ └── docker.ts # Docker sandbox executor
│ │ ├── db/
│ │ │ ├── index.ts # Database connection & queries
│ │ │ └── schema.ts # SQL schema
│ │ ├── middleware/
│ │ │ ├── rateLimit.ts
│ │ │ └── errorHandler.ts
│ │ └── config/
│ │ └── index.ts
│ └── Dockerfile
├── execution/
│ └── Dockerfile # Multi-language execution image
├── docker-compose.yml
└── .env.example
MIT