Challenge Overview

We are giving out bonus payments to every participant that submits and has a score +80. Thus, if you submit and you don't win but your score is +80, we will still pay you a bonus for your efforts.

Faulty operation in buildings is known to waste 15% to 30% of total HVAC energy on average - yet fault diagnostic tools have not been widely adopted by the industry due to the current lack of low-cost, accurate solutions. Kinetic Buildings have developed a technology for detecting and diagnosing faults, that that combines high-level data-driven analytics and component-level diagnostics using a Bayesian network. This combination provides holistic building diagnostics that can be readily conveyed to a building operator using a probabilistic output.

Challenge Overview

You are provided with HTML5 UI prototype and Mongo database schema. You will build the backend that hook the UI prototype with the backend to serve data from the mongo db.

The outcome of the challenge will be a fully functional angluarjs/nodejs application.

Challenge Requirements

NodeJS Framework and Modules

  • - You will use MongoDB, NodeJS, ExpressJS, and AngularJS stack in this challenge.

  • - You are required to use open source node module such as async to deliver a high quality, well organized code.

Mongo Database Schema

  • - You are provided with mongo dump file that contains all the collections needed by the frontend with sample data.

  • - You are expected to add more sample data and re-submit the dump file for testing purpose.

Mapping between UI and Mongo DB

  • - You are provided with a detailed powerpoint file and excel sheet that show you the mapping between the UI fields in each page and the mongo db collections/fields.

  • - You will refer to these documents to understand what fields should be returned, you should only include fields that is mentioned in the excel sheet and exclude other fields from the API response.

Pages and Functionality Requirements

