Welcome to the Collaborative Editor Backend — the powerful engine behind real-time document editing, syncing user edits instantly using WebSockets, Java Spring Boot, and MongoDB.
🖥️ This is the Backend (API + WebSocket) of the project. Find the frontend here: Collaborative Editor UI
🚀 Backend deployed on Render (https://collabeditor-bsua.onrender.com)
Backend:
- ☕ Java 17
- ⚙️ Spring Boot
- 🔄 Spring WebSocket (
TextWebSocketHandler) - 🧠 Jackson (for JSON parsing)
- 💾 MongoDB (document persistence)
- 🌐 Deployed via Render
- 🔄 Real-time WebSocket connections for collaborative editing
- 🔗 Join sessions with unique document URLs
- 👥 Multi-user document editing support
- 💬 Commenting system
- 🧠 Username-based session tracking
- ❌ Handles unexpected disconnects gracefully
- 🛑 Smart validation and error handling
com.thughari.collabeditor ├── websocket/ │ └── EditorWebSocketHandler.java // Handles all WebSocket communication ├── service/ │ └── WebSocketService.java // Session management, message handling ├── model/ // Document model └── CollabEditorApplication.java // Main Spring Boot application git clone https://github.com/thughari/CollabEditor.git cd CollabEditorMake sure MongoDB is running locally and update the connection URI in src/main/resources/application.properties:
spring.data.mongodb.uri=mongodb://localhost:27017/collabeditor./mvnw spring-boot:run💡 Default port is
8080.
Connect via WebSocket to:
ws://localhost:8080/ws/editor/{documentId} Example with Angular:
new WebSocket('ws://localhost:8080/ws/editor/abc123');{ "type": "join", "payload": { "documentId": "abc123", "username": "Hari" } }{ "type": "edit", "payload": { "documentId": "abc123", "content": "Hello world!" } }{ "type": "comment", "payload": { "documentId": "abc123", "comment": { "text": "Add a heading here", "position": 5 } } }Sessions are automatically cleaned up when:
- WebSocket is closed
- Invalid message or document ID
- Network disconnect
- Start MongoDB locally
- Run backend with
./mvnw spring-boot:run - Launch frontend at
http://localhost:4200 - Open in multiple tabs and watch edits sync in real time!
We welcome improvements to the backend logic or performance! To contribute:
git checkout -b fix/session-bug git commit -m "Fix session handling bug" git push origin fix/session-bugOpen a Pull Request ✅
Hari Thatikonda 📫 LinkedIn | GitHub
MIT — use it freely, improve it collaboratively.