Skip to content

Repository files navigation

C++ Notebook πŸ““βš‘

Build Status License: MIT Live Demo PRs Welcome Good First Issues

C++ Notebook Repo Card

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:

  1. Desktop Application: A local-first client built on Tauri, utilizing your machine's local g++ compiler.
  2. 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.

✨ Features

  • 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, and c++23 standards 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.

πŸ› οΈ Architecture

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++]
Loading

πŸš€ Local Development Setup

1. OS-Specific Prerequisites

To run or build the desktop version, your system needs Node.js, the Rust toolchain, and the g++ compiler installed.

πŸͺŸ Windows

  1. Node.js: Download and run the installer from Node.js Official Website.
  2. 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\bin to your Windows system Environment Variable PATH.
  3. 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.

🍎 macOS

  1. Node.js: Install via Homebrew: brew install node.
  2. 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.

🐧 Linux (Ubuntu / Debian)

  1. Node.js: Install via your package manager or NodeSource.
  2. 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
  3. Rust:
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

2. Getting Started

  1. Clone the Repository:

    git clone https://github.com/regionalduck/cpp-notebook.git
    cd cpp-notebook
  2. Install Dependencies:

    npm install
  3. Run Development Server:

    • For Web Version (Browser):
      npm run dev
    • For Desktop Application (Tauri):
      npm run tauri dev
  4. Build Production Packages:

    • Frontend Web Bundle:
      npm run build
    • Desktop App Binaries (macOS, Windows, Linux):
      npm run tauri build

🌐 Remote Backend Runner Deployment

The remote sandbox executor lives inside the /backend folder. It is designed to containerize and execute user code securely.

Quick Deploy to Render or Railway

This project is configured with a Dockerfile that works out-of-the-box on Render or Railway.

  1. Create a new Web Service pointing to your repository.
  2. Set the Root Directory to backend.
  3. The build system will automatically compile the Docker container, run the health check endpoint, and expose the WebSocket server.
  4. Copy your live URL (e.g. https://cpp-notebook-backend.onrender.com/).
  5. Change the prefix to wss:// (e.g. wss://cpp-notebook-backend.onrender.com).
  6. Add it to your .env file:
    VITE_REMOTE_RUNNER_URL=wss://cpp-notebook-backend.onrender.com

Running the Backend Locally

cd backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
python server.py

πŸ”’ Security Practices & Sandbox Limits

To protect servers hosting the remote backend, backend/server.py implements the following safeguards:

  • Unprivileged User: The container runs under a locked-down sandbox Linux 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.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A modern, interactive C++ notebook inspired by Google Colab and Jupyter. Compile & run C++ code cells, stream stdin/stdout in real-time, and configure C++17/20/23 standards.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Sponsor this project

Packages

Contributors

Languages