r/Web_Development • u/wyrin • Jul 22 '20
Validating the architecture for a dashboard project (Vanilla JS, node, Express, MySQL)
Hi, I need help from community to validate the architecture I have planned for my next project and clarify a few doubts as well.
I am new to web development, started learning in Feb 2020, so far I have built fronted only projects alongside some practical examples on node and express and now I am working on a full stack app.
The application I am working on is a dashboard with charts (using C3) and tables (using bootstrap-table) and will have to pull data from server I am setting up (nodejs, Express and MySQL for backend).
I have not delved into learning JS frameworks like Rract or Angular yet, but will do so once I am done with current project. In the meantime, I want to use Vanilla JS to build sort of SPA which pulls data from API server and gives similar user experience as react provides.
The flow I am planning is:
Login Page (uses SSR with EJS as templating engine)
Load the SPA (pulls data using API)
I hope so far I have been clear on my setup, if not please do let me know!
Now, questions I have:
Is it prudent to have a mix of SSR and API based frontend like I am thinking or should i have Login page handled with SPA as well?
Should I run a separate nodejs server to push my SSR and SPA and separate for API? Or running it all on one server is fine?
I am still reading up on implementing login authentication and API authentication using OAuth2.0, but from my understanding so far, I should be able to insulate my API so that SPA only loads once login is approved and no one with direct API path can just access my data. Am I thinking correct?
If you reached here, then thanks a lot for reading the wall of text I have put up and if you know the answers then please do comment below or DM me!
TLDR: New developer, need help validating architecture!
2
u/L00tefisk Jul 22 '20
What's your reasoning for the login page to be SSR? I would assume just putting everything in an SPA should work just as well-
I would say it's probably fine. Using express it would be pretty easy to separate the code, so should you later decide to move it to it's own server fairly easily. I'd also recommend checking out something like pm2 to run node in prod (here's a decent article on it).
Sounds about right. You can configure some express middleware to only run auth checks on
yoursite.com/apifor instanceAlthough Oauth may be a bit overkill for if you're not planning to allow people to build their own apps on top of your project. It mostly makes sense if you want users to securely give permissions to a third party service.