MVC with AngularJS and node js - angularjs

I have been wondering whether this combination of technologies would work. I can implement a modular web application with MVC, EF, and utilize AngularJs if I would want to play around with the technology to implement sort of a mini SPA. I would like to extend my knowledge a bit further, and I was wondering whether I could utilize node.js instead of EF for relational database communication. Can I intermingle MVC back end with AngularJs for front end (mixed with MVC), and node.js for database communications

Is it possible? Yes, technically, but it would be very bad practice.
ASP.NET's MVC does nearly everything server-side. This means that views are built within the server and sent to the user. The controller is also server side.
With AngularJS, this paradigm is flipped on its head. The controller and view are both client side. The server sends the user all of the views and controllers at once, and then from then on only serves data. This is very attractive for single-page applications, and sites that want to exchange data, but not have to constantly send a new view. NodeJS is a popular architecture to use for the server, but any server architecture will work fine with Angular.
Both systems have their pros and cons, but there is no sane reason I can think of to use them together. You can certainly use ASP.NET as the server/model for an AngularJS application, but I'd discourage you from using APT.NET MVC with Angular.

Related

Angular + Apache CXF for RDBMS access or Angular + Spring MVC?

I have to write a simple web-application which basically fetches data from RDBMS, does some computations on the data and displays the results on screen.
There is a reference application from which I need to re-use components.
I have come up with two options -
First - To use Angular.js for creating the views which calls REST based web services exposed by the server side using Apache CXF. REST based services hit the DB, process the data and return it to the client side.
Second - To use Angular.js for creating the views which calls Spring MVC based controllers. Controllers hit the DB, process the data and return it to the client side.
I only have experience in Spring MVC + tiles based JSP for views, so, I was initially inclined with the second approach, but upon further thinking, I think that the first approach is better since I can let the application be driven from the client side for flow routing and let the client side be dependent on REST bases services rather than being tied up to the Spring MVC framework.
it will really help me if somebody can provide me some more inputs... thanks in advance...
Working with Rest expose your services, to any level including your application as well. If in future anyone else needs you services, you can easily expose it using REST. So in my view, working with REST is more beneficial and rest depends on your business case.
Moreover you can combine both approaches. use REST to expose your services and MVC for separation of concerns and avoiding tightly coupled data and business logic.

Advantages of a separate REST backend API?

Context: I'm a beginner programmer, self taught in the hope of making a SPA. I've started with JavaScript, Jquery, PHP and MySQL, and now feel pretty confident with all. I've started with Ember, and am now moving away from having a PHP API to Node. Which has then brought me closer to Meteor... I'm aware I'll need to use Mongo instead, but having an integrated front and back seems to be sensible and have some advantages.
So my question is what are the advantages of having a separate REST backend API (eg Express) rather than an integrated front/back (eg Meteor).
One that springs to mind is that my app will be tablet/pc based, but in future I'll want a different mobile version, so I'd be able to use just use the same API. I'm conscious that the above question is the main concern with this stack question, but perhaps if a meteor developer could clarify whether this is indeed a concern.
Thanks in advance!
well for me you'll get a lot of advantages using a rest API, they are lightweight, extensible and overall reusable.
today it's a trend to use a vertical architecture that means having a RestFul service with a single responsibility, why because it scale better and it's easier to assign a team to an api, so that way you'll be able to manage several teams and apis in a very ordered way. This is probably how Twitter, wunderlist and other companies works, because it's a solution to scale better.
take a look to this talk by Raffi Krikorian he was the head of architecture of Twitter for a while is a little bit old but it worth every minute and to illustrate some of the advantages.
Also you can look at the diagram below, I did while ago it explains the differences between the MVC and API first type of architecture.
I've authored one rest app using angular and rest services and it has been a very nice experience to me there's no way back.
good luck
Meteor doesn't really "integrate" the front (client) and backend (server) as you describe. It still maintains them as two separate layers. The beauty of meteor (aside from the insanely awesome reactivity) is that it uses Javascript everywhere, instead of using JS on the client and some other language on the server, so you can use the same APIs on both the front and backend. Although Meteor does snazzy things like let you write client and server code in the same file, it still requires you to distinguish between the two, and server code is still stored only on the server and client-side code is still served down to the client.
Meteor is still young, but the developers and community are very active, and everything you described can be achieved with it at this point. I've been working with Meteor for about 6 months now, and it hasn't let me down yet. I'm working on a production-level application that also requires exposing a REST API for consumption in mobile apps, which I'm doing quite successfully with Meteor (I just updated a user profile using a REST endpoint from an Android device and watched it change in the Meteor app in realtime. So cool!).
I was using this great package, RestStop2, for building REST APIs in meteor, but it was unfortunately deprecated, so I released an updated version. Check it out for an example of building REST APIs in Meteor. It's available through the Meteor package manager: https://atmospherejs.com/nimble/restivus
So to answer your question, you always want to separate the REST API into it's own layer, but that is entirely possible with Meteor. To make it clear, you would never consume this REST API from within your Meteor app. Meteor uses DDP (not HTTP), which gives you a much more direct connection with your server, so you're doing something wrong if you're accessing data on your Meteor server from a Meteor client via HTTP. Of course, with Meteor, you have the advantage of being able to use existing code from your REST API.
There's a really good write-up that explains some of the considerations of writing a REST API in Meteor: http://www.meteorpedia.com/read/REST_API.
The design of a architecture separated in layers like frontend, backend (Rest Api) and DB, is for obtain a better a scalability, reusability and logic separator of features of the application. For example:
Today make a web applications separated in 3 layer (frontend, backend,
and databases), if tomorrow you wanna do a mobile application you can
develop the application like a extra project in the frontend layer,
but use all the features developed in backend. Then the frontend
application not need servers why run inside every device, but maybe
the load in the backend servers increase, and you only need add 1 more
server in the backend layer.
Its a little example, but is the most common case in this new era of mobile applications.
Remember always this in MVC architectures:
Frontend: Always call services from the backend, render the view, and capture data. Sometimes make a litle logic.
Backend: Receive the request, apply all the business logic, read and write operations in databases, and return a response preferred in json format.
Model: store data, backups, slaves, etc.
PD: If you use meteor in this example you gonna need to make a api Rest to develop the mobile application.

