Months ago I began a new web project which, in the beggining, seemed like a small application with virtually few users. I began the project by using the awesome Hackathon Starter WebApp Boilerplate by Sahat because the initial requirements seemed to fit into that boilerplate. As you may expect, the project requirements have evolved since then and right now I have a large-scale SaaS application. The front end code was completely decoupled from the initial project in order to use React, and I striped out everything from the original project to leave it only as a back end REST API service. Right now, I need to implement a bunch of features and the project’s codebase seems to have become a full Bolognese Spaghetti code which I need to refactor ASAP.
For the past 2 months I’ve been diving into architecture design books, posts and videos, but my app keeps growing without me being able to make a decision and refactor the back end code. Right now, it is just plain MVC with mongoose
on the Models
, express
on the server and everything from business logic, to authentication, validation and data presentation inside the Controllers
.
I’ve tried (literally) thousands, of different back end boilerplates in multiple languges and specs, but I would like to keep coding in NodeJS (TypeScript welcome). My question is, for a newbie with no experience on large-scale apps, how to refactor/rewrite my code, into a more robust architecture using NodeJS. Should I use ORMs? Should I use DDD, Service/Repository? Authentication with JWT should be a middleware? Using RBAC is acceptable? Also, the database design on MongoDB became so difficult I (literally yesterday) switched to PostgreSQL as my data began to become more relational than I anticipated. I didn’t expect this project to grow this big and I am panicking as I can’t afford rewriting/refactoring code more than once at least for the next 8 months as I will be the only developer involved in the back end side.
Thanks in advance and sorry for my awful english.
7