In this section we will detail the pages and backend endpoints required to serve pages with data, you are expected to build REST API in backend that communicate with the Angularjs app in the frontend, so we are detailing the endpoints needed to address that :

  • - Home page

    • - page : #/home

    • - This mainly for navigation, the navigation is explained in the UI prototype.

  • - Building Overview Page

    • - Page : /#/building

    • - Backend requirements :

      • - GET /sites

        • - When opening the page it will call this endpoint to load sites list.

        • - Input parameters are :

          • - search  : represents the search query

          • - sortColumn : represents the column to sort results in ascending order.

        • - Logic :

          • - Retrieve records from “sites” collection.

            • - if search parameter is provided then use mongo $text feature to search the documents.

            • - Sort results by sortColumn parameter in ascending order.

          • - For each site in retrieved sites, retrieve the “pages.stov” record using “site#stID” field.

          • - Refer to “Screen 2: Building Status View” in the mapping excel file for list of fields to return.

          • - Return the result in json format.

      • - GET /site/{id}/faults

        • - When user expand diagnostics we call this endpoint

        • - Input parameters :

          • - id : corresponds to site ID.

          • - sortColumn (optional : default to Description)

          • - sortOrder (optional : default to descending) : ascending or descending

        • - Logic :

          • - Retrieve records from “pages.faults” where id == pages.faults#siteRef  excluding fltAction == Service queue or fltAction == Repaired.

          • - Refer to “Screen 3: Building Diagnostic View” in the mapping excel file for list of fields to return.

          • - return the result in json format.

        • - For “Select an Action” drop down, here are the possible values :

          • - Select an Action. This is set when faults.fltAction is not set or set to “Select an Action”.  

          • - Service queue. This will update the fltAction field, and will be found by the query that populates the service queue screen.

          • - Generate report. This would generate a .pdf file of the report.  This was left off of the scope for this project so it is a dead link for now.

          • - Repaired.  This will be hidden from the fault list, and only displayed in the service queue list.

          • - Ignored.  This will just update the interface display with the "ignored" value.  I would like this to remain on the list, and then the value be returned to "Select an Action" in one week.

          • - Active Test Scheduled.  This would open an interface for active interaction with the building, but this will be developed later, so it is a dead link now.

        • - The fltAction retrieved from faults document will be one of the possible values above, it should be case insensitive.

        • - When user change selected item in this Select an action drop down list it should be updated in backend, so we need this endpoint to do the update :

          • - PUT /faults/{id}/action

            • - Input parameter is :

              • - id (required) : the fault id

              • - action (required) : the new action.

            • - The action value should be one of the possible values (see above)

            • - Update the fault of the provided id to set the new action value.

      • - GET /site/{site-id}/faults/{Id}

        • - When user click on a diagnostic record this endpoint will be invoked to populate the information in expanded panel.

        • - Input parameters :

          • - site-id : represents site Id.

          • - id : represents the fault Id.

        • -Logic :

          • - Retrieve record from “pages.faultDetail” where id == pages.faultDetail#fltRef

          • - Include only the fields needed by front end as mentioned in the excel sheet section “Screen 4: Building Diagnostic - Detail View”.

          • - Retrieve the “equip” document associated with site id, where equip#siteRef == id, and read the eqID value, and tags array, and return array of plot charts names to be rendered.

            • - The arrays should be configurable.

            • - We will have two arrays configurable “ahu-charts”, and “vav-charts” :

              • - The values of each array will be the chart type keys used in the chart mapping configuration , refer to “Plot Charts Details” section below.

            • - if tags contains “ahu” string then array will contain:

              • - operational-mode

              • - mixing-box

              • - coil-Section

              • - supply-fan

              • - return-fan-1

              • - return-fan-2

            • - else if tags contains “vav” string then array will contain :

              • - zone-temperature

              • - damper-operation

              • - reheat-operation

        • - Response will be the faultDetail fields as mentioned above, eqID, and chart-types array.

        • - return the result in json format.

      • - GET /site/{id}/history

        • - This is used to return history chart data.

        • - This endpoint will be called after retrieving fault details to retrieve the history data.

        • - Input parameter :

          • - id : represents the site id

          • - duration : 1 day, 3 days, 7 days, 30 days

        • - We will use different plot collection depends on the duration

          • - 1 day : use plots.one collection

          • - 3 days : use plots.three collection

          • - 7 days : use plots.seven collection

          • - 30 days : use plot.thirty collection

        • - We pull data based on following criteria from the target plot collection, the query is :

          • - db.[collection].find( {sitRef:[id]} , {_id:0, diagHist:1});

      • - GET /plot/{id}

        • - This is used to get plot chart data.

        • - This endpoint will be called after retrieving fault details, for each chart-type in fault details response we will make a separate call to this endpoint.

        • - Input parameter :

          • - id : represents the equipment id

          • - duration : 1 day, 3 days, 7 days, 30 days

          • - chart-type : this should be string field, represents one of the 9 charts to be supported.

        • - We will use different plot collection depends on the duration

          • - 1 day : use plots.one collection

          • - 3 days : use plots.three collection

          • - 7 days : use plots.seven collection

          • - 30 days : use plot.thirty collection

        • - We pull data based on following criteria from the target plot collection :

          • - plot.XX#equitRef == eqID

          • - Lookup the chart configuration based on provided chart-type parameter (refer to Plot Chart Details section).

          • - Return the required information from configuration and the data for the plotted arrays to be rendered.

      • - PUT /fault/{id}/comments

        • - this insert new comment into faultDetails collection.

        • - input parameters

          • - id : the fault id, used to lookup the faultDetail document.

          • - comment : the comment string.

        • - Add new comment item into the faultDetail#comments array, the username will be a dummy value.

  • - Diagnostic Overview Page

    • - Page : #/diagnostic

    • - Backend requirements :

      • - GET /faults

        • - This endpoint is called when opening the screen.

        • - Input parameter :

          • - search  : represents the search query

          • - sortColumn : represents the column to sort results

          • - sortOrder : ascending or descending

        • - Retrieve records from “pages.faults”

          • - Include only the fields needed by front end as mentioned in the excel sheet.

          • - Use mongo $text feature to search documents using the passed in search

          • - Sort results by provided sortColumn and sortOrder.

        • - Return the result in json format.

      • - GET /fault/{id}

        • - This endpoint is called when clicking on a diagnostic row

        • - This is same endpoint used in Building Overview Page (refer to that section).

      • - GET /plot/{id}

        • - This returns the charts plot data.

        • - This is same endpoint used in Building Overview Page (refer to that section).

      • - PUT /fault/{id}/comments

        • - this insert new comment into faultDetails collection.

        • - this is same endpoint used in Building Overview Page (refer to that section)

      • - “Select an Action” drop down logic is same as the one in “Building Overview Page” (see above)

  • - Comfort Overview Page

    • - Page : /#/comfort

    • - Backend requirements :

      • - GET /comforts

        • - this endpoint is called when opening the page.

        • - input parameter :

          • - search  : represents the search query

          • - sortColumn : represents the column to sort results

          • - sortOrder : ascending or descending

        • - Retrieve records from “pages.comfort”

          • - Include only the fields needed by front end as mentioned in the excel sheet (Screen 5: Building Comfort View)

          • - Use mongo $text feature to search documents using the passed in search

          • - Sort results by provided sortColumn and sortOrder.

        • - return the result in json format.

      • - “Select an Action” drop down logic is same as the one in “Building Overview Page” (see above)

      • - GET /site/{siteId}/comforts/{comfortID}

        • - This is called when clicking on a comfort row to get the comfort details and plot data to render the chart

        • - Input parameter :

          • - siteId : the site id

          • - comfortID : the pages.comfort#comID record

          • - duration : 1 day, 3days, 7 days, and 30 days

        • - Retrieve the “equip” document associated with site id, where equip#siteRef == id, and read the eqID value.

        • - Retrieve the “pages.comfort” record that matches the provided comfortID to get siteRef field, and use it to get the details from “db.pages.stov” where pages.comfort#siteRef == pages.stov.siteRef

        • - For plot data, the chart will be retrieved from target plot collection using eqID value as done in other pages plot charts.

        • - Plot chart y-axix will be :

          • - Axis label: “Temperature”

          • - Axis values: based on plot-array values

          • - Arrays to plot

            • - “Zone Temp”

            • - “Htg Stpt”

            • - “Clg Stpt”

  • - Service Queue Page

    • - Page : /#/service

    • - This page functionality is same as  “Diagnostic Overview” page with one additional requirement :

      • - When retrieving faults records we filter it where fltAction == "In Service Queue" or fltAction == “Repaired”.

    • - “Select an Action” drop down logic is same as the one in “Building Overview Page” (see above)

