You don't need to merge this PR. I just wanted to share some of the boilerplate that I thought would be useful in this project.
I made quite a few changes when messing around with this.
New Packages:
yjs: This is a CRDT library. We will probably need to use CRDTs to store and sync text documents. This allows us to do so with edits from multiple sources concurrently.
socket.io-client: Pretty self-explanatory. We need a client to connect to the server web sockets.
Proposed architecture change:
I had some discussion with some of the folks in the backend thread about Frontend vs Backend page routing. While I think it makes more sense to do a MPA using backend routing, I realize that might not be very feasible since React is designed to make SPAs. That being said, we still need to serve the initial page with our backend. Hence lines 13-19 in app.py.
Build steps:
Now that we are delivering the initial page using Flask, npm run dev is not needed. you can just build the frontend and run Flask. Socket.IO also messes with the flask run command. Socket.IO won't work (at least from what I've seen) when ran with flask run. You can use python app.py instead to run the app.py file manually. I am not sure if there is a better way to do this. Maybe have a bash script that builds the frontend and runs the backend.
Let me know of any criticisms or things I can do better. Like I said this was just me messing around and getting to know the framework better. Currently this is a working real time "editor". You can have two clients and changes from one client affects the other.
You don't need to merge this PR. I just wanted to share some of the boilerplate that I thought would be useful in this project.
I made quite a few changes when messing around with this.
New Packages:
Proposed architecture change: I had some discussion with some of the folks in the backend thread about Frontend vs Backend page routing. While I think it makes more sense to do a MPA using backend routing, I realize that might not be very feasible since React is designed to make SPAs. That being said, we still need to serve the initial page with our backend. Hence lines 13-19 in app.py.
Build steps: Now that we are delivering the initial page using Flask,
npm run dev
is not needed. you can just build the frontend and run Flask. Socket.IO also messes with theflask run
command. Socket.IO won't work (at least from what I've seen) when ran withflask run
. You can usepython app.py
instead to run the app.py file manually. I am not sure if there is a better way to do this. Maybe have a bash script that builds the frontend and runs the backend.Let me know of any criticisms or things I can do better. Like I said this was just me messing around and getting to know the framework better. Currently this is a working real time "editor". You can have two clients and changes from one client affects the other.