Challenge Overview

Challenge Overview

 

The goal of this challenge is to build a node.js frontend web application that communicate with DataBus REST API and draw charts using google chart and angularjs.

Challenge Requirements

You will use the following technology/frameworks in this challenge :

  • Web application will be built using Express.JS, and HTML5 with AngularJS/Bootstrap UI.

  • We are using google charts to render charts in frontend.

  • Databus REST API to retrieve data to render as google charts.

  • Apache web server will be used as reverse proxy for the web application.

  • MongoDB for persisting user data, and any other required data.

User Model

  • User model will hold the following information :

    • username (this will be same as Databus username)

    • password (should be encrypted used crypto nodejs lib)

    • apikey  (the Databus user apikey)

    • tableNamePrefix (represents the user table name prefix in Databus)

  • Create a CRUD service for User model.

  • Write a JS script that allows creating a user in DB from command line (terminal) with fields passed in as arguments.

  • Use proper ORM nodejs module for interaction with MongoDB.

Creating Databus tables

Provided in challenge forums a csv file with data to be populated in three time series tables :

  • The file contains 4 columns

    • uts -  unix time stamp, in milliseconds (the DataBus standard)

    • kW  -  building usage, kilowatts

    • cs  -  battery activity (charge +, discharge -), in kilowatts; max/min = +/- 9

    • soc -  state-of-charge, kilowatt-hours; max/min = 0/50

  • You will create 3 tables: 1 for each of kw, soc,and cs; and each of these tables will have 2 columns: 1 for the time stamp (a Unix-like timestamp in milliseconds, provided by uts in the sample file) and 1 for the actual value (kW/cs/soc).

  • table name should be in this format {Prefix}{column-name-from-csv} i.e. topcoderkw (where prefix is ‘topcoder’ and column-name-from-csv is kW), the prefix will be stored in the user model.

    • The reason we need a prefix because DataBus does not allow duplicate table names across databases, so we need a unique name for each user, so a prefix is proper method for that. so three tables for ‘topcoder’ prefix would be

      • topcoderkw

      • topcodercs

      • topcodersoc

This page document how to create database via UserInterface, and creating tables via API http://buffalosw.com/wiki/provisioning-databus-2/ (you cannot create a table via User Interface)

Google Charts

We will create three charts types :

  1. kW table

    1. A line plot chart for the whole month with appropriate date time tics (not uts).

  2. cs  table

    1. A dial chart - value at time stamp 1414717200000

  3. soc table

    1. A bar  chart -  value at time stamp 1414553400000 (fully charged bar is green, fully discharged is red)

Each chart to be rendered in the frontend page should have the following :

  • Separate chartGenerator controller, html, css, and javascript.

  • chart metadata and labeling for items and units should be included in the chart rendering.

    • Based on chart type, you can come up with the needed meta/information. We are open to your creativity here.

  • When page loads, each chat javascript will call backend to retrieve data and render the chart.

    • The javascript will render a google chart

    • create a time interval in js to keep pulling new data and re-render chart every few seconds.

  • This code design is important to follow as we will change/update chart code, and add more charts in future.

  • chart generator is expected to

    • read the username from session, validate it by calling user service, if user does not exist, then return Not Authorized error

    • retrieve user object via user service

    • using the prefix table name call Databus API to download data

    • Retrieved data from DataBus should be structured it for the google chart type, and send it back to caller.

Required Pages

  • Login page

    • There is no reset password or sign up

    • The page displays username/password

    • Make sure to render error login message properly

  • Landing page

    • User must be logged in to access the page

    • It will display the 3 charts in scope in this challenge.

    • The controller is expected to hold reference to chart generators.

      • we will add more charts in future, we want to make the efforts minimal to do it, we prefer that we can inject charts into controller, but we are open to your creativity.

    • the frontend view will include charts js/css/html to the page.

Sample Data Script

  • The sample data for testing should be created as a csv file.

  • Write a command line script that upload the sample data that can run as cron job to generate random data and upload it to the DataBus API.

    • this is important so we can show a realtime update in the frontend charts.

  • The table name and file name should be provided as input arguments

Apache Server

  • Update apache configuration to host the express.js web application.

  • You must provide the updated configuration in your submission.

Folder Structure

You can follow the default folder structure generated by expressjs application generator.

Configuration and environment variables

  • You can use node-config for configurations

  • All sensitive information should be placed in environment variables.

  • Configuration will include

    • routes

    • MongoDB connection information.

    • .. other configuration as needed.

Ubuntu AWS VM

We have Ubuntu AWS VM Image that has DataBus deployed to it, it’s dependencies, and apache server.

You can request a VM in the challenge forums, or you can ask to share the AWS Image with your AWS account, or you can follow the provided deployment document to deploy to your own local ubuntu machine.

Document

The sample data file is provided in challenge forums.



Final Submission Guidelines

.

Deliverable

  • All source code and configurations that addressed the requirement above.

  • README deployment document.

ELIGIBLE EVENTS:

2015 topcoder Open

REVIEW STYLE:

Final Review:

Community Review Board

Approval:

User Sign-Off

SHARE:

ID: 30049127