justjs: node.js tutorials

New here? You might want to start at the beginning.

7/8 '12

vidmood: a new wave web app

After a long wait, we have a shiny new sample project: vidmood. vidmood lets you share your moods in the form of wacky YouTube videos. It is (or will be) social, it's fun, and most importantly it demonstrates a different approach to building web apps with node.

The blog application was a traditional web app, in the style of Ruby on Rails or Symfony 1: a big web application server rendering lots of HTML for each individual URL the user can access.

vidmood is different. vidmood follows the new wave approach taken by web apps like twitter and gmail. When you visit the home page, you receive a web page... and that's the last time you receive a new web page (except for the Twitter login process).

Instead, that web page contains a JavaScript application in its own right, perfectly capable of asking the node app server for the resources it needs. When the JavaScript code in the browser wants to post a new "mood" to the site, it does that via an AJAX request. Updates to the live feed of "moods" are also received via AJAX. And rather than sending "fully baked" HTML for these AJAX updates like early AJAX applications did, the server just responds with data in JSON format.

What does all this mean? It means that vidmood is fast, and easy to scale. The server does as little work as possible. The browser does all that heavy lifting shifting HTML elements around. All the server has to do is provide access to data. In a nutshell, the server is the model layer.

I'll be covering the code line by line over the next few days. But if you're curious, you don't have to wait! You can check out the source code now, or just play with the first version of the vidmood app.

 

blog comments powered by Disqus