M.E.A.N. Stack Development with Vagrant

If you are new to MEAN, I would recommend checking out my MEAN Workshop.

Also checkout my tutorial MEAN stack – A Hands on Tutorial

Recently I started using Vagrant for one of my clients. The requirement was to have a unified working environment for all the developers, so that they can focus more on code and less on the onboarding and setup. So, I built a Vagrant box that is ready to be used for M.E.A.N. Stack development.

If you are new to Vagrant take a look at

In this post, I will show how to consume the mean-box I have created as is and get started with M.E.A.N. development. Later in the post, I will also show how you can build a customized version of your own Vagrant box and then share it with your team.

So, let us get started.

Continue reading

Re-Architecting a Firebase app to work with Node.js and MongoDB

In the last few days, I have see people worrying about two major problems. One of which is what is going to happen when Angular 2.0 releases and next one is how to migrate an existing Firebase code to a Node.js/MongoDB platform.

I am not going to answer problem one, as I don’t know what is going to happen (ahem chaos) but I will try and propose an experimental solution to the second issue on how you can re-architecting a Firebase app to work with Node.js and MongoDB.

I have met a few people who used Firebase to develop their product and hit the market in a short span of time. Now that the product is doing good, they want to stabilize it further and add more features. And they have realized that a few things may not be that easy to achieve using Firebase.

So they have built another layer with Node.js and MongoDB which kind-of replicates the data and performs actions on it. Another solution I have seen is to use apibase – a Node.js module to communicate with Firebase. I was not really satisfied with the solutions.

So, I went back and asked why Firebase and why are you fitting Firebase in your application architecture? Here are 2 major answers

  • Real time data sync
  • Offline storage

After giving the above reasons a good thought, I have come up with the below architecture that will “emulate” Firebase using Websockets and Local Storage inside a Node.js/MongoD.

If this solution gets stable over a period of time, I may create a yeoman/slush generator to scaffold a Node.js/Express.js and a MongoDB app with real time data sync and offline storage capabilities.

For this post, I will use a simple Todo app as an example. You can find the completed code here.

So let us get architecting!

Continue reading

MEAN stack – A Hands on Tutorial

MEAN stack – A Hands on Tutorial

Also checkout a lighter version of the Todo App using DiskDB instead of MongoDB : Building a Todo App with DiskDB

If you are new to MEAN, I would recommend checking out my MEAN Workshop.

Looking for a way to set up Vagrant to work with M.E.A.N. Stack applications? Take a look at M.E.A.N. Stack Development with Vagrant

If you have been working in the  Nodejs/Web development world, you must have heard about MEAN. If you did not, MEAN stands for

  • M – MongoDB
  • E – Expressjs
  • A – Angularjs
  • N – Nodejs

Sweet right! This IMO is the next gen technology stack to build scalable and efficient web applications that uses Javascript on both the server and the client.

In this post, we will be building a simple Todo App. We will be building the app from scratch, which will give you an idea as what component goes where and how to configure it. If you already have taken a stab at MEAN stack generators/frameworks, you must have noticed the complex file structures, and you are not sure which files gets wired to which other file.  We will be demystifying them but in simple a Todo app.

The final product we are going to build will look like

Screen Shot 2014-08-22 at 7.53.26 amScreen Shot 2014-08-22 at 7.53.45 amScreen Shot 2014-08-23 at 8.29.18 pm

You can find a demo here. You can find the complete code here.

So, let us get started.

Continue reading

Koa Monk and Gulp – Getting Started

Koa Monk Gulp – Getting Started

In this post, we will take a look at the basic concepts of Koa and Monk. Then we will scaffold a new Koa Monk project using a Slush (A Scaffolding tool like Yeoman, but uses Gulp for task management) generator named slush mongo written by Antonio & me.

So, let’s get started.

Contents

Continue reading

Ionic Restify MongoDB – An End to End Hybrid App

Ionic Restify MongoDB – An End to End Hybrid App

Build the same Bucket List app without worrying about server side code, check out Creating a Firebase Powered End to End Ionic Application

In this post, we are going to build an End to End Hybrid App, that has a server component and a client component. Our server will be built on top of Node js, with Restify as the server side framework and MongoDB as the data persistence layer. Our Client is a Hybrid App, built with Ionic framework. We then are going to deploy the Ionic app using PhoneGap Build service to generate a Native installer.

The App we are going to build is a Bucket List app. Here a user can register and login. Then s/he can create a few bucket list items. Which would eventually result in

2014-04-27-12-42-23 2014-04-27-12-42-32

2014-04-27-12-44-31 2014-04-27-12-46-08

  2014-04-27-12-46-37 2014-04-27-12-43-37

These images are taken from my Android Samsung Galaxy Note I device. And the performance was okay. But there is a lot of scope for improvement. If you want to dig into the app yourself, click here.

I have deployed the REST server on Heroku, DB on MongoLab and the client is the Ionic PhoneGap Native app!

List of all the REST service endpoints can be found here (needs some cleanup).

If you want to issue a PhoneGap build before diving in, you can fork this repo and submit it here. Download the installer and test it out. Or you can download the installer directly from here.

You can find the complete code here.

Contents

Continue reading

MapReduce in MongoDB

MapReduce in MongoDB

MapReduce in MongoDB tutorial

MapReduce in MongoDB Getting started

MapReduce in MongoDB Example

MapReduce in MongoDB with Node js

In this post, we will take a look at performing MapReduce operations on JSON documents present in MongoDB. We will generate dummy data using dummy-json, a  node package and we will use Mongojs another node package to run MapReduce jobs on that data from our Node application.

For a quick sneak peak, take a look at this runnable (click on the run button).

Contents

You can find the complete code here.

Continue reading

Nodejs Restify MongoDB – Build your own REST API

Nodejs Restify MongoDB – Build your own REST API

Nodejs Restify MongoDB tutorial

Restify GET PUT DELETE POST

MongoDB Mongojs MongoLab

Runnable Demo

In this post, we are going build a Node based REST API for a collection in our application. We will use Restify to handle our server endpoints. Then we use Mongojs to interact with the database. We will be using MongoLab, (a free* MongoDB as a Service) to store our data. To make things a bit more interesting, we will use Runnable to deploy the app and share it with the world.

We will be building a simple product API, where we Create a new product, Read the product, Update the product and finally Delete the product using the traditional REST methods POST, GET, PUT & DELETE.

The final output of this post would be

Screen Shot 2014-04-20 at 4.35.49 pmTo get your hands on the above demo, navigate to myRunnable, scroll to the very end of the page & wait for the terminal to show up. Then run

node client.js

to see the above output.

Contents

You can find the complete code hereNow, Let’s see how we can build the REST API.

Continue reading