I use Spring for backend work and Angular for frontend and maintain each in separate repositories.
This was because I considered both the frontend and backend completely separate projects, IE a new frontend can be developed in an entirely different framework and it'd still work with the existing backend and vice versa; they are in no way tied down to each other.
I've been reconsidering this as I learned one can have their Angular site served through Spring, rather than using NGINX/Apache. This would allow deploying the two as a single application and reduce the need to run two web servers. (Tomcat/NGINX)
Is this normal and is it advisable to do? I partially feel it's better to keep them separated, for example by deploying them as a single unit the frontend is now a part of the backend, even if only visual changes are made, parts of the backend would have to go offline just to deploy those changes?
I can also see here that Spring have bunched up both projects in the same repository. Is this normal as this project structure appears to be somewhat messy compared to for example in a single repository just having a
api directory, or better yet, two separate repositories?
Didn't notice until I posted this, the link in this post is a Spring/Angular JS repo, while I use Spring/Angular CLI, just for clarity.
I've also discovered it's possible to serve the frontend with Spring, without the frontend being inside the application. (Allowing it to be replaced very easily.) Thanks to the
spring.resources-static-locations configuration in
application.yml which makes this a little more appealing now.
Looking further into it, it seems the choice is either:
- Spring for API + NGINX for Frontend with Reverse Proxy to access API.
- Spring for API, with external static resources hosted on a Google Cloud Storage Bucket so that the website can be updated without the backend having downtime. The site is served by Spring, but still completely separate from it.