GitHub - pastor-methods/prototype-frontend: Open statistics prototype

Build Status Dependency Status Code Climate License Badges

This is a prototype application that explores ideas for publishing statistical data on the web. The application was built by the Open Data Institute on behalf of the Office of National Statistics. The background on the project and the ideas being explored have been captured in this blog post.

A demonstration version of this application can be found at:

http://open-statistics.herokuapp.com/

Application Components

The application is made up of three components:

The application is intended to be backed by a Mongo database which stores the underlying statistical data.

The API provides views over that data for use in the prototype website or, potentially, other applications.

The prototype used some sample ONS data. There are scripts for downloading, converting and populating a Mongo database with this data.

All of the components are written in Ruby. Both the web application and the data API are simple Sinatra applications.

The demo version of the site has been deployed to Heroku.

For more detail on the design and implementation of each of the components, consult the repos referenced above.

The rest of this README has some notes on how to deploy the frontend only.

Application Overview

The frontend is a Sinatra application with templates that use ERB.

The data used to build the pages is retrieved from the statistical API using ActiveResource as the client library. This provides a simple (but limited) way to retrieve data from JSON based APIs.

The time series graphs are displayed using the Rickshaw time series charting library.

Deploying the Frontend

Note: to develop with the front end application you will need to have a copy of the data API deployed, see the API deployment notes in the ons-data-api project.

The API could be running locally, to give a complete sandboxed environment. Or several developers could share an API deployed to a shared location.

Installation

First install the basic dependencies:

This provides a basic environment. To install the ruby libraries used in the application run:

This will install all of the necessary dependencies which are listed in the Gemfile.

There are no direct code dependencies between the frontend application and the other components, the application just uses the API to retrieve the required data.

Running the Application Locally

The application needs to know the location of the API. This is configured using an environment variable DATA_API_URL. This needs to be set to the base URL of the API, including the port if necessary. E.g:

export DATA_API_URL=http://localhost:3000

The application can then be run as a Rack application, using the configuration from config.ru:

By default this will start the application on http://localhost:9292.

Running the Application on Heroku

All of the configuration is in place to run the application on Heroku. Read the Heroku documentation on deploying Rack based applications and setting environment variables.