HabitRPG: Gamify Your Life
HabitRPG adds fun to habit-tracking, todo lists, and GTD by gamifying your life, turning your goals into a Role Playing Game. Level up as you succeed, lose HP as you fail, earn money to buy weapons and armor. It’s open source and constantly improving.
JavaScript, of Course!
Habit’s built on Derby, a real-time Node.js framework. Derby employes Node, MongoDB, Socket.IO, and an Angular-like client MVC with model-view bindings and real-time persistence. I’m sure you’ve heard of Meteor – they’re direct competitors. Frienemies even.
Choosing Derby took weighing pros and cons. On the one hand, it does so much stuff for you – the app was an absolute breeze to write. It seems like magic at first that variable bindings in your HTML are automatically persisted to the database and reflected real-time in other browsers, with a simple <input type=”text” value=”{edit_me}”/>. On the other hand, the framework is quite young, and Habit has seen many hard issues only to find them fixed with the next derby#master push.
Would I do it again? Absolutely.
Hosting
At first Habit was hosted on Heroku. Heroku doesn’t support Websockets, but Socket.IO has a fallback option of XHR-polling. In my limited load testing, I in fact found that XHR-polling supported more concurrent users than Websockets; and the real-time communication was sufficiently fast for my needs (you’d be surprised!). However, you HTML5 multiplayer game devs will probably prefer Websockets – you need every ounce of real-time speed you can get. In that case, you can’t user Heroku.
Now, Racer (Derby’s database driver) doesn’t yet support session-handling over multiple processes, which Heroku and Nodejitsu use for horizontal scaling. As a result I recommend either Appfog (which gives you a comparatively beefy single instance for free) or custom hosting – we’re using Liquid Web, but of course there’s AWS. Incidentally, Derby doesn’t use that many resources – 512MB-1GB RAM and ~50% CPU utilization at my peak load (I don’t have proper metrics, sorry). The biggest concern with scalability ended up being MongoDB. Add your indexes and optimize your set() operations! See this article for more.
A Leg Up
Other things I’m using:
- BrowserQuest creative commons icon set
- Bootstrap