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
  • 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
  • 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
  • rust playground integration

    rust playground integration

    this would be so cool with rust playground integration

    thank you very much

    opened by lucaszanella 1
  • Save file

    Save file

    So, how to save the edited file? Where it save the file?

    opened by Alsan 1
  • how long files in a link are available

    how long files in a link are available

    how long files in a link are available? I mean life time.

    opened by xerenahmed 1
  • Latex syntax

    Latex syntax

    Thank you for the amazing project

    is there a way to add more syntax like Latex?

    opened by a0ab1d3564 1
  • Feature request: save session in hard disk as a backup

    Feature request: save session in hard disk as a backup

    since all the sessions are live in RAM and they're expire after 24 hour or end of it, there's some problems when exit that session accidentally, so i believe save sessions in hard disk as a backup is useful feature at least there's a history of these sessions listed there.

    opened by annymosse 0
  • 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 3
  • 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 2
  • State Persistence for volatile deployments

    State Persistence for volatile deployments

    It appears that the current implementation keeps the state table in volatile memory (RAM) rather than committing it to disk. As such, deploying this in a scenario where the service's lifetime is not guaranteed (container orchestration, e.g. kubernetes) the state would be lost in an eviction scenario.

    It would be nice if there was a way to offload the state table into a somewhat more persistent datastore or use something like sqlite with a pvc in kubernetes to help maintain state.

    opened by PeterGrace 1
Owner
Eric Zhang
Student at Harvard University and competitive programmer, with research in machine learning & programming languages. @scaleapi, @NVIDIA, @HarvardPL
Eric Zhang
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.7k Jun 14, 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.5k Jun 13, 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 Jun 12, 2021
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 569 Jun 16, 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 42 Jun 13, 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 72 Jun 5, 2021
syntect is a syntax highlighting library for Rust that uses Sublime Text syntax definitions.

syntect is a syntax highlighting library for Rust that uses Sublime Text syntax definitions. It aims to be a good solution for any Rust project that needs syntax highlighting, including deep integration with text editors written in Rust.

Tristan Hume 1k Jun 14, 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 Jun 12, 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 31 Mar 5, 2021
Rust :heart: Emacs

Rust ❤️ Emacs A community-driven port of Emacs to Rust. Table of Contents Why Emacs? Why Rust? Why A Fork? Getting Started Requirements Dockerized dev

Remacs 4.5k Jun 15, 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 498 May 31, 2021
Command line tool for inspecting Parquet files

pqrs pqrs is a command line tool for inspecting Parquet files This is a replacement for the parquet-tools utility written in Rust Built using the Rust

Manoj Karthick 23 May 14, 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 119 Jun 8, 2021