Ignore authenticaion and authorization
Define the APIs expected from the system. This is your chance to analyze and define the read and write paths so that you can come up with the high-level design...
1) POST /doc -> It is used to create a document with doc1 id
{
documentId:"doc1"
}
WS /docs/{docId}
SEND {
type: "insert"
....
}
SEND {
type: "updateCursor"
position: ...
}
SEND {
type: "delete"
...
}
RECV {
type: "update"
...
}
Describe the overall system architecture. Identify the main components needed to solve the problem end-to-end. Use the diagramming tool to create a block diagram.
Each user makes a call to load balancer which then makes a call to api gateway the for createing a document we will make a post call to document Metadata Service for creating the document then we make a websocket connection to document service for establing a websocket connection between the user and document service we can use the consitent hashing to map each document to the correct server to make sure each user who is trying to edit the document lands on to the same server.
once webscoket connection is established and the data is sent throught the webosocket connection for each document we will be sending the edits to the server not the whole document from time to time the and will be storing this edits in cassandra the cassandra the cassandra will have docid as partioning key and time as the sort key in order to revert the change can just read the operations in decesnding order for that user and revert the doc for adding the comment user can make the call to document service similar to normal opeation and store the comment in document Comment Db with the commentDetail, cellId and userid who posted the comment.
For conflict resloution there are two types of conflict resolution one is OT and other is CRDTS in ot each document makes changes to it's operation if there are any changes in other operation for example is user is trying to edit poisition 5 at the same time another user is trying to add text "hello"something at the same place then first operation is transformed to edit(10)
there is one more datastrucure called CRDT i will not go in detail to it when we try to insert a word on a same positioin the order will be decided based on the userId of the user who have insereted
We are going to use OT to manage real-time collaboration and user presentce
we are going use consistent hashing to scale the websocket servers.
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.
Each user makes a call to load balancer which then makes a call to api gateway the for createing a document we will make a post call to document Metadata Service for creating the document then we make a websocket connection to document service for establing a websocket connection between the user and document service we can use the consitent hashing to map each document to the correct server to make sure each user who is trying to edit the document lands on to the same server.
once webscoket connection is established and the data is sent throught the webosocket connection for each document we will be sending the edits to the server not the whole document from time to time the and will be storing this edits in cassandra the cassandra the cassandra will have docid as partioning key and time as the sort key in order to revert the change can just read the operations in decesnding order for that user and revert the doc for adding the comment user can make the call to document service similar to normal opeation and store the comment in document Comment Db with the commentDetail, cellId and userid who posted the comment.
For conflict resloution there are two types of conflict resolution one is OT and other is CRDTS in ot each document makes changes to it's operation if there are any changes in other operation for example is user is trying to edit poisition 5 at the same time another user is trying to add text "hello"something at the same place then first operation is transformed to edit(10)
there is one more datastrucure called CRDT i will not go in detail to it when we try to insert a word on a same positioin the order will be decided based on the userId of the user who have insereted
We are going to use OT to manage real-time collaboration and user presentce
we are going use consistent hashing to scale the websocket servers.
For handling duplicate edits we can assign a unique id to each edit based on document.