What is MEAN Technology

So, what is a MEAN stack? The idea is quite simple actually – there are 4 main parts:

These are some of the advantages of a MEAN stack:

  • Single language is used in the whole application
  • Support for the MVC pattern
  • JSON is used for transfering data
  • Node.js’s huge module library
  • Open source so you can tweak it to your preferences if you’re an experienced user

OK, enough with the chit-chat, now we’ll go and install all the necessary parts.

How to Install and Configure MongoDB on Ubuntu

Import the public key used by the package management system.

The Ubuntu package management tools (i.e. dpkg and apt) ensure package consistency and authenticity by requiring that distributors sign packages with GPG keys. Issue the following command to import the MongoDB public GPG Key:

1.
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6

2. Create a list file for MongoDB.

Create the /etc/apt/sources.list.d/mongodb-org-3.4.list list file using the command appropriate for your version of Ubuntu:

Ubuntu 12.04
echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
Ubuntu 14.04
echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
Ubuntu 16.04
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list

3. Reload local package database.

Issue the following command to reload the local package database:

sudo apt-get update

4. Install the MongoDB packages.

Install the latest stable version of MongoDB.

Issue the following command:

sudo apt-get install -y mongodb-org

Run MongoDB Community Edition

Most Unix-like operating systems limit the system resources that a session may use. These limits may negatively impact MongoDB operation. See UNIX ulimit Settings for more information.

The MongoDB instance stores its data files in /var/lib/mongodb and its log files in /var/log/mongodbby default, and runs using the mongodb user account. You can specify alternate log and data file directories in /etc/mongod.conf. See systemLog.path and storage.dbPath for additional information.

If you change the user that runs the MongoDB process, you must modify the access control rights to the /var/lib/mongodb and /var/log/mongodb directories to give this user access to these directories.

1. Start MongoDB.

Issue the following command to start mongod:

sudo service mongod start

2. Verify that MongoDB has started successfully

Verify that the mongod process has started successfully by checking the contents of the log file at/var/log/mongodb/mongod.log for a line reading

[initandlisten] waiting for connections on port 

where is the port configured in /etc/mongod.conf, 27017 by default.

3. Stop MongoDB.

As needed, you can stop the mongod process by issuing the following command:

sudo service mongod stop

4. Restart MongoDB.

Issue the following command to restart mongod:

sudo service mongod restart

5. Begin using MongoDB.

To help you start using MongoDB, MongoDB provides Getting Started Guides in various driver editions. See Getting Started for the available editions.

Before deploying MongoDB in a production environment, consider the Production Notes document.

Later, to stop MongoDB, press Control+C in the terminal where the mongod instance is running.

Native Mongodb management tool or admin UI

Robomongo is a shell-centric cross-platform MongoDB management tool. Unlike most other MongoDB admin UI tools, Robomongo embeds the actual mongo shell in a tabbed interface with access to a shell command line as well as GUI interaction.

How to Install Robomongo

Click here to download robomongo tool. here is steps for connecting to mongo db

To add your DocumentDB: API for MongoDB account to the Robomongo MongoDB Connections, perform the following steps.

  1. Retrieve your DocumentDB: API for MongoDB account connection information using the instructions here.Screen shot of the connection string blade
  2. Run Robomongo.exe
  3. Click the connection button under File to manage your connections. Then, click Create in the MongoDB Connections window, which will open up the Connection Settings window.
  4. In the Connection Settings window, choose a name. Then, find the Host and Port from your connection information in Step 1 and enter them into Address and Port, respectively.Screen shot of the Robomongo Manage Connections
  5. On the Authentication tab, click Perform authentication. Then, enter your Database (default is Admin), User Name and Password. Both User Name and Password can be found in your connection information in Step 1.Screen shot of the Robomongo Authentication Tab
  6. On the SSL tab, check Use SSL protocol, then change the Authentication Method to Self-signed Certificate.Screen shot of the Robomongo SSL Tab
  7. Finally, click Test to verify that you are able to connect, then Save.

How to Install Express

Assuming you’ve already installed Node.js, create a directory to hold your application, and make that your working directory.

$ mkdir myapp
$ cd myapp
Use the npm init command to create a package.json file for your application. For more information on how package.json works, see Specifics of npm’s package.json handling.

