© 2025. All rights reserved.

Summer Project

August 22, 2013

A Neat Idea

During the last few summers I've dabbled with a few interesting software technologies with no clear goal in mind, never really getting anything significant accomplished. This last summer was a different story. It has been a bit more productive than any of my past few summers.

I got a tutoring position on campus and with it came a small project proposed by my new manager. He required a system to streamline the current question queue system. We threw around a few unclear ideas on how to build the system, and that was the extent of our initial planning. However, we all agreed on the goals of the project.

Project Goals

The three major components were:

  1. A component for students to submit questions.
  2. A component for tutors to view student questions.
  3. A component for managers to track usage statistics.

System Structure

The idea remained in the back of my head and I didn't really start developing it until the middle of the summer when I got into node.js.

I had been dabbling with javascript in the browser with jquery, but hadn't done anything significant. When I found node, I really got into javascript on the server. In one night I prototyped pretty much the entire system. I used mongodb for the database to store stats on the server for each question. I used socket.io for a real time queue that everybody could monitor. I used express for a small REST API that took care of the system communication. I even got a nice tablet interface for student to ask questions with backbone and hammer. Most of the critical components were complete.

Code Snippets

The two libraries made most of the implementation of the major components relatively simple. The use of socket.io allowed for the seamless updates to the question queue and the mongodb node driver allowed for easy statistical tracking. I want to share some interesting code samples which exemplify the usefulness of these libraries.

Firstly, socket.io

// Hook into incoming questions and notify the queue.
app.post('/questions', function (req, res) {

    /* other handler code */

    io.sockets.emit('questions', questions.getQueue());
});

Essentially, every time the REST API gets a post a new questions, I send the entire list of questions to the queue, and it accordingly refreshes its view.

Mongodb for stats

The statistical tracking system can be reduced to the use of the mongodb driver and its ability to upsert. Basically, if the stat is present in the database, then it can simply be updated, else it is initialized, all with a single operation.

// find the collection and upsert the updates
collection.update( { _id: id },

    { $inc: update }, {upsert: true, safe: true},
        function (err, result) {
            if (!err) {
                // success
            } else {
                // catch error
            }
        }
);

Conclusion

What really drew me to this project was that it offered a challenge that was complex enough to keep me interested but not outside the possibility of finishing it before the end of the summer.

This has been mostly true. The majority of the components are implemented, however they lack proper documentation and thorough testing; two major components of quality software. So although the system is implemented, I don't feel comfortable calling is complete.

Overall, it has been a pretty good summer for me in terms of learning new and interesting technologies and applying them to solve a real problem. I hope that the system proves to very useful and efficient

So what was just a few simple ideas turned into a pretty neat project. Currently it is not being used as we wait for funding to buy the necessary hardware (tablets) to implement the system.