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.
- 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
Each peer runs its own server and can connect to other peers.
When a user edits the document, the operation is:
- Given a unique ID
- Applied locally
- Stored in operation history
- Broadcast to connected peers
The document is stored as a list of characters with unique IDs. Deleted characters are marked as tombstones before cleanup.
- Python
- Socket Programming
- Threading
- JSON
- Basic CRDT/RGA concepts
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{
"type": "insert",
"position": 3,
"character": "A",
"uid": [1234567890, "user1"]
}{
"type": "delete",
"uid": [1234567890, "user1"]
}- 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
- Add a graphical interface
- Improve conflict resolution
- Replace
eval()with safer input parsing - Add peer authentication
- Add automatic peer discovery
- Improve document merge ordering
- 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