Skip to content

Conversation

ncduy0303
Copy link

@ncduy0303 ncduy0303 commented Oct 11, 2025

Collaboration Service Implementation

This PR introduces a collaboration service backend that enables real-time collaborative coding sessions with persistent document storage using Y.js and MongoDB.

Data Schema

Room Model

{
  room_id: string,
  question_id: string,
  user_ids: string[],
  programmingLanguage: enum,
  isActive: boolean,
  created_at: timestamp,
  updated_at: timestamp,
  closed_at: timestamp
}

Y-doc Storage

  • Each room's document stored as MongoDB collection (room_id = collection name)
  • Real-time updates persisted as individual documents in the collection
  • Full document reconstruction by combining all deltas

API Endpoints

REST API

Method Endpoint Description
POST /api/v1/rooms Create new collaboration room
GET /api/v1/rooms/:roomId Get room details + latest document
PATCH /api/v1/rooms/:roomId/close Close room (irreversible)
PATCH /api/v1/rooms/:roomId/language Change programming language

WebSocket Events

Event Direction Description
connect/disconnect Client -> Server User join/leave room
room-close-notification Server -> Client Broadcast room closure
language-change-notification Server -> Client Broadcast language change

Notes

  • Dockerized service and Github Actions CI/CD pipeline
  • Dual port exposure (HTTP:8003, WebSocket:8004)
  • Y-MongoDB provider for document persistence
  • Y.js documents for Monaco Code Editor (can be switched to other code editor libraries depending on our Front End)
  • Rooms are closed automatically after period of inactivity (i.e. no connected clients for 10 minutes)

Things to do next after this PR

  • Integrate collaboration service into front end.
  • Add authentication

…with Y.js real-time editing

- Add Room schema with Y-doc integration for collaborative editing
- Implement REST API for room management (create, get, close, language change)
- Add WebSocket server for real-time collaboration events
- Set up Y.js MongoDB provider for persistent document storage
- Add Docker configuration and CI/CD pipeline
- Configure dual-server architecture (HTTP:8003, WebSocket:8004)

API Endpoints:
- POST /api/v1/rooms - Create collaboration room
- GET /api/v1/rooms/:roomId - Get room details and document content
- PATCH /api/v1/rooms/:roomId/close - Close room collaboration
- PATCH /api/v1/rooms/:roomId/language - Change programming language

WebSocket Events:
- connect/disconnect - User join/leave room
- room-close-notification - Broadcast room closure
- language-change-notification - Broadcast language updates
Copy link

@DanielJames0302 DanielJames0302 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@DanielJames0302 DanielJames0302 merged commit dbe1db1 into dev Oct 14, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants