For the bi-directional communication between the user and the system (edit doc from user and sync update to user), we need to use WebSocket.
CreateDoc:
POST /doc {
"user_id": "123",
"create_time": datetime,
"title": "XXXX",
"format": "WORD" | "EXCEL" | "PPT".
} -> return a doc object with doc id, and save to the database
ViewDoc:
GET /doc/:doc_id -> query the database and render the doc content to users
EditDoc:
PATCH /doc {
"user_id": "123",
"doc_id": "456",
"time": datetime,
"content": "XXXXX",
} -> update doc content to the database and sync to all collaborators
Invite:
POST /invite {
"user_id": "123",
"doc_id": "456",
"time": datetime,
"invitees": [
"invitee_id": "789",
"permission": "VIEW" | "EDIT" | "DOWNLOAD",
]} -> add invitees to the ACL of the doc and also update the database
Client:
API gateway:
Doc server:
ACL server:
S3 blob storage:
Cache:
Database:
User {
"id": str, - primary key
"name": str, - index
"create_time": datetime,
"docs": List of doc ids }
Doc {
"id": str, - primary key
"title": str, - index
"content": str,
"create_time": datetime,
"media_links": [] of S3 link to media files
"ACL": [{
"user_id": str,
"permission": "VIEW" | "EDIT" | "DOWNLOAD",
}]}
With 200M doc per day, the total database storage is 200M * 5MB * 365 * 3 = 1000PB in 3 years.