Relating Data about Congress
Congrelate, a project of the Sunlight Labs, is a web app and data aggregation framework written in Sinatra. At its core, Congrelate is a dynamic, sortable spreadsheet of data about Members of Congress.
By pulling in other sets of data about campaign contributions and voting records, a user can quickly answer questions like: “Which women voted against the Lily Ledbetter Fair Pay Act?” or “Which industries are the largest contributions to members of the Senate Finance Committee?”.
Congrelate accomplishes this by pulling together data from various sources. Currently, the standard data sources used are:
- Sunlight Labs API for basic information on members of Congress and the committees they sit on.
- US Census data for demographic information on congressional districts.
- OpenSecrets.org for industry contribution data.
- GovTrack.us for congressional vote history.
Getting Set Up
Congrelate uses Sinatra for the basic web framework, and jQuery to power the dynamic data table. See
- Required gems: sinatra, htmlentities, activerecord, activesupport, open-uri, json, fastercsv, hpricot, httparty, technicalpickles-daywalker (from GitHub).
- Set up a database, copy
config/database.ymland modify as needed.
- Register for a Sunlight Labs API key.
sources/api_keys.ymland add your Sunlight API key for “legislator”.
- OpenSecrets.org releases their data under their OpenData initiative (as a zipped up CSV file). To get this, sign up for an account at OpenSecrets.org and download the 2008 Campaign Finance data set here. Unzip that into
data/opensecrets/, so that the .csv files are in
- A simple
rake sources:updatewill update all data sources according to their time-to-life values in
ruby congrelate.rbwill fire up the app on port 4567.
Developing Your Own Data Sources
We strongly encourage you to fork this code and contribute your own data sources to the project! In five easy steps:
- Create a new directory in
- Write the database migration and pop it in
- Write an ActiveRecord model that defines class methods for sorting, updating, and generating columns for the data, and any other helper classes you need
- Write the form HTML for the pop-up that lets the user choose from your data (view helpers provided)
sources/sources.ymlwith the details of your new source
sources/example/ directory for details.