#TECH

Rapid Application Development using MEAN Stack

Budget and time are the biggest constraints that people usually face while building an application. So, before starting any new project, we need to set up all the required tools and project structure which is time consuming. Practicing code reuse and using web application frameworks for this can greatly improve both productivity and time.

“Every website you visit is the product of a unique mixture of libraries, languages, and web frameworks.” — IBM

What is MEAN?

The authors of MEAN Stack define it as :

MEAN is a fullstack JavaScript platform for modern web applications”.

So with MEAN, there isn’t any need to learn any additional language for the backend part. All you need to learn for MEAN stack is- Javascript, to do anything one could do with LAMP stack.

Yes!! You are hearing me right, Javascript for both frontend and backend.

Components of MEAN

MEAN is an acronym for MongoDB, ExpressJS, AngularJS, NodeJS.
So, its components are :

M – MongoDB – Data Storage (NoSQL Database)
E – ExpressJS – Web Application framework (Backend framework)
A – AngularJS – Frontend framework
N – NodeJS – Web Server

Why MEAN?

So why to use MEAN ? What are the advantages associated with it ? These questions must be striking your head. So, let’s discuss what one can do with the full stack javascript framework, the MEAN.

  • With NodeJS, we don’t need to deploy finished application to a stand-alone web server, instead, web server is included in the application itself and installed automatically with MEAN stack.
  • With NoSQL database like MongoDB, no need to spend time writing complex SQL queries.
  • The shift from LAMP to MEAN is the move from traditional server-side page generation to a client-side single page application orientation.
  • Support for the MVC pattern.
  • Single language (Javascript) to be used for the entire web application.
  • LAMP stack restricts OS to Linux but MEAN brings OS independence. Node.js runs as well on Windows and OS X as it does on Linux.

Prerequisites

Before getting started with MEAN stack, we need to install various MEAN software packages.

  1. Install NodeJS
    $ sudo apt-get update
    $ sudo apt-get install nodejs
    $ sudo apt-get install npm
  2. Install MongoDB
    Visit the MongoDB home page, download the platform-specific installer, and accept
    the defaults as you install MongoDB.

Installing MeanJS

There are two ways to install and get going with MEAN stack:

  1. Clone the git repository:
    $ git clone https://github.com/linnovate/mean.git
  2. Use the yeoman generator : Yeoman is a scaffolding tool. To use it, we first need to install Yeoman or Yo generator.
    • Install Yeoman generator :
                   $ npm install -g yo
    • Once yo-generator is installed , we need to install Mean generator as well:
                   $ npm install -g generator-meanjs
    • Then, to install the new copy of application in your working directory, type the
      following command:
                  $ yo meanjs

This will ask you few questions about your application and will generate it for you.

Installing MeanJS

With yo-generator, one can easily create CRUD module by the following command:
$ yo meanjs:crud-module <module-name>
This command will create both the ExpressJS and AngularJS CRUD modules along with the test cases.

Once you have done setup for MEAN application, you can check its status whether everything has been installed or not by using the following command:
$ mean status

Also make sure you do run the following command to make sure all the dependencies are installed before you run the Node server:
a.) $ npm install – To install all the server side node modules
b.) $ bower install – To install all the client side libraries

Mean Stack Directory Structure

Mean Stack Directory Structure:

App – contains all the server side backend code
Public – contains all the client side code

So, all the ExpressJS code i.e the controllers, routes, views is defined under app directory, whereas the AngularJS related code is contained under public directory.

Post Installation

Once this is done, run the NodeJS server using grunt command and here is your first MEAN application.

Post Installation

I hope I was able to explain everything which is needed for the setup. If you still face any issues, please drop your comments. I would be happy to help. 🙂

Thank you for reading.

You might also like