$ npm init
This command prompts you for a number of things, such as the name and version of your application. For now, you can simply hit RETURN to accept the defaults for most of them, with the following exception:

entry point: (index.js)
Enter app.js, or whatever you want the name of the main file to be. If you want it to be index.js, hit RETURN to accept the suggested default file name.

Now install Express in the myapp directory and save it in the dependencies list. For example:

$ npm install express –save
To install Express temporarily and not add it to the dependencies list, omit the –save option:

$ npm install express
Node modules installed with the –save option are added to the dependencies list in the package.json file. Afterwards, running npm install in the app directory will automatically install modules in the dependencies list.

How to Install Nodejs

Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Latest version node.js ppa is maintaining by its official website. We can add this PPA to Ubuntu 16.04 LTS (Trusty Tahr) and 14.04 LTS (Xenial Xerus) Systems and install node.js with few easy commands.

Step 1: Add NodeJs PPA

First, you need to node.js PPA in our system provides by nodejs official website. We also need to install python-software-properties package if not installed already.

$ sudo apt-get install python-software-properties
$ curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash –
Step 2: Install Node.js and NPM

After adding required PPA file lets install Node package. NPM will also be installed with node.js. This command will also install many other dependent packages on your system.

$ sudo apt-get install nodejs
Step 3: Check Node.js and NPM Version

After installing node.js verify and check the installed version. You can find more details about current version on node.js official website.

$ node -v

v7.5.0
Also, check the version of installed npm.

$ npm -v

4.1.2
Step 4: Create Demo Web Server (Optional)

This is an optional step. If you want to test your node.js install. Let’s create a web server with “Hello World!” text. Create a file http_server.js

$ vim http_server.js
and add following content

var http = require(‘http’);
http.createServer(function (req, res) {
res.writeHead(200, {‘Content-Type’: ‘text/plain’});
res.end(‘Hello World\n’);
}).listen(3001, “127.0.0.1”);
console.log(‘Server running at http://127.0.0.1:3001/’);
Now start the web server using below command.

$ node –debug http_server.js

debugger listening on port 5858
Server running at http://127.0.0.1:3001/
The web server has been started on port 3001. Now access http://127.0.0.1:3001/ URL in browser. Now you will need to configure a front end server for your app.

Why do we need event driven architecture

A software system with an Event-Driven Architecture (EDA) is built around the idea that events are the most significant elements in the system and that they are produced somewhere in the system and consumed somewhere else in the system. The business value is that you can easily extend such a system with new things that are ready to produce or consume events that already are in place in the system. Of course, you can add new events as you go.

Yes, this is absolutely great. If you build something new there is no reason why you shouldn’t use this kind of architecture. However, focusing on the events is not the only thing you should do.

Instead, you should just build an architecture in which you have components or services and some kinds of “channels” between some of these components. Over a channel an event can flow from one component — the producer — to another one — the consumer. These components are loosely coupled and can exist in a distributed world. Some of these events are such that you broadcast them to anybody that has subscribed to them.

Thus don’t constrain your architecture to just be event-driven. There is really no money to save by doing just that. Let it be components with channels. The channels I am talking about were already adopted in the telecom standard SDL back in 1982. In EDA, it is basically a mechanism for brokering events. In the OMG standard CORBA from the early 1990s, it was called the “Event Service”. What a coincidence! Actually one way of thinking about EDA conceptually is really that it is all that CORBA was meant to be, but in the Web/Internet world.

The most interesting components are services. You get service-oriented architecture (SOA) at the same time, and more.

However, those of you who think this is fundamentally new have really not done your homework. It is probably true that the three letter combination EDA is new as it was for SOA. We have also got some new great platforms that make it easier to implement these ideas.

Over the years I have seen trends in the component world that put more focus on the components than the channels (and thus the events) between them. Other times it has been the other way around. However, there is absolutely no reason to choose. You should allow for both. But what we don’t need are more buzzwords. They don’t help us at all.

To summarize, you should go for a component architecture without any compromises. This is what made the Ericsson AXE system such an incredible success story more than 30 years ago. And thanks to its architecture, it is still probably the best selling product of its kind in the world. However, Ericsson had to build its own infrastructure managing components with channels since such solutions didn’t exist at the time.

Of course, this is still new to people who have not previously developed a component architecture. Thus those people have to come up to speed and that means training and mentoring. And to start with, you need some good technical practices. It is as easy as that!