Rustpad is an efficient and minimal collaborative code editor, self-hosted, no database required

Overview

Rustpad

Rustpad is an efficient and minimal open-source collaborative text editor based on the operational transformation algorithm. It lets users collaborate in real time while writing code in their browser. Rustpad is completely self-hosted and fits in a tiny Docker image, no database required.


rustpad.io

The server is written in Rust using the warp web server framework and the operational-transform library. We use wasm-bindgen to compile text operation logic to WebAssembly code, which runs in the browser. The frontend is written in TypeScript using React and interfaces with Monaco, the text editor that powers VS Code.

Architecturally, client-side code communicates via WebSocket with a central server that stores in-memory data structures. This makes the editor very fast, allows us to avoid provisioning a database, and makes testing much easier. The tradeoff is that documents are transient and lost between server restarts, or after 24 hours of inactivity.

Development setup

To run this application, you need to install Rust, wasm-pack, and Node.js. Then, build the WebAssembly portion of the app:

wasm-pack build rustpad-wasm

When that is complete, you can install dependencies for the frontend React application:

npm install

Next, compile and run the backend web server:

cargo run

While the backend is running, open another shell and run the following command to start the frontend portion.

npm start

This command will open a browser window to http://localhost:3000, with hot reloading on changes.

Testing

To run integration tests for the server, use the standard cargo test command. For the WebAssembly component, you can run tests in a headless browser with

wasm-pack test rustpad-wasm --chrome --headless

Deployment

Rustpad is distributed as a single 12 MB Docker image, which is built automatically from the Dockerfile in this repository. You can pull the latest version of this image from Docker Hub.

docker pull ekzhang/rustpad

(You can also manually build this image with docker build -t rustpad . in the project root directory.) To run locally, execute the following command, then open http://localhost:3030 in your browser.

docker run --rm -dp 3030:3030 ekzhang/rustpad

We deploy a public instance of this image using DigitalOcean App Platform.


