Open nelimee opened 1 month ago
Note: to avoid loosing valuable comments, I copy-paste comments from #239 here
From https://github.com/QCHackers/tqec/pull/239#issuecomment-2129690761 (@Gistbatch):
Just as a reminder: We already had a Flask server in place, which was initially set up by @smburdick, and the front end has some unused functionality. The file server root is in
/web/main.py
, also deployed to gcloud. I don't have any strong preference betweenflask
andfastapi
, and most of the concepts are very similar.
- From a dev perspective, we might eventually think about hosting a proper database, which is straightforward with Pydantic.
- If we plan to host the backend and the frontend on different sites, we also need to enable
CORS
- We should start to think about what information needs to be transferred at which points in time
- Also we should set up a proper structure for the webserver
As an alternative, there is also
GraphQL
which can be used to query data in a different way, I don't think it's useful for our purposes though.
From https://github.com/QCHackers/tqec/pull/239#issuecomment-2133295164 (@nelimee):
I have no personal preference on that. As I already said multiple times, I am not competent for web-related development task (and I try to stay as far away as possible from anything related to web-technologies).
My choice of
pydantic
+fastapi
was based on the easy of use ofpydantic
and the ultra-fast integration offastapi
once you havepydantic
models in place. There is really no smart thinking that happened on my side, an I will adopt whatever is judged to be the best solution by others.Let's consider this PR as a playground to start exploring the integration between the frontend and backend, and see what is required from both sides. At any time (if possible, early), if the choice of
pydantic
+fastapi
seems worse than another library, please tell me, or change the framework directly.
From https://github.com/QCHackers/tqec/pull/239#issuecomment-2134718323 (@Gistbatch):
I'm very much in favor of FastAPI because I have worked with it before. I think
pydantic
also works withflask
anddjango
.
Note: replaces #239
This is a draft PR trying to implement a REST server on the backend side.
This is the initial implementation that will allow a link between the frontend and the backend.
Currently, the idea is the following: all the QEC-related state is stored in the backend and the frontend is making requests through the provided REST API to 1. query the current QEC state or 2. change it. Here, "QEC-related state" means that:
Because we want to avoid a communication at each user inputs, the frontend may store partial state.
Note that everything I wrote above and the code from this PR is a proposal, I am very much open to any other idea if it turns out to be easier to use.
To use the code from that PR and experiment with the REST server, follow the instructions:
tqec
package to get the new dependenciesor install the added dependencies directly
Related issues:
170: if the decision to pursue in the direction explained above is taken, the backend will be responsible for that, and already implement the feature.
169: the backend would become responsible for the generation of the file, the frontend will still need to provide a way to save the file to the user.
61: nicely handled by using
pydantic
and implementing methods to convert from/to the definedpydantic.BaseModel
.38: the main related issue, this PR try to fix #38.
18: this PR introduces the possibility to export to Stim files, and so should fix that issue.