Thank you for contacting us. We will get back to you shortly.
January 18, 2016 - by Dave Jensen, Founder, Road Rules
Road Rules is a member of Joyent's Node.js Innovator Program, Class of 2015. Guest blogger Dave Jensen is the founder of Road Rules, which provides the most interactive way to stop texting while driving and is written primarily in Node.js. Dave explains why Road Rules selected Node.js and how they leverage the runtime for their innovative new app.
It wasn’t just nostalgia that led to the decision to use Node.js. Several benefits factored into the decision to use Node.js.
NPM. NPM is the package manager for Node.js and is one of the reasons for the popularity and growth of Node.js. NPM makes adding libraries and third party modules super easy, handling all of the dependencies for you. On top of that, as of this writing, there are 225k modules in NPM with 2.5B downloads per month!
Tools. There are Node.js projects that range from small simple libraries to full blown applications. Not only can you run your entire back end on node.js but also you can run other aspects of your engineering operations and online presence with Node.js based software. There are basic libraries like Lodash for various utility functions or Async to help with control flow in your asynchronous code. There are drivers for working with all the SQL and NOSQL databases. There are web frameworks like Express or HapiJS. There are two popular tools for build/task runners, Grunt and Gulp. For testing, there are a few great frameworks such as Mocha, Jasmine, and Lab, which includes code coverage. A great tool for managing your Node.js processes is PM2. You can run a message broker with MQTT using Mosca. If you need a continuous integration/delivery server, then there is StriderCD. You can even use HarpJS for static website generation, Ghost for blogging, and NodeBB for community forums.
Road Rules is an Android app (iOS coming later) that helps eliminate distracted driving by assisting you while you drive. For instance, we detect when you’re driving (using only your phone) and automatically respond to text messages on your behalf.
So how does an native Android app use Node.js? Node.js runs our entire server-side infrastructure. We’re using Restify, but are transitioning to HapiJS, to power the API used by the Android app. The API server communicates directly to MongoDB using the Mongoose ODM as well as Redis, which we use as a time cache. We will, however, be moving to Couchbase using Ottoman in the near future. We are also planning on introducing a microservice platform such as Seneca. The Android app uses MQTT to stream data, such as data for location sharing, and we use Mosca as our message broker and small modules that do work on the incoming data. The front end web application is a separate service from the REST API service and is built with HapiJS. Finally, we also have another small standalone application that powers web based location sharing, which is used in conjunction with the Android app.
One of the more powerful concepts in Node.js is small, maintainable modules. Even though it seems like a lot to keep track of, it’s working out well with our small engineering team. Each small component is easier to test as an individual part. Changes to a module or service won’t cause regressions in other unrelated modules.