Upload
rishabh-saxena
View
114
Download
0
Embed Size (px)
Citation preview
The acronym "MEAN" stands for "MongoDB Express.js AngularJS Node.js" and
represents a group of technologies which are known to synergize well together. The
major benefit of the MEAN stack is that it's extremely quick to prototype with. Node.js
allows you to use Javascript on the backend as well as the front end which can save you
from having to learn a separate language. In addition, the NoSQL nature of MongoDB
allows you to quickly change and alter the data layer without having to worry about
migrations, which is a very valuable attribute when you're trying to build a product
without clear specifications.
MONGO DB
MongoDB is an open-source document database, and leading NoSQL database.
MongoDB is a cross-platform, document oriented database that provides, high
performance, high availability, and easy scalability. MongoDB works on concept of
collection and document.
Salient features:
Relational databases have a typical schema design that shows number of tables
and the relationship between these tables. While in MongoDB there is no concept
of relationship
Schema less: MongoDB is document database in which one collection holds
different documents. Number of fields, content and size of the document can be
differ from one document to another.
*Collection is a group of MongoDB documents. It is the equivalent of an RDBMS table.
A collection exists within a single database. Collections do not enforce a schema.
Documents within a collection can have different fields. Typically, all documents in a
collection are of similar or related purpose.
*A document is a set of key-value pairs. Documents have dynamic schema. Dynamic
schema means that documents in the same collection do not need to have the same set of
fields or structure, and common fields in a collection's documents may hold different
types of data.
Structure of a single object is clear.
No complex joins
Deep query-ability. MongoDB supports dynamic queries on documents using a
document-based query language that's nearly as powerful as SQL.
Ease of scale-out: MongoDB is easy to scale
Conversion / mapping of application objects to database objects not needed
Uses internal memory for storing the (windowed) working set, enabling faster
access of data.
Why should we use MongoDB
Document Oriented Storage: Data is stored in the form of JSON style documents
Location based queries in built feature in mongodb. Index on any attribute
Replication & High Availability
Auto-Sharding
Rich Queries
Fast In-Place Updates
Professional Support By MongoDB
Where should we use MongoDB?
Big Data
Content Management and Delivery
Mobile and Social Infrastructure
User Data Management
Data Hub
EXPRESS.JS
Express.js is a Node.js web application server framework, designed for building single-
page, multi-page, and hybrid web applications. It is the de facto standard server framework for node.js.
Salient features:
Express is a minimal and flexible Node.js web application framework that provides a robust set of features to develop web and mobile applications.
It facilitates a rapid development of Node based Web applications. Allows to set up middlewares to respond to HTTP Requests. Defines a routing table which is used to perform different action based on HTTP
Method and URL. Allows to dynamically render HTML Pages based on passing arguments to
templates. Creating RESTAPI endpoints.
ANGULAR JS
AngularJS is a fully client-side framework.
AngularJS is a structural framework for dynamic web apps. It lets you use HTML
as your template language and lets you extend HTML's syntax to express your
application's components clearly and succinctly. Angular's data binding and
dependency injection eliminate much of the code you currently have to write. And
it all happens within the browser, making it an ideal partner with any server
technology.
Salient Features:
AngularJS is a powerful JavaScript based development framework to create RICH
Internet Application(RIA).
AngularJS provides developers options to write client side application (using
JavaScript) in a clean MVC(Model View Controller) way.
Application written in AngularJS is cross-browser compliant. AngularJS
automatically handles JavaScript code suitable for each browser.
AngularJS is open source, completely free, and used by thousands of developers
around the world.
AngularJS is a framework to build large scale and high performance web
application while keeping them as easy-to-maintain.
Core Features
Following are most important core features of AngularJS −
Data-binding − It is the automatic synchronization of data between model and view
components.
Scope − These are objects that refer to the model. They act as a glue between controller
and view.
Controller − These are JavaScript functions that are bound to a particular scope.
Services − AngularJS come with several built-in services for example $http to make a
XMLHttpRequests. These are singleton objects which are instantiated only once in app.
Filters − These select a subset of items from an array and returns a new array.
Directives − Directives are markers on DOM elements (such as elements, attributes, css,
and more). These can be used to create custom HTML tags that serve as new, custom
widgets. AngularJS has built-in directives (ngBind, ngModel...)
Templates − These are the rendered view with information from the controller and
model. These can be a single file (like index.html) or multiple views in one page using
"partials".
Routing − It is concept of switching views.
Model View Whatever − MVC is a design pattern for dividing an application into
different parts (called Model, View and Controller), each with distinct responsibilities.
AngularJS does not implement MVC in the traditional sense, but rather something closer
to MVVM (Model-View-ViewModel).
Deep Linking − Deep linking allows you to encode the state of application in the URL
so that it can be bookmarked. The application can then be restored from the URL to the
same state.
Dependency Injection − AngularJS has a built-in dependency injection subsystem that
helps the developer by making the application easier to develop, understand, and test.
Advantages of AngularJS
AngularJS provides capability to create Single Page Application in a very clean
and maintainable way.
AngularJS provides data binding capability to HTML thus giving user a rich and
responsive experience
AngularJS code is unit testable.
AngularJS uses dependency injection and make use of separation of concerns.
AngularJS provides reusable components.
With AngularJS, developer write less code and get more functionality.
In AngularJS, views are pure html pages, and controllers written in JavaScript do
the business processing.
On top of everything, AngularJS applications can run on all major browsers and smart
phones including Android and iOS based phones/tablets.
Disadvantages of AngularJS
Not Secure − Being JavaScript only framework, application written in AngularJS
are not safe. Server side authentication and authorization is must to keep an
application secure.
Not degradable − If your application user disables JavaScript then user will just
see the basic page and nothing more
NODE JS
Node.js is an open-source, cross-platform runtime environment for developing server-
side Web applications. Although Node.js is not a JavaScript framework, many of its basic
modules are written in JavaScript, and developers can write new modules in JavaScript.
The runtime environment interprets JavaScript using Google's V8 JavaScript engine.
Features of Node.js
Following are some of the important features that make Node.js the first choice of
software architects.
Asynchronous and Event Driven All APIs of Node.js library are asynchronous
that is, non-blocking. It essentially means a Node.js based server never waits for
an API to return data. The server moves to the next API after calling it and a
notification mechanism of Events of Node.js helps the server to get a response
from the previous API call.
Very Fast Being built on Google Chrome's V8 JavaScript Engine, Node.js library
is very fast in code execution.
Single Threaded but Highly Scalable - Node.js uses a single threaded model
with event looping. Event mechanism helps the server to respond in a non-
blocking way and makes the server highly scalable as opposed to traditional
servers which create limited threads to handle requests. Node.js uses a single
threaded program and the same program can provide service to a much larger
number of requests than traditional servers like Apache HTTP Server.
No Buffering - Node.js applications never buffer any data. These applications
simply output the data in chunks.
Where to Use Node.js?
Following are the areas where Node.js is proving itself as a perfect technology partner.
I/O bound Applications
Data Streaming Applications
Data Intensive Real time Applications (DIRT)
JSON APIs based Applications
Single Page Applications
Advantages of Node JS
1. You Already Know JavaScript
Let me guess. You're using a rich client framework (Angular, Ember, Backbone) and a
REST-ful server-side API that shuttles JSON back and forth. Even if you're not using one
of those frameworks, you've written your own in jQuery. So if you're not using Node.js
on the server, then you're constantly translating. You're translating two things: 1) the
logic in your head from JavaScript to your server-side framework, and 2) the HTTP data
from JSON to your server-side objects.By using JavaScript throughout your app, you not
only gain mental energy, you gain practicality as well. By potentially re-using your
models, and templates, you reduce the size of your application which reduces complexity
and chance for bugs.
2. It's Fast
In addition to lightning fast JavaScript execution, the real magic behind Node.js is the
event loop. The event loop is a single thread that performs all I/O operations
asynchronously. Traditionally, I/O operations either run synchronously (blocking) or
asynchronously by spawning off parallel threads to perform the work. This old approach
consumes a lot of memory and is notoriously difficult to program. In contrast, when a
Node application needs to perform an I/O operation, it sends an asynchronous task to the
event loop, along with a callback function, and then continues to execute the rest of its
program. When the async operation completes, the event loop returns to the task to
execute its callback.
MEAN vs LAMP
The simplicity and common structure of MEAN make your life easier. MongoDB offers a
more flexible, accommodating layer for storing data. Node.js provides a better nexus for
running your server, while Express.js helps standardize how you build your websites. On
the client, AngularJS provides a clean way of adding interactive functions and AJAX-
driven rich components. Put them all together and they make a clean, coherent
mechanism for moving data from user to disk farm and back again.
The real explanation, however, is deeper. Here we offer nine reasons to give MEAN a
shot with your next project. Not everyone has the time or budget to toss out and recode
the old in the latest, trendiest framework, nor should you throw away the rock-solid
reliability of battle-tested tools like Apache, MySQL, or PHP. But for green-field projects
that could benefit from flexibility, simplicity, and performance, going MEAN may make
your life better than you think.
MongoDB is built for the cloud
If your Web app plans include making good on the pennies-per-CPU promise of the
cloud, the MEAN stack offers a compelling database layer in MongoDB. This modern
database comes equipped with automatic sharding and full cluster support, right out of
the box.
MySQL's structure is confining (and overrated)
Anyone who has developed or maintained a LAMP-based app for any amount of time
knows that MySQL’s strength as a relational database can feel a bit imprisoning at times.
Like all relational databases, MySQL forces you to push your data into tables. This isn't a
problem if every single entry fits into exactly the same format, but how often is the world
that generous? What if two people share the same address but not the same account?
What if you want to have three lines to the address instead of two?.
MEAN makes code isomorphic
The simplicity doesn't stop with using JavaScript on the server. By going MEAN, you
can enjoy that same JavaScript on the client, too, leaving behind the LAMP stack's
client/server. If you write code for Node and decide it’s better placed in AngularJS, you
can move it over with ease, and it's almost certain to run the same way. This flexibility
makes programming MEAN-based apps significantly easier. Plus, if you're staffing up a
project, you don't need to look for a PHP expert and a JavaScript expert, or a front-end
and a back-end specialist. Instead, it’s all JavaScript across the stack.
JSON everywhere
AngularJS and MongoDB both speak JSON, as do Node.js and Express.js. The data
flows neatly among all the layers without rewriting or reformatting. MySQL's native
format for answering queries is, well, all its own. MEAN uses the same JSON format for
data everywhere, which makes it simpler and saves time reformatting as it passes through
each layer. Plus, JSON’s ubiquity through the MEAN stack makes working with external
APIs that much easier: GET, manipulate, present, POST, and store all with one format.
Node.js is superfast
Apache was great, but these days, Node.js is often flat-out faster. A number of
benchmarks show that Node.js offers better performance, while doing much more.
Perhaps it's the age of the code. Perhaps the Node.js event-driven architecture is quicker.
It doesn't matter.
Depth matters
The Node.js package manager, Npm, makes it even easier to share code, and the public
repositories targeting Node.js are growing quickly. While the PHP crowd may lead at this
moment in time, the future may favor Node.js.
AngularJS is fresh
If you want to do anything on the client side, you're on your own. Sure, there are plenty
of good PHP-based frameworks that work with MySQL, but each is a bit different and
moving in its own direction. WordPress, Joomla, and Drupal, for example, offer differing
strategies, and it's hard to switch between them, let alone port code from one to the other.
Anointing one client framework adds consistency and stability.