Plot Charts Details

This section explains the plot charts returned based on the passed in equipment tag and plot type parameters in GET /site/{id}/plot endpoint.

The chart mapping should be configurable so it can be easily extended in future, each chart configuration will have these fields :

  • - chart type will be the key for each array item.

  • - value will be json object with following fields :

    • - chart title

    • - left hand axix (optional)

      • - label

      • - value (optional - if missing then it means we will depends on plot arrays values)

        • - min

        • - max

      • - plots

        • - array of “array” names in the plots.xxx to be returned.

    • - right hand axix (optional)

      • - label

      • - value (optional - if missing then it means we will depends on plot arrays values)

        • - min

        • - max

      • - plots

        • - array of “array” names in the plots.xxx to be returned.

Operational Mode Plot Chart

  • - Left-hand y-axis:

    • - Axis Label: “Damper/Valve Pos. (% open)”

    • - Axis values: 0-100

    • - Arrays to plot (these arrays in the plot collection documents we use to retrieve data):

      • - “HW Vlv”

      • - “CW Vlv”

      • - “OA Dmpr”

  • - Right-hand y-axis:

    • - Axis Label: “Temperature”

    • - Axis values: based on the plot-array values

    • - Arrays to plot:

      • - “OA Temp”

Mixing Box Plot Chart

  • - Left-hand y-axis:

    • - Axis Label: “Temperature”

    • - Axis values: based on the plot-array values

    • - Arrays to plot (these arrays in the plot collection documents we use to retrieve data):

      • - “OA Temp”

      • - “RA Temp”

      • - “MA Temp”

      • - “MAT Stpt”

  • - Right-hand y-axis:

    • - Axis label: Damper pos. (% open)

    • - Axis values: 0-100

    • - Arrays to plot (this array in the plot collection documents we use to retrieve data):

      • - “OA Dmpr”

Coil Section Plot Chart

  • - Left-hand y-axis:

    • - Axis label: “ Temperature”

    • - Axis values: based on the plot-array values

    • - Arrays to plot (these arrays in the plot collection documents we use to retrieve data):

      • - “MA Temp”

      • - “SA Temp”

      • - “SAT Stpt”

      • - “PH Temp”

      • - “PHT Stpt”

  • - Right-hand y-axis

    • - Axis label: “Valve position (% open)”

    • - Axis values: 0-100

    • - Arrays to plot (these arrays in the plot collection documents we use to retrieve data):

      • - “HW Vlv”

      • - “CW Vlv”

