Summer 2012 Intern Project System Design

This is another excerpt from this summer’s 31-page intern project report (PDF). All of this was written entirely by our interns, with only some editing feedback from professional Oasis Digital developers or managers.


 

System Design

Server

The team decided to implement a Node.js server. Node.js is a trending web server that runs off of the Google V8 engine. Node’s asynchronous, non-blocking I/O has been a source of its rising popularity. There is a full analysis of Node.js in the Tools section. We used Express.js for the organization of the server. The group used PostgreSQL as the database system for the project. PostgreSQL is a popular, free database system, rivaling MySQL and SQL.  We wrote different API files to organize the server into server calls to the database relating to users, tasks, and graphs. There is an utility file with helper functions including the PostgreSQL module to allow a connection with the database. Interestingly, the client-side HTML is rendered on the server from Jade syntax into proper HTML.

The following code displays the modules that were loaded and used by the server. Obtaining the library files was as simple as including the module names in the Node.js package.json file, and Node.js handles the rest. We only needed to require each module in our main server file, as shown below. We were also able to include our own server files, which housed the routing information for the server calls to the database.

Screen Shot 2014-09-15 at 10.27.29 PM

The main purpose of the server is to take a request from the client and respond with the requested information. In order to do this, the server is largely made up of routes. Each route has a String associated with it which is needed to be appended to the base URL in order for the function to be called on the server. Below is an example of our main route on the server. “Req” stands for the client-request, and “res” stands for the server response. Notice that the server responds to the client by rendering our main Jade file.

 Screen Shot 2014-09-15 at 10.28.25 PM

A large part of the server was to find and display information from the database. The task, user, and graph server files were composed of functions that interacted with the database using a specific SQL call. For example, the function below displays the attributes of a certain task in the database.

 Screen Shot 2014-09-15 at 10.28.42 PM

The function below is a main part of the server. It interacts directly with the PostgreSQL database. Most other functions in the server utilize this function.

Screen Shot 2014-09-15 at 10.29.15 PM

Published by

Oasis Digital Interns

Each summer, Oasis Digital hires a group of high school and college student interns. To learn about the program, visit our summer intern web site.