A real-time collaborative document editor built with React, Node.js, Socket.IO, and Operational Transformation (OT).
- Real-time collaborative editing with multiple users
- Operational Transformation for conflict resolution
- User authentication with JWT
- Document management (create, list, edit)
- Rich text editing with Quill
- WebSocket-based synchronization
- React 18 + TypeScript
- Vite
- Redux Toolkit
- Quill Editor
- Socket.IO Client
- React Router
- Node.js + Express + TypeScript
- MongoDB (document storage)
- Redis (session management)
- Socket.IO (real-time communication)
- JWT authentication
- Operational Transformation engine
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher)
- MongoDB (v6 or higher)
- Redis (v7 or higher)
- npm or yarn
# Install server dependencies
cd server
npm install
# Install client dependencies
cd ../client
npm installcd server
cp .env.example .envEdit server/.env with your configuration:
PORT=5000
MONGO_URI=mongodb://localhost:27017/gdocs
REDIS_URL=redis://localhost:6379
JWT_SECRET=your_super_secret_jwt_key_here
CLIENT_ORIGIN=http://localhost:5173cd client
cp .env.example .envEdit client/.env:
VITE_API_URL=http://localhost:5000/api
VITE_SOCKET_URL=http://localhost:5000# Windows (if installed as service)
net start MongoDB
# Or using mongod directly
mongod --dbpath C:\data\db
# macOS/Linux
brew services start mongodb-community
# or
sudo systemctl start mongod# Windows (using WSL or Redis for Windows)
redis-server
# macOS
brew services start redis
# Linux
sudo systemctl start rediscd server
npm run devServer will run on http://localhost:5000
cd client
npm run devClient will run on http://localhost:5173
- Open http://localhost:5173 in your browser
- Register a new account or login
- Create a new document or open an existing one
- Share the document URL with others to collaborate in real-time
- Start editing - changes will sync automatically across all connected users
├── client/ # React frontend
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── hooks/ # Custom hooks
│ │ ├── pages/ # Page components
│ │ └── store/ # Redux store
│ └── package.json
│
├── server/ # Node.js backend
│ ├── src/
│ │ ├── middleware/ # Express middleware
│ │ ├── models/ # MongoDB models
│ │ ├── routes/ # API routes
│ │ ├── services/ # Business logic
│ │ └── socket/ # Socket.IO handlers
│ └── package.json
│
└── README.md
POST /api/auth/register- Register new userPOST /api/auth/login- Login user
GET /api/docs- List all documentsPOST /api/docs- Create new documentGET /api/docs/:id- Get document by IDPUT /api/docs/:id- Update documentDELETE /api/docs/:id- Delete document
join-document- Join a document roomsend-operation- Send editing operationleave-document- Leave document room
document-loaded- Initial document datareceive-operation- Receive operation from other usersuser-joined- User joined the documentuser-left- User left the document
cd server
npm run build
npm startcd client
npm run build
npm run preview- Ensure MongoDB is running:
mongod --version - Check connection string in
.env - Verify database path exists
- Ensure Redis is running:
redis-cli ping(should return PONG) - Check Redis URL in
.env
- Change PORT in
server/.env - Update VITE_API_URL and VITE_SOCKET_URL in
client/.env
- Ensure server is running before client
- Check CORS settings in
server/src/app.ts - Verify CLIENT_ORIGIN matches your client URL
# Set JWT secret
echo "JWT_SECRET=$(openssl rand -base64 32)" > .env
# Start all services
docker-compose up -d
# View logs
docker-compose logs -fAccess the application:
- Frontend: http://localhost:3000
- Backend: http://localhost:5000
See DEPLOYMENT.md for detailed deployment instructions including:
- Docker deployment
- Manual deployment
- Cloud deployment (AWS, Heroku, DigitalOcean)
- Nginx configuration
- SSL setup
- Scaling strategies
Before deploying to production:
- Change JWT_SECRET to a strong random value
- Configure CORS with your frontend domain
- Enable HTTPS/SSL
- Set up MongoDB authentication
- Configure Redis password
- Set up monitoring and logging
- Configure automated backups
- Test disaster recovery
MIT