Node.JS & MongoDB: New Apps Prototyping Highway

This post is also available in: Russian

nodejs

If you have ever started a new mobile app project odds are that you thought about a working prototype right after preliminary mockups were ready. In the context of Lean Startup methodology with its Minimal Viable Product (MVP) concept, it would in no way sound an exageration that making a prototype even before the final design decisions are vital to your project success. Previously, we all had an excuse that making a prototype takes lots of effort. But that’s not true for most of the mobile app projects today. With a prototype you can collect valuable feedback much earlier, making much more conscious decisions in design and app dynamics.

In this post I’m going to describe the usual practice of our projects. We utilize Node.JS and MongoDB to prepare prototypes for all new apps we develop. This involves no significant back end development efforts and gives you a ready to use service in several weeks. In fact, usually you get a scalable architecture as well. So, let’s get deeper into demonstrating a real case study from PhotoSuerte app. It is a photo-messaging app for iPhone that connects users at random. So, let’s not waste your time. Read this post and make a prototype for your next big app!

The idea behind the PhotoSuerte is pretty simple. A user takes a photo and the app delivers it to a random user. That random user could send a photo reply and start a photo chat with the author. Some time ago we have written about making a chat service using Node.JS and Redis. Here we have more sophisticated requirements: user accounts, chat history, media storage, message management. But even such a broad range of features could be quickly developed with Node.js.

The reasons behind Node.js & MongoDB selection are perfectly outlined in this video => http://www.10gen.com/presentations/mongonyc-2011/mongodb-and-nodejs

Node.js can efficiently handle numerous events without serious logic needed. In most cases, this is true and back end just needs to make some small calculations and data processing before putting or getting data in/from a database. Now MongoDB is responsible for scalability you may think more about app dynamics.

So let’s assume you have an app idea and a great desire to implement it. You know that it would be great that your app had a chance to appear in the AppStore. Start making a prototype as early as drawing breathtaking pixels. When you need a backend to test and develop the app dynamics you could easily use Node.JS with MongoDB. In this case you have a simple JavaScript based processor for all incoming requests and a scalable data storage behind. Such an approach will give you some time until your product is very popular and you have more time and resources to invest into the back end.

Probably the best thing in Node.js is that there are thousands of open source modules which you could plug in just in a matter of seconds. They saved me a lot of time and make the process of apps building much more fun. You could test your design assumptions even before your design is complete. By design I mean not only pixels here but the whole UX and app dynamics.

In our case we have just two collections in the database: Users and Photos. Node.js back end handles the following tasks:

  • Authentify users (Facebook, Twitter and VKontakte – the Facebook of Russia and CIS)
  • Handle users’ photo uploads (cloud-based storage)
  • Distribute photos among the users
  • Send push notifications
  • Send email alerts.

I would suggest using Express.js as a base framework to start with. It is pretty simple to make an application on top of it and the architecture is very flexible. For us it was pretty simple to add an CMS Web interface after the app launch.

Social Network based authentication can be handled via the Request module. It is very simple to get Facebook/Twitter profiles on the server side after the client-side authentication. Also there are other plugins for a variety of tasks: APNS module to send APNS messages, SMTP plugin to send email notifications. To manage backend processes we use Supervisord.

For media storage we used our own distributed storage system already well-described in this blog. But you may feel free to integrate any storage into you business logic.

In view of this, all you now need is to implement API method routes and database requests relevant to them. Also, Node.JS offers a huge advantage. JavaScript code could be maintainable by almost any developer with some (however limited it is) OOP expertise.

Conclusions
1. Knowing existing engineering solutions helps. It saves time and lets you focus on really important tasks.
2. Node.JS is ideal for most of server-side prototyping. You can quickly implement your server side logic and focus on user experience instead of engineering tasks which were already solved.

PS
In fact you could speed up a your server prototype development even further. There is a cool open source framework called Deployd which you could host yourself or use their cloud. All you need is just to configure data processing rules for all your back end API methods. Parse is the only cloud based alternative from Facebook. So, if you develop a new app to rock the world, do it as soon as possible with a prototype.

Leave a Reply