Arlen Stalwick

Software Developer

Hey there, I'm Arlen Stalwick, VP Engineering @ Wavo.me. I write about my projects and whatever it is that I'm trying to teach myself.


Realtime Node.js and Backbone Boilerplate Code

I've had to do a few projects lately that require using Socket.io as the primary transport for single page apps communicating with a server. Having looked around a bit on the web, there are not a whole lot of examples as to how to do this using Backbone.js. So, I've created a sample app / boilerplate code project on github.

Link: https://github.com/astalwick/realtime-node-boilerplate

The goal of the project is to provide the basic structure of a realtime app, so that next time you're thinking about starting a Socket.io based project, you're all set to go. It does this in the form of The World's Worst Todo List, a crazy-ugly todo list app. The todo list part is really just there to show how to wire things ups - the whole point of this thing is that you'll tear the todolist functionality out, and replace it with something useful.

The realtime functionality is accomplished by swapping out Backbone.js' sync() function, which is normally designed to communicate via http with REST endpoints, with a version that uses Socket.io. The heavy lifting has already been done - I've used Backbone.ioBind here.

The other advantage of this project is that it breaks the client and server up into a (to me, anyway) relatively logical folder structure for a serious single-page Node.js app. You're good to go with a folder structure that should scale up with your app. It's quite similar (small variations) to the folder structure we use at Wavo.me.

Now, it's really a brand new project for me, so it's imperfect - there are bugs, and the code could use another pass. Nevertheless, it'll get you started.

comments powered by Disqus