Skip to content

SMFEH323/KISE-Docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KISE Docs - Peer-to-Peer Collaborative Text Editor

Overview

This project is a peer-to-peer collaborative text editor built in Python. It allows multiple peers to edit a shared document while synchronizing changes across connected nodes.

The goal of this project was to understand distributed systems, document synchronization, and conflict handling by implementing a simple collaborative editor using an RGA-style data structure.


Features

  • Peer-to-peer communication using sockets
  • Real-time document editing
  • Insert and delete operations
  • Operation history tracking
  • Synchronization with multiple peers
  • Support for offline editing
  • Tombstone-based deletion
  • Basic conflict handling using unique operation IDs
  • Simulated network delay and message loss

How It Works

Each peer runs its own server and can connect to other peers.

When a user edits the document, the operation is:

  1. Given a unique ID
  2. Applied locally
  3. Stored in operation history
  4. Broadcast to connected peers

The document is stored as a list of characters with unique IDs. Deleted characters are marked as tombstones before cleanup.


Tech Stack

  • Python
  • Socket Programming
  • Threading
  • JSON
  • Basic CRDT/RGA concepts

Main Commands

add        # Add a peer
edit       # Insert or delete a character
view       # View current document
save       # Save document to a file
sync       # Sync with connected peers
reconnect  # Request missing operations
peers      # Show connected peers
exit       # Exit program

Example Operation

Insert Operation

{
  "type": "insert",
  "position": 3,
  "character": "A",
  "uid": [1234567890, "user1"]
}

Delete Operation

{
  "type": "delete",
  "uid": [1234567890, "user1"]
}

Current Limitations

  • Command-line interface only
  • No permanent network discovery
  • Basic conflict resolution
  • No authentication between peers
  • Uses eval() for delete input, which should be replaced for safety

Future Improvements

  • Add a graphical interface
  • Improve conflict resolution
  • Replace eval() with safer input parsing
  • Add peer authentication
  • Add automatic peer discovery
  • Improve document merge ordering

What This Project Demonstrates

  • Understanding of peer-to-peer systems
  • Basic distributed document synchronization
  • Socket programming in Python
  • Concurrent programming with threads
  • CRDT-style thinking using tombstones and operation IDs

Releases

No releases published

Packages

 
 
 

Contributors

Languages