1 of 37

MEAN/MERN STACK

Mongo DB, Express JS, Angular/React JS, Node.js

1

Burhan Bharmal

2 of 37

AGENDA

  • Introduction
  • What is LAMP Stack?
  • Requirements for a modern web
  • What is MEAN/MERN Stack?
  • What is Mongo DB?
  • What is Express?
  • What is Angular JS/Angular 2+?
  • What is Node.JS?
  • What is React JS
  • Disadvantages of MEAN STACK
  • Conclusion
  • Any Questions?

​

2

3 of 37

INTRODUCTION

  • MEAN is an opinionated full stack JavaScript framework which simplifies and accelerates web application development.
  • MEAN represents a major shift in architecture - from relational databases to NoSQL and from server-side Model-View-Controller to client-side, single-page applications.
  • MEAN is an acronym for Mongo DB, Express JS, Angular JS and Node.Js.
  • Same as MERN is an acronym for Mongo DB, Express JS, React JS and Node.Js.

3

4 of 37

WHAT IS LAMP STACK

  • Linux
  • Apache
  • MySQL
  • PHP
  • LAMP stack is a popular open source web platform commonly used to run dynamic web sites and servers.
  • It includes Linux, Apache, MySQL, and PHP/Python/Perl and is considered by many the platform of choice for development and deployment of high performance web applications which require a solid and reliable foundation.

4

5 of 37

PROBLEMS WITH LAMP?

  • Apache is not the fastest web server around
  • It’s hard to write good-to-read, reusable and fast PHP code
  • Front-end works with other languages than the back-end
  • Too many conversions (XML to PHP to HTML, model to SQL)
  • There is no separated server-side and client-side development

5

6 of 37

REQUIREMENTS FOR A MODERN WEB

  • Customers want fast web sites/fast response times
  • No page reloads
  • Enterprises want to go virtual
    • One box + Several virtual images => Shared Hardware
    • System with minimal memory footprint/overhead needed
  • As many concurrent requests as possible
  • Only load resources when needed (conditional loading/lazy loading)
  • Mobile/Responsive UIs

6

7 of 37

WHAT IS MEAN/MERN STACK?

  • MEAN Stack is a full-stack JavaScript solution that helps you build fast, robust and maintainable production web applications using Mongo DB, Express, Angular JS/Anglar2+, and Node.js.
  • Similarly MERN Stack is same except the front end in which we are going to use React JS instead of Angular JS.

​

7

8 of 37

ADVANTAGES OF MEAN/MERN

  • 100% free
  • 100% Open Source
  • 100% JavaScript (+JSON and HTML)
  • 100% Web Standards
  • Consistent Models from the back-end to the front-end
  • Use a uniform language throughout your stack
    • JavaScript (the language of the web)
    • JSON (the data format of the web)
  • No conversion needed for the database
  • Use JavaScript with a great framework (compared to jQuery)
  • Allows to start with the complete front-end development first
  • Very low memory footprint/overhead

8

9 of 37

PROCESSING MODEL

9

10 of 37

MONGO DB

  • Mongo DB is a cross-platform document-oriented database - classified as a NoSQL database which eschews the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas.

10

11 of 37

WHAT IS MONGO DB?

  • Developed by software company 10gen (now MongoDB Inc.)
  • Fast NoSQL schema-less database written in C++
  • Document-Oriented Storage
    • JSON-style documents with dynamic schemas
  • Full Index Support
    • Index on any attribute
    • Replication & High Availability
  • Auto-Sharding
    • Scale horizontally without compromising functionality

11

12 of 37

12

MongoDB

RDBMS

Collection

Table

Document

Row

Index

Index

Embedded Document

Join

Reference

Foreign Key

Example

> db.mycol.insert({

_id: ObjectId(7df78ad8902c),

title: ‘MongoDB Overview’,

description: ‘MongoDB is no sql database’,

by: ‘Burhan Bharmal’,

url: ‘https://burhanbharmal.com’,

tags: [‘mongodb’, ‘database’, ‘NoSQL’],

likes: 100

})

13 of 37

MONGO DB DOCUMENT

13

14 of 37

MONGO DB COLLECTION

14

Collection

15 of 37

ADVANTAGES AND DISADVANTAGES

  • Advantages
  • Lightening fast.
  • Auto sharding.
  • Replication is very easy.
  • You can perform rich queries, can create on the fly indexes with a single command.

​

  • Disadvantages
  • Very unreliable
  • Indexes take up a lot of RAM.
  • B-tree indexes

15

16 of 37

EXPRESS JS

  • Express is a minimal and flexible node.js web application framework, providing a robust set of features for building single and multi-page, and hybrid web applications.

16

17 of 37

WHAT IS EXPRESS?

  • Node JS based web framework
  • Based on connect middleware
  • Makes usage of Node JS even easier
  • Easy to implement REST API
  • Easy to implement session management
  • Supports several template rendering engines (Jade, EJS)
    • Supports partials => so you can split your HTML in fragments
  • Asynchronous
  • Implements MVC pattern
  • 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

17

18 of 37

EXAMPLE

18

19 of 37

