0

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?

3
  • Can you clarify what problem you are trying to solve? Asking "how to allow multiple users to edit a file" is way too broad for this community. Commented Mar 24, 2023 at 12:18
  • Thanks for the feedback, I edited the question. I hope is clearer now. the part I am stuck on is whether using plain POST/GET requests and routes is the canonical way of achieving file edits on a remote file. I removed the multi-user part as it is not the subject of the question and I initially added it to provide more context to the question. Commented Mar 24, 2023 at 12:32
  • The path attribute 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. Commented Mar 24, 2023 at 18:41

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.