C++ Notebook is a modern, high-performance, interactive code playground for C++ developers, students, and hobbyists. Drawing inspiration from Google Colab and Jupyter Notebooks, it allows you to run independent C++ code cells, view real-time compilation and execution outputs, stream interactive standard input (stdin), and compile using standard C++17, C++20, or C++23 configurations.
π Live Web Version: cpp-notebook.rapiddocs.in
The application runs in two modes:
- Desktop Application: A local-first client built on Tauri, utilizing your machine's local
g++compiler. - Web Version: A browser-based version that connects securely to a remote sandbox runner to execute C++ code without installing anything locally. You can try the live version directly at cpp-notebook.rapiddocs.in.
- Interactive Cell Environment: Create, drag-and-drop, clone, and execute independent code blocks or formatted Markdown notes.
- Real-Time Interactive Stdin: Pipe user input (
cin,scanf) dynamically to your running programs via an integrated console interface. - Cross-Platform Architecture: Powered by a decoupled frontend that switches between Tauri IPC invoke calls (local execution) and WebSockets (remote sandbox).
- Custom Standards: Swap between
c++17,c++20, andc++23standards on-the-fly. - Developer Appreciation & Support: Built-in modal next to the help settings panel containing repository links and developer support options.
- Aesthetic Glassmorphism UI: Beautiful, premium dark/light mode designs featuring smooth transitions and micro-animations.
graph TD
A[Frontend: React + TS] -->|Desktop Mode| B[Tauri IPC / Rust Bridge]
A -->|Web Mode| C[WebSocket Client]
B -->|Local System| D[Local Compiler: g++]
C -->|Secure Network| E[Remote Backend Service]
E -->|Sandboxed Process| F[Linux Subprocess / g++]
To run or build the desktop version, your system needs Node.js, the Rust toolchain, and the g++ compiler installed.
- Node.js: Download and run the installer from Node.js Official Website.
- C++ Compiler (g++):
- Download MSYS2 from msys2.org and run the installer.
- Open MSYS2 UCRT64 terminal and install the toolchain:
pacman -S mingw-w64-ucrt-x86_64-gcc
- Add
C:\msys64\ucrt64\binto your Windows system Environment Variable PATH.
- Tauri Dependencies:
- Download and run the Rust installer from rustup.rs.
- Install Build Tools for Visual Studio 2022 from visualstudio.microsoft.com and select the Desktop development with C++ workload.
- Node.js: Install via Homebrew:
brew install node. - C++ Compiler & Tauri Dependencies:
- Open terminal and install Xcode Command Line Tools:
xcode-select --install
- Install Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Optional (Real GCC instead of Apple Clang):
brew install gcc.
- Open terminal and install Xcode Command Line Tools:
- Node.js: Install via your package manager or NodeSource.
- C++ Compiler, Tauri & GUI Libraries:
- Run the following command to install the required GTK, WebKit, and build tools:
sudo apt update sudo apt install -y build-essential curl wget file libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev libwebkit2gtk-4.1-dev
- Run the following command to install the required GTK, WebKit, and build tools:
- Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Clone the Repository:
git clone https://github.com/regionalduck/cpp-notebook.git cd cpp-notebook -
Install Dependencies:
npm install
-
Run Development Server:
- For Web Version (Browser):
npm run dev
- For Desktop Application (Tauri):
npm run tauri dev
- For Web Version (Browser):
-
Build Production Packages:
- Frontend Web Bundle:
npm run build
- Desktop App Binaries (macOS, Windows, Linux):
npm run tauri build
- Frontend Web Bundle:
The remote sandbox executor lives inside the /backend folder. It is designed to containerize and execute user code securely.
This project is configured with a Dockerfile that works out-of-the-box on Render or Railway.
- Create a new Web Service pointing to your repository.
- Set the Root Directory to
backend. - The build system will automatically compile the Docker container, run the health check endpoint, and expose the WebSocket server.
- Copy your live URL (e.g.
https://cpp-notebook-backend.onrender.com/). - Change the prefix to
wss://(e.g.wss://cpp-notebook-backend.onrender.com). - Add it to your
.envfile:VITE_REMOTE_RUNNER_URL=wss://cpp-notebook-backend.onrender.com
cd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
python server.pyTo protect servers hosting the remote backend, backend/server.py implements the following safeguards:
- Unprivileged User: The container runs under a locked-down
sandboxLinux user with zero superuser access. - CPU Limits: Terminated automatically if a C++ process consumes > 10 seconds of raw CPU time (stops infinite loops).
- Memory Caps: Capped at 128 MB RAM per execution to prevent out-of-memory crash attacks.
- Process Limits: Max 20 processes to protect against fork-bombs.
- Ephemeral Disk Cleaning: All compiled files, binaries, and source scripts are stored in temporary virtual directories and deleted instantly once execution ends.
This project is licensed under the MIT License - see the LICENSE file for details.
