All Projects
Full Stack

C++ Online Compiler

About

The C++ Online Compiler is a full-stack, web-based development environment that allows users to write, compile, and execute C++ code directly within their browser. Built entirely from scratch, it removes the friction of local compiler setups by providing a seamless, real-time coding experience with instant output feedback and isolated execution.

Tech Stack

React
Tailwind CSS
Node.js
Express.js

Features

Real-Time Execution

Write C++ code and execute it instantly with results streamed directly to the browser.

Comprehensive Error Handling

Captures and cleanly displays both standard output (stdout) and compilation/runtime errors (stderr).

Isolated Processing

Executes user-submitted code securely utilizing Node.js child processes.

Dynamic File Management

Uses the fs module to handle the creation and cleanup of temporary .cpp files on the server automatically.

Modern Interface

A responsive, developer-friendly UI built with React.

Architecture

01

Client Layer

The React frontend acts as the user interface, capturing code input and sending it to the backend via a REST API payload.

02

File Processing

Upon receiving the request, the Express backend uses the fs module to write the raw string into a temporary .cpp file on the server.

03

Compilation & Execution Pipeline

The child_process module is used to spawn a system shell command. It first runs the compiler (like g++) on the .cpp file. If successful, it executes the resulting binary file.

04

Feedback Loop

The backend listens to the child process's data streams, captures the output or compilation errors, and sends it back to the React frontend as a structured JSON response.

Future Improvements

Docker Sandboxing

Wrap the execution layer in isolated, ephemeral Docker containers to provide strict security limits on memory, CPU, and network access to prevent malicious code execution.

Monaco Editor Integration

Upgrade the code input area with the Monaco Editor (the engine behind VS Code) to provide syntax highlighting, line numbers, and intelligent auto-completion.

Execution Timeout Limits

Implement strict timeout rules on the child processes to automatically kill programs that enter infinite loops, preventing server resource exhaustion.