Skip to content

A Google Docs–style real-time collaborative editor backend built with Node.js, Socket.IO, Redis Pub/Sub, and MongoDB. Supports horizontal scaling, Operational Transform (OT), and multi-user sync.

Notifications You must be signed in to change notification settings

randomfunction/RealTimeDoc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Real-Time Collaborative Editor Backend

A scalable, conflict-free real-time collaborative editing backend — inspired by Google Docs — built with Node.js, Socket.IO, Redis Pub/Sub, and MongoDB. Supports multiple concurrent users editing the same document with Operational Transform (OT) conflict resolution and multi-instance horizontal scaling.


Features

  • Real-Time Text Editing
  • Operational Transform (OT) conflict resolution
  • Redis Pub/Sub cross-server sync
  • MongoDB persistence with versioning
  • Supports multi-character insert/delete/paste
  • Ready for horizontal scaling and deployment

Tech Stack

Layer Tech
Server Node.js + Express
WebSocket Engine Socket.IO
State Sync Engine Operational Transform (Custom)
Pub/Sub Broker Redis
Database MongoDB + Mongoose
Frontend (Basic) HTML, CSS, JS

Getting Started

1. Clone the Repository

git clone https://github.com/yourusername/collab-editor-backend.git
cd collab-editor-backend

2. Install Dependencies

npm install

3. Start Redis & MongoDB

Using Docker:

# Redis
docker run --name redis -p 6379:6379 redis

# MongoDB
docker run --name mongo -p 27017:27017 mongo

Or install them locally if Docker is not preferred.

4. Run Multiple Servers

# Terminal 1
npx cross-env PORT=3000 node server.js

# Terminal 2
npx cross-env PORT=3001 node server.js

Open http://localhost:3000 and http://localhost:3001 in browser tabs to test real-time sync across servers.


Test It

  • Users joining the same docId will see each other’s edits in real time.
  • Edits propagate across servers via Redis.
  • Operational Transform ensures conflict-free syncing.

Future Plans

  • User Authentication & Role-based Access
  • Live Cursors & User Presence
  • Docker + Docker Compose Setup
  • Cloud Deployment on Render / Railway / EC2
  • Load Testing with 1000+ simulated users

Author

Tanishq Parihar B.Tech CSE (Data Science), IIIT Nagpur LinkedIn | GitHub


License

This project is licensed under the MIT License.

About

A Google Docs–style real-time collaborative editor backend built with Node.js, Socket.IO, Redis Pub/Sub, and MongoDB. Supports horizontal scaling, Operational Transform (OT), and multi-user sync.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published