Hi everyone,
We're in the process of restructuring our project: we have a mandate to do so in 1 month π
The ultimate goal is to:
β simplify our product,
β correct the rookie mistakes we made (not using Remix as a BFF, reduce our dependencies footprint, etc.),
β prepare for the future (we would like to develop a native application in mid-term).
In practice, we are going to have an intermediary API layer:
β authenticated cookie would be reduced to a sessionId/token (kind of the same, right?),
β this sessionId will be used in every API call to identify the user, assess if he has the correct role, and return data accordingly.
β loaders/actions in Remix will not query the DB directly, but rather fetch the API endpoints with the sessionId (BFF !!)
β this way, the native application will easily plug to the same API.
Now the question is: how will the overall architecture looks like?
I'm thinking about two options (see the nice schema attached π )
- We use a separate Node.js Express server,
- We use a
/apiresource routes directly in Remix.
The pros of 2 is the simplicity of the rework: everything stay in Remix, we should be able to work fast.
The pros of 1 is the state-of-the-art solution: separate the API from the frontend.
Option 2 is a quick win from my point of view.
But I'm wondering:
a. Is option 2 scaleable ? Anybody with some experience with decent traffic. We have <100 users but we hope to onboard billions of users when we promote our product, obviously π€
b. If we would need to transit to option 1 later, how easy will it be? Copy/paste easy? Fairly easy? Not so straightforward easy?
c. Is there a way to use express middlewares in /api? (I believe the answer is no for the moment: https://github.com/remix-run/remix/discussions/1432)
Thank you for your input π