ADVANTAGES AND DISADVANTAGES

  • Advantages
  • Regardless of complexity, there should be very few roadblocks if you know JavaScript well.
  • Supports concurrency well.
  • Fast and the performance is comparable with Golang micro frameworks and Elixir's Phoenix.
  • Disadvantages
  • There is no built in error handling methods.

19

20 of 37

ANGULARJS/ANGULAR2+?

  • AngularJS is an open-source JavaScript framework, maintained by Google, that assists with running single-page applications. Its goal is to augment browser-based applications with model–view–controller (MVC) capability, in an effort to make both development and testing easier.
  • Angular is the blanket term used to refer to Angular 2, Angular 4 and all other versions that come after AngularJS. Both Angular 2 and 4 are open-source, Typescript-based front-end web application platforms. 

​

20

21 of 37

WHAT IS ANGULAR JS

  • JavaScript framework developed by Google
  • Based on Model-View-* Pattern (client-side)
    • MVC/MVVM
    • Bi-Directional Data Binding
  • The model is the central component that expresses the application's behavior and manages its data, logic, and rules.
  • The view generates an output based on the information in the model.
  • The controller accepts input, converts it into commands and sends the commands to the model and the view.
  • Very modular and extensible
    • Makes testing an ease
  • Great Browser support (> IE8)

21

22 of 37

WHAT IS ANGULAR 2+

  • Angular uses Microsoft’s Typescript language, which is a superset of ECMAScript 6 (ES6).
  • This has the combined advantages of the Typescript features, like type declarations, and the benefits of ES6, like iterators and lambdas.
  • Angular 2, controllers and $scope were replaced by components and directives.
  • Components are directives with a template. They deal with a view of the application and logic on the page.
  • There are two kinds of directives in Angular 2. These are structural directives that alter the layout of the DOM by removing and replacing its elements, and attributive directives that change the behavior or appearance of a DOM element.
  • In Angular 4, the structural derivatives ngIf and ngFor have been improved, and you can use if/else design syntax in your templates.

22

23 of 37

COMMON FEATURE

23

24 of 37

ADVANTAGES AND DISADVANTAGES

  • Advantages
  • Fast development
  • Makes developing SPA easy
  • Awesome performance
  • Make apps scalable

​

  • Disadvantages
  • Good for IO driven apps only (not games)

24

25 of 37

REACT JS

  • A JavaScript library for building user interface. ReactJS is Developed by Facebook. React is a view layer library, not a framework like Backbone, Angular etc. You can't use React to build a fully-functional web app.
  • React is the V in MVC.

25

26 of 37

WHAT IS REACT JS

  • React is a simple library for creating user interface
  • React renders your UI and responds to events
  • Transform data into interface components.
  • Every component has state and props
  • It re-render the whole app as state changes.
  • Supports JSX which allows you to write JS and XML together
  • Virtual DOM makes re-rendering on every change fast

26

27 of 37

EXAMPLE

27

28 of 37

ADVANTAGES AND DISADVANTAGES

  • Advantages
  • React is extremely efficient since it uses a Virtual DOM
  • It makes writing JavaScript easier because of JSX syntax
  • React is awesome for SEO
  • UI taste cases are easy to write

​

  • Disadvantages
  • ReactJS is only a view layer
  • It doesn’t support old browser i.e. IE8
  • Slow you down tremendously at the start

28

29 of 37

NODE JS

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

29

30 of 37

WHAT IS NODE.JS

  • Written in C/C++
    • Can also use C libraries
  • Built on top of Chrome’s V8 engine – so pure JavaScript!
    • Therefore based on latest ECMAScript 5
  • Framework to build asynchronous I/O applications
  • Single Threaded – no concurrency bugs – no deadlocks!
  • Not internally though – but we’ll get to that
  • One node process = one CPU Core

30

31 of 37

WHAT IS NODE.JS – CONT.

  • Can easily handle 10k concurrent connections
    • Doesn’t have any problems with concurrency
    • Doesn’t create much overhead (CPU/Memory)
  • Easily scalable (just create a cluster)
  • Very fast (well, it’s mostly C code)
  • Installation and first server start within less than 5 minutes
    • REST-API that replies to GET requests can be implemented in less than 5 minutes as well!
  • It’s not a web framework!

31

32 of 37

EXAMPLE

32

33 of 37

ADVANTAGE AND DISADVANTAGE

  • Advantages
  • Node.js is fast
  • The ever-growing NPM
  • Real-time web apps
  • Productivity

​

  • Disadvantages
  • JavaScript's semantics and culture

33

34 of 37

DISADVANTAGES OF MEAN/MERN STACK

  • There are still no general JS coding guidelines
  • MongoDB is not as robust as an SQL server
    • This security is what they sacrifice to gain speed
  • Once you’ve created the first site with this technology, it’s hard to go back to the old approach

34

35 of 37

CONCLUSION

  • In the end, Mean is a full stack, JavaScript, web application framework. If you require a fast, easy, simple way to create a modern, responsive, dynamic web site then MEAN would be a great solution.

35

36 of 37

ANY QUESTIONS ??

36

37 of 37

THANK YOU ☺

37