OWASP top 10 web app security risks mitigation in AngularJS

I'm using HDIV for JSF and Spring MVC applications to mitigate OWASP top 10 security risks. Now I have to implement the same in AngularJS.
Is there any library avilable similar to HDIV for AngularJS?
For client-mvc scenarios such as AngularJS Spring-Hateoas approach fits well with HDIV. Actually, HDIV has a module for that integration: https://github.com/hdiv/hdiv/tree/hdiv-hateoas
It’s not totally finished yet but the integration of URL resources works (see ResourceRequestDataValueProcessor) but it’s not finished the support for forms. When we started this module this data format for forms was not finished or defined, and that’s why we did not continue this work.
We think it could be possible a very integrated solution with HDIV following Hypermedia and HATEOAS
approach for client-mvc apps or also for native mobile apps. In other words, within REST Hypermedia approach all URLs or forms, excepting the first URL, are created in the server side, in a similar way of traditional server side MVC web technologies.
Please take a look to this module (hdiv-hateoas) and we can support you if you have any doubts.
Roberto Velasco (HDIV team)

Architecture for mobile application

Right now ,i and my friend looking forward to make a mobile application, which is going to get data from several different sources, analyze it with some kind of algorythm and make the best decision on that. The main problem is - right architecture for that. We consider that mobile application is going to be just a client, representing data placed somewhere on internet (anyway internet is required).
Can u help us with making right choice?
We have some kind of knowledge about client-server architecture with sockets... But this is definetly not we need in this particular situation.
Our thought is to make a web site which is going to generate all the required data.After that implement mobile apps which will represent info from website, using convenient interface. Is it right way?
Yes, that's the way to go.
Now, you have several options within that architecture...
server gets data from several different sources
server might expose some kind of RESTful API to the client apps
clients can be native mobile applications or client might be html5 mobile apps
depending on the nature of the data, you might want to consider some kinds of caching data that you get from 3rd party services/sources
EDIT:
I use ASP WebApi to build REST Api that serves json data to android mobile app.
So, my infrastructure is:
- MS SQL 2012
- ASP MVC 4, WebAPI
- android mobiles (we're targeting mainly Jelly Bean & Kit Kat)
I've built n-layered application with layers (bottom up order):
- DAL (i don't use any ORM framework...i use my own repository that runs stored procedures on SQL server)
Repository that wraps around db DAL and a few Service Agents that gets data from 3rd party services we use
Business layer where i do our business operations
Service layer (for now, it has no special use but afterwards i might need it as my business layer will be consumed from a few clients: WebAPI, web site, windows service...)
WebAPI for REST where mobile client requests end up

backbone.js and the need of a back-end engine

reading this days about backbone.js (documentation, examples, etc), and as far as i have understood, this framework lets you code directly on the front-end, almost all the back-end engine, since you can structure a MVC architecture. You can create your data model, controllers, etc.
My question is: if you already have the MVC architecture built on the Front-End (engine), you just need a DataBase (SQL) in the cloud from where you can fetch or store data, why do you need a back-end engine (RoR3,Java,etc) to persist document data?
thanks in advance
You are confusing two different meanings of front end, the model in the backbone framework is not able to connect to a database directly, this model are designed to connect to an API (that would be your backend) that is connected to a database
Things you still need to do on the server:
authentication
authorization
data sanitation and filtering
Possiby
interact to third parties
business logic that involves modules other than UI
etc.
Front-End MVC frameworks (Backbone, Angular, etc) all rely on a backend service to provide the data that, say Backbone, would then use as its model.
You could have an entire MVC pattern on the backend that accepts requests and spits out some JSON for a frontend MVC framework to use.
If you just want a database without creating a server, I would recommend using Google FusionTables - but you need OAuth and maybe even ClientLogin (depending) on top of that.
Because as far as I know Backbone works with RESTful services and it needs a server to handle the requests:
get: to list data from the db
post: to add new stuff to the db
put: to update current data
delete: to remove data from the db.
.. and also perform all sorts of server related stuff if you like
For instance I'm using Restful server based on Code Igniter to handle that stuff. From there you can choose the DB you want to work with. I already tried using MySQL and MongoDB

Resources