Skip to main content
  1. Posts/

P2PDocs: A Decentralized Collaborative Editor

Author
Virgola
AI & Cybersecurity Student @ University of Udine X University of Klagenfurt.
Go enthusiast & CTF player @ Madrhacks
Table of Contents

P2PDocs is a peer-to-peer collaborative text editor developed for the Distributed Systems course at the University of Udine. The project explores how decentralized systems can handle real-time collaboration with consistency, conflict resolution, and offline-first operation.

Project Overview
#

P2PDocs Logo

The goal of P2PDocs was to implement a fully decentralized editor where multiple peers can simultaneously edit documents. Core distributed algorithms were implemented and evaluated, including:

  • Conflict-Free Replicated Data Types (CRDTs) for automatic conflict resolution
  • Causal Broadcast for ordered message delivery
  • Offline-first collaboration to allow peers to work without a central server

The system provides a hands-on demonstration of real-world challenges in distributed systems: network partitions, concurrency, and fault tolerance.


Technical Contributions
#

1. LSEQ CRDT Implementation
#

We adopted the LSEQ strategy to preserve user intention across peers:

  • Position Vectors: Rational numbers for dense ordering
  • Peer-ID Tagging: Resolve concurrent edits
  • AVL Order-Statistic Tree: Efficient O(log n) insertions and deletions

2. Network Layer
#

  • Echo-Wave Protocol for reliable operation propagation
  • Neighbor Handshake for joining peer synchronization
  • Crash Recovery with ETS (Erlang Term Storage) for persistence

3. Testing & Validation
#

  • Unit Tests with ExUnit
  • Multi-Node Testing using Docker to simulate network partitions and node failures:
  ./start_n_instances_for_tests.sh 5  # Launch 5 peers
  ./disconnect.sh 2                   # Simulate node failure

Team
#

Distributed Systems Course Project

Stack: Elixir, Node.js, Docker


Future Work
#

Based on our final report, future improvements could include:

  1. Markdown support for rich text editing
  2. Real-time cursor tracking
  3. Optimized vector clock size for performance

Learn More
#

For a technical deep dive, including full CRDT implementation details, network protocol design, and system validation, see the Project Report.

Explore the Code: GitHub

Related