I am creating a platform which allows multiple users to edit a file simultaneously and I was wondering if using a web server with routes could be the correct architecture for this goal. I am trying to achieve something similar to Figma or Google Docs, where they allow multiple users to edit a single file concurrently.
My current idea is to have a server with an file system for each group of user (through a virtual machine or a container). Then I could have a route for editing a file (like for example
/edit) where, with a POST request having the file path and a JSON for the edit as the parameters, an user can "append" an edit to a file. For example, a request could be like this:
{
"path": "/files/file1.txt",
"edit": {
"type": "insert",
"pos": 0,
"data": "Hello, world!"
}
}
In this way, I could also check if an user has the permissions necessary to edit the file by validating the request with a guard to the edit route through an auth provider like auth0.
Additionally, for reading the files, I was thinking of similarly doing an initial GET request for the file when an user initially opens it and then automatically sending any edit to the file to users which have the file open.
I am not sure however if using plain routes and simple POST/GET request is the correct way of dealing with this issue.
I am new to backend development so I am worried I could be re-inventing the wheel (and a bad one at that) when a framework for this kind of app already exists. However, I tried looking online but I could not find anything that matches what I am trying to achieve.
Is this a valid/canonical approach for achieving edits to a file on a server?
pathattribute won't be sufficient. You will also need a serial, timestamp, hash, or similar to identify each specific revision. Using GET to read & render the document is fine. For mutation there's more than one web verb that may be relevant.