1

I am a java developer. Since one of our developers are leaving I was handed over a project he was maintaining. He says it is a node + angular js project. But as per my understanding, backend should be written in node js (just as we do java api development) and front end should be written in angular as a separate application. These two applications should be hosted separately and the angular front end should call node js backend for any requests required. So I am confused what is meant by angular+node in the same application and they are hosted as a single application. Can someone experienced in this area please enlighten me?

5
  • 1
    "These two applications should be hosted separately". I'm unclear what you mean by "hosted separately". The node backend serves up content to the browser, including the angular-based front end. Whether you consider the back and front ends the one application or two is pure semantics and thus unimportant.
    – David Arno
    Oct 25, 2019 at 7:35
  • What I am usually exposed to is, the backend is a separate application. It will run independently and expose API end points to the frontend/mobile apps to be used. The front end is also a separate application which will run on it's own. Frontend will call the backend APIs as required. The user will type the frontend application's url in his browser. So what you mean is, there is another architecture where we can have backend and frontend developed as a single project? Is it considered a good practice?
    – Leni
    Oct 25, 2019 at 7:52
  • Ah, OK. I understand now. In that case, it really depends on how the thing has been set up. You don't have to do it the way you describe. In fact I've not come across folk doing it that way before. Instead the one backend can both serve the frontend URL and a set of web APIs. That may be what the other developer has done in this case. Or they may just consider the "frontend" server and browser content, plus the APIs, as one application. It sounds like you need to ask them for clarification.
    – David Arno
    Oct 25, 2019 at 8:00
  • Thanks for the explanation. Unfortunately he has already left and was working in another geo location.
    – Leni
    Oct 25, 2019 at 8:28
  • Could it be that the Angular front-end is simply served by the Node back-end, with both being built as part of the same project? In the Java world, you have projects built in a similar manner with a Spring back-end serving the front-end files (the front-end being built thanks to frontend-maven-plugin and then put as static files inside the WAR). Front-end and back-end then communicate through APIs.
    – KevinLH
    Oct 25, 2019 at 9:05

1 Answer 1

2

Its fairly normal to have your webpages and js served by the same webapplication which also hosts your api code.

This simple approach has some upsides. You dont have to do anything special with cross site scripting controls, code and ui are in the same place etc.

And also some downsides. you can't deploy new versions of the api separately to the UI and vice versa.

Given that the UI is often tightly coupled to the api responses I would suggest going for a dual api aproach. Have a seperate api project, but also have a server side component of your UI.

So angular calls its local api, which then calls the 'real' api.

This allows the Front end developers a level of abstraction which they can use to modify the server side responses where required, while keeping the backend api, which may be used for other purposes as well, separate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.