All code is licensed under the MIT license.
Issues
  • Changing hour and day values for cleanup

    Changing hour and day values for cleanup

    Hey!

    I saw that rustpad has fixed values for the cleanup intervals:

    https://github.com/ekzhang/rustpad/blob/64d0b632ac72143c4e94fce1ecaf5db94bb90547/rustpad-server/src/lib.rs#L82-L83

    I think it would be nice to make them configurable via dotenv or any other solution. Do you think it's applicable? If so, I'd like to submit a PR.

    opened by orhun 6
  • Third-party websocket client

    Third-party websocket client

    I would love to use rustpad for my hardware live coding project. Is it possible to connect a third-party client via WebSocket to rustpad? If you can point me to any examples or resources it would be great.

    Thank you.

    opened by curiouswala 6
  • Add dark mode functionality

    Add dark mode functionality

    Closes #1

    opened by SphericalKat 4
  • Docker container SSL certificates

    Docker container SSL certificates

    Hey!

    I'm using the given example command from README.md to run a rustpad instance on my server:

    docker run --rm -dp 3030:3030 ekzhang/rustpad
    

    But unfortunately I couldn't figure out how to enable SSL for the running instance. I have certificates on my server and I tried to give net access to the container but no luck. What am I supposed to do here?

    I think It'd be nice to mention such case in the documentation.

    opened by orhun 3
  • Enable state persistence through SQLite

    Enable state persistence through SQLite

    Summary

    We add a new environment variable, SQLITE_URI, to Rustpad. When this is set to a connection string (e.g., sqlite://rustpad.db), Rustpad's behavior will change to automatically persist documents to the database, every 3 seconds, if there has been a change. These documents will remain between server restarts and after documents are automatically cleaned from in-memory data structures due to inactivity, which provides some form of file system-based persistence.

    This resolves #6.

    opened by ekzhang 3
  • Output logs to Docker

    Output logs to Docker

    Apologies if I'm barking up the wrong tree - but for some reason when I'm running this in a Docker container, I can't see any log messages in /var/log/docker.log relating to rustpad. The Rustpad web app itself works fine.

    Context: I'm running the dockerized image straight from https://hub.docker.com/r/ekzhang/rustpad. The environment is Unraid v6.9.2 with Docker v20.10.5

    opened by huiguang-liang 3
  • Connecting to server issue when using reverse proxy

    Connecting to server issue when using reverse proxy

    I'm using a reverse proxy for SSL and when I open rustpad, it always tell me that it's connecting to server, which it never does. Any help?

    Using NGINX for reverse proxy Using Cloudflare for SSL Provider

    opened by AzamServer 2
  • Set <Editor/> fontSize as configurable or docker environment parameter

    Set fontSize as configurable or docker environment parameter

    At present, for HiDPI displays, the editor fontsize is a little too small. After inspecting the source I see that the fontSize is hardcoded.

    <Editor
        theme={darkMode ? "vs-dark" : "vs"}
        language={language}
        options={{
            automaticLayout: true,
            fontSize: 13,
        }}
        onMount={(editor) => setEditor(editor)}
    />
    

    Is it possible to expose this fontSize setting as a Docker environment variable?

    opened by huiguang-liang 2
  • Trouble connecting with Nginx to Docker instance

    Trouble connecting with Nginx to Docker instance

    I have my docker instance of rustpad running on port 3030, and it connects just fine when specifying the port number. However, when I attempt to use Nginx to reverse proxy, it's failing to sync to the server.

    I see nothing indicating an error in the web socket connection. It does several retries and then ultimately fails. I also see no errors in the JS console or the docker log console.

    Is it merely an issue with nginx not passing certain headers?

    image

    opened by binarydad 2
  • Dark mode

    Dark mode

    A dark mode, possibly based on the prefers-color-scheme media query, would be nice! Given that this uses Monaco, leveraging some existing theme should be fairly straightforward.

    opened by linusg 2
Owner
Eric Zhang
Student at Harvard University and competitive programmer, with research in machine learning & programming languages. @scaleapi, @NVIDIA, @HarvardPL
Eric Zhang
A text editor in ≤1024 lines of code, written in Rust

Kibi: A text editor in ≤1024 lines of code, written in Rust A configurable text editor with UTF-8 support, incremental search, syntax highlighting, li

Ilaï Deutel 676 Nov 24, 2021
An opinionated modal editor to simplify code editing from the terminal

(I'm currently refactoring the platform layer. So we have to first finish this cleanup before we're able to continue adding features) An opinionated m

Matheus Lessa Rodrigues 129 Nov 26, 2021
A package manager for the Lite-XL code editor

Lite-XL Package Manager (lpm) (Under Development) lpm is an attempt to create a package manager for the Lite-XL code editor. It's primary goal is to p

Debarchito Nath 7 Nov 26, 2021
My own personal code editor built with Rust + OpenGL

Glyph This is my personal code editor that I am building for fun and to get more familiar with OpenGL. Glyph currently supports Vim keybinds, syntax h

Zack Radisic 27 Nov 23, 2021
Borderlands 3 Save/Profile Editor for Windows/MacOS and Linux!

Borderlands 3 Save Editor A tool to help you modify your Borderlands 3 Saves and Profiles. Currently it runs on Windows, Mac OS and Linux. It supports

Zak 94 Nov 29, 2021
A terminal-based text editor written in Rust

Iota Iota is a terminal-based text-editor written in Rust. Here's what it looks like right now, editing itself. Motivation Iota was born out of my fru

Greg Chapple 1.5k Nov 25, 2021
Aspiring vim-like text editor

Rim Rim is an aspiring Vim-like text editor written in Rust. Current state Rim is in an early prototype stage. This means that you can load, edit and

Mathias Hällman 509 Nov 25, 2021
An independent Rust text editor that runs in your terminal!

Ox editor Ox is a code editor that runs in your terminal. About The Project Ox is a code editor. It was written in Rust using ANSI escape sequences. I

null 2.6k Nov 28, 2021
A modern editor with a backend written in Rust.

Xi Editor (pronounced "Zigh") A modern editor with a backend written in Rust. Maintenance status: The xi-editor project is not currently under active

null 18.8k Nov 24, 2021
An experimental next-generation Electron-based text editor

Attention: GitHub has decided not to move forward with any aspect of this project. We'll archive the repository in case anybody finds value here, but

Atom Archive 8.6k Nov 29, 2021
Web base text editor written in rust

Ultron Ultron is a web based monospace text-editor with syntax highlighting, completely written in rust. I wrote this code editor for my very specific

Jovansonlee Cesar 57 Nov 17, 2021
A save editor for Mass Effect Trilogy

Trilogy Save Editor A save editor for Mass Effect Trilogy A bit late but just in time ! This software is similar to Gibbed's save editors (and forks)

Karlitos 79 Nov 7, 2021
ReVi is a cross-platform terminal based Vim inspired text editor.

ReVi Table Of Contents: About Usage Install Clone && Installing Development Q&A KeyBindings Roadmap Changelog About ReVi is a cross-platform terminal

null 21 Sep 12, 2021
Rust-based traffic editor for RMF

Traffic Editor III Welcome to Traffic Editor III. install stuff Unfortunately we need a newer Rust than what comes with Ubuntu 20.04. First make sure

null 1 Nov 24, 2021
A fast and small Rust library to make Electron apps more secure.

electron-hardener A Rust library and command line tool to harden Electron binaries against runtime behavior modifications. This provides a way to hard

1Password 316 Nov 24, 2021
A (self hosted) pastebin for easily sharing text right from the terminal

termpad termpad allows you to easily host a pastebin server for saving and viewing text right from the terminal, or the browser. Client Usage Assuming

Spyros Roum 23 Sep 28, 2021
A self-hosted Fuzzing-As-A-Service platform

OneFuzz A self-hosted Fuzzing-As-A-Service platform Project OneFuzz enables continuous developer-driven fuzzing to proactively harden software prior t

Microsoft 2.4k Nov 21, 2021
🎧 a self-hosted Spotify → Discord music bot

Aoede is a Discord music bot that directly streams from Spotify to Discord. The only interface is Spotify itself. Note: a Spotify Premium account is c

Max Isom 84 Nov 16, 2021
Octopus Linguistics for self-hosted runners

octoling Octopus Linguistics for self-hosted runners. Early PoC Allows to create self-hosted ephemeral runners on various providers. (currently only s

Mary 5 Nov 1, 2021
Marko Editor is a simple WYSIWYG editor for note taking.

Marko Editor Marko Editor is a simple WYSIWYG editor for note taking written in Rust and GTK 4. It uses Markdown as storage format and can read simple

Michael 38 Nov 16, 2021
TIF is a terminal_image_format. (theres no TIF editor, so i made TIF images through a hex editor lol)

Colors these are the colors you can use when displaying images on the terminal BYTES: 5A = BLUE 5B = BLACK 5C = RED 5D = GREEN 5E = PURPLE 5F = WHITE

buzz 2 Nov 21, 2021
A web service that generates images of dependency graphs for crates hosted on crates.io

crate-deps A web service that generates images of dependency graphs for crates hosted on crates.io This project is built entirely in Rust using these

Corey Farwell 20 Nov 9, 2020
A text editor in ≤1024 lines of code, written in Rust

Kibi: A text editor in ≤1024 lines of code, written in Rust A configurable text editor with UTF-8 support, incremental search, syntax highlighting, li

Ilaï Deutel 676 Nov 24, 2021
An opinionated modal editor to simplify code editing from the terminal

(I'm currently refactoring the platform layer. So we have to first finish this cleanup before we're able to continue adding features) An opinionated m

Matheus Lessa Rodrigues 129 Nov 26, 2021
A package manager for the Lite-XL code editor

Lite-XL Package Manager (lpm) (Under Development) lpm is an attempt to create a package manager for the Lite-XL code editor. It's primary goal is to p

Debarchito Nath 7 Nov 26, 2021
My own personal code editor built with Rust + OpenGL

Glyph This is my personal code editor that I am building for fun and to get more familiar with OpenGL. Glyph currently supports Vim keybinds, syntax h

Zack Radisic 27 Nov 23, 2021
Minimal, flexible framework for implementing solutions to Advent of Code in Rust

This is advent_of_code_traits, a minimal, flexible framework for implementing solutions to Advent of Code in Rust.

David 5 May 27, 2021
🚀Memory safe, blazing fast, configurable, minimal hello world written in rust(🚀) in a few lines of code with few(1092🚀) dependencies🚀

?? hello-world.rs ?? ?? Memory safe, blazing fast, minimal and configurable hello world project written in the rust( ?? ) programming language ?? ?? W

mTvare 1.2k Nov 29, 2021
Tiny, no-nonsense, self-contained, Tensorflow and ONNX inference

Sonos' Neural Network inference engine. This project used to be called tfdeploy, or Tensorflow-deploy-rust. What ? tract is a Neural Network inference

Sonos, Inc. 1.1k Nov 26, 2021