logo
logo
Sign in

MEAN Stack Architecture: MongoDB, ExpressJS, AngularJS, and NodeJS

avatar
Evincedev
 MEAN Stack Architecture: MongoDB, ExpressJS, AngularJS, and NodeJS

Introduction

MEAN is a free and open-source JavaScript software stack for building dynamic websites and web applications or we can say that MEAN stack is a collection of JavaScript-based technologies used to develop web applications. MEAN is an acronym for MongoDB, ExpressJS, AngularJS, and Node.js. From client to server to database, MEAN is full-stack JavaScript.

M = MongoDB, a popular database manager which implements a NoSQL structure.

E = Express.js, a framework that supports and is used to host Node.js projects.

A = Angular.js, yet another framework for building apps. It builds upon the classic HTML framework style and extends it to web apps

N = Node.js, the crowning glory. This is a runtime environment, which runs server-side web applications, i.e. it works on the back-end, away from the user’s eyes to fetch relevant data or perform operations on the same.

MongoDB offers a more flexible, accommodating layer for storing data. Node.js provides a better nexus for running your server, while Express.js helps to standardize how you build your websites. On the client-side, AngularJS provides a clean way of adding interactive functions and AJAX-driven rich components. The amalgamation of all makes a clean, coherent mechanism for moving data from the user to the disk farm and back again.


Features Of MEAN Stack Architecture


One of the most important benefits of all is that it lets the developer write the entire code in JavaScript; from client to server. This is like a blessing for the JavaScript developers who have invested their time and money in learning JavaScript for the client-side tasks.


It supports the MVC (Model View Controller) architecture.

The MEAN components are open source; in other words, the stack gets updated regularly. In addition to this, it is easy to use, flexible to understand and moreover assists the developers to customize as per the requirements.

A massive module library of node.js and the use of JSON to transfer the data are a few other features of MEAN.

Not just the start-ups and SMBs but also big companies like Walmart, PayPal, Yahoo, Netflix, Uber, LinkedIn, etc. have also shifted to Node.js


Use Cases of MEAN

Because of its enhanced scalable and handling capacity of concurrent users, it is much more favored for developing cloud-native applications. Though MEAN stack is not ideal for every application there are other uses where it easily offsets. AngularJS helps to develop SPAs (single-page applications) which normally includes all the information or functionalities for the user on a single page. Most common examples are as follows:

  1. Calendars
  2. Expense Tracking
  3. Mapping & location tracking
  4. News


MEAN Stack Architecture


MEAN is a free and open-source JavaScript software stack for building dynamic websites and web apps. It is very simple & easy to use for both back-end and front-end. In other technologies, there are different languages used for front and back-end but however, MEAN is written in one language for both server-side and client-side execution. Working of MEAN Stack is explained below in the figure properly.


MEAN Stack Architecture Explanation

  1. When the client makes any request it is firstly processed by the AngularJS. AngularJS is a client-side language in JavaScript.
  2. After that, the request enters phase 2 which is NodeJS. NodeJS is a server-side language in JavaScript.
  3. In phase 3, which is ExpressJS makes the request to the database.
  4. MongoDB retrieves the data & returns the response back to the ExpressJS.
  5. Then ExpressJS sends a response back to the NodeJS and then NodeJS forwards it to the AngularJS to display the result.


AngularJS (Client-Side)


AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and allows you to extend HTML’s syntax to express your application’s components clearly and succinctly. AngularJS 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.

  1. AngularJS is a browser-independent powerful JavaScript-based data binding UI framework to create RICH Internet Application(RIA).
  2. It provides developers with options to write a client-side application (using JavaScript) in a clean MVC (Model View Controller)
  3. An open-source, completely free, and used by thousands of developers around the world. It is licensed under the Apache License version 2.0.

1) Model

It is the lowest level of pattern responsible for maintaining data.

The model is responsible for managing application data. It responds to the request from view and to the instructions from the controller to update itself.

2) View

It is responsible for displaying all or a portion of data to the user.

A presentation of data in a particular format, triggered by the controller’s decision to present the data. They are script-based template systems such as JSP, ASP, PHP and very easy to integrate with AJAX technology.

3) Controller

It is a software Code that controls the interactions between the Model and View.

The controller responds to user input and performs interactions on the data model objects. The controller receives input, validates it, and then performs business operations that modify the state of the data model.


NodeJS (Server Side)


Node.js is a server-side platform built on Chrome’s JavaScript runtime to easily build fast and scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, hence, perfect for data-intensive real-time applications that run across distributed devices.


1) Asynchronous and Event-Driven

All APIs of Node.js library is 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.


2) Very Fast

Being built on Google Chrome’s V8 JavaScript Engine, Node.js library is very fast in code execution. Moreover, with its runtime feature, one can easily build scalable and secure web apps.


3) Single-Threaded but Highly Scalable

Node.js uses a single-threaded model with event looping. The 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.


4) Buffering

A stream of data can be classified as the movement of the data from one point to another with a function of either to process or read it and make decisions accordingly. Depending upon the flow of data through a stream either the process will consume the data faster and needs to wait for the excess data or if it is slower than it needs to wait for additional data to arrive before it is being sent out for processing. Whichever is the scenario, the waiting area is the ‘Buffer’. Node.js does not hold the control over the speed, time of data arrival or the speed of the stream however, it can only act on the time to send out the data.


Threading

Node.js operates on a single thread, using non-blocking I/O calls, allowing it to support tens of thousands of concurrent connections without incurring the cost of thread context switching. The design of sharing a single thread between all the requests that use the observer pattern is intended for building highly concurrent applications, where any function performing I/O must use a callback. In order to accommodate the single-threaded event loop, Node.js utilizes the libuv library which in turn uses a fixed-sized thread pool that is responsible for some of the non-blocking asynchronous I/O operations.


Get More Details at - https://evincedev.com/blog/mean-stack-architecture/

collect
0
avatar
Evincedev
guide
Zupyak is the world’s largest content marketing community, with over 400 000 members and 3 million articles. Explore and get your content discovered.
Read more