Supply Fan Plot Chart

  • - Left-hand y-axis:

    • - Axis label: “Fan Speed %”

    • - Axis values: 0-100

    • - Arrays to plot (this array in the plot collection documents we use to retrieve data):

      • - “SF Spd”

  • - Right-hand y-axis

    • - Axis label: “Supply Air Flowrate”

    • - Axis values: based on the plot-array values

    • - Arrays to plot (this array in the plot collection documents we use to retrieve data):

      • - “SA Flow”

Return Fan Plot Chart

  • - Left-hand y-axis:

    • - Axis label: “Fan Speed %”

    • - Axis values: 0-100

    • - Arrays to plot (this array in plot collection documents we use to retrieve data)

      • - “RF Spd”

  • - Right-hand y-axis

    • - Axis label: “Supply Air Flowrate”

    • - Axis values: based on the plot-array values

    • - Arrays to plot:

      • - “RA Flow”

Return Fan Plot Chart

  • - Left-hand y-axis:

    • - Axis label: “Fan Speed %”

    • - Axis values: 0-100

    • - Arrays to plot:

      • - “SF Spd”

  • - Right-hand y-axis

    • - Axis label: “Supply Air Static Pressure”

    • - Axis values: based on the plot-array values

    • - Arrays to plot:

      • - “SA SP”

      • - “SA SP Stpt”

Zone temperature Plot Chart

  • - y-axis

    • - Axis label: “Temperature”

    • - Axis values: based on plot-array values

    • - Arrays to plot

      • - “Zone Temp”

      • - “Htg Stpt”

      • - “Clg Stpt”

Damper Operation Plot Chart

  • - Left-hand y-axis

    • - Axis label “Damper Position”

    • - Axis values: 0-100

    • - Arrays to plot

      • - “Dmpr Pos”

  • - Right-hand y-axis

    • - Axis label: “Zone flowrate”

    • - Axis values: based on plot-array values

    • - Arrays to plot

      • - “DA Flow”

Reheat operation Plot Chart

  • - Left-hand y-axis

    • - Axis label: “Temperature”

    • - Axis values: based on plot-array values

    • - Arrays to plot

      • - “SA Temp”

      • - “DA Temp”

  • - Right-hand y-axis

    • - Axis label: “Reheat Position”

    • - Axis values: 0-100

    • - Arrays to plot

      • - “Rht Vlv”

Validation

Add proper validation for input parameters :

  • - Input parameter if required should not be empty or null.

  • - Input parameter should be in proper format, i.e. datetime.

  • - Validation between callbacks should be properly handled.

Logging

  • Add proper logging for method entry, method exit at INFO level.

  • Add proper logging for input parameters, and return parameters at DEBUG level.

  • Add proper logging for errors in ERROR level.

  • Use winston for logging, make the logging level configurable, and preferred to separate log files by level.

REST API Request and Response

  • - GET endpoints parameters will accept parameters as query strings, in key/value format.

  • - Response should be in json format always.

Hosting

It is preferred if you provide scripts and steps to deploy the application on Heroku.

Documentation

Provide a detailed README documentation for how to setup and configure the application.

Configurations

You are expected to use environment variables to store sensitive information and environment-specific configurations.    

Documents

Provided in challenge forums :

  • - UI prototype

  • - Excel file and powerpoint documents for mapping

Folder Structure and Configuration

Follow this folder structure :

  • - config/    

    • - config.js    

  • - app.js

  • - controllers/

  • - models/

  • - services/

  • - helpers/

  • - README.md

  • - env-sample (don't include .env in your submission)

  • - .. other files if needed

For configuration, we expect routes and other sensitive config will be configured in config/config.js, we prefer if you use node-config module for that. but We will leave it up to you to use the proper approach.

 



Final Submission Guidelines

Deliverable

  • - All source code that implement the requirement.

  • - README in markup language

  • - Verification document contains steps to verify your solution.

ELIGIBLE EVENTS:

2016 TopCoder(R) Open

Review style

Final Review

Community Review Board

Approval

User Sign-Off

ID: 30051633