This project is the front end for the Crime Data Explorer, using data from 18f/crime-data-api. The Crime Data Explorer is a website that allows law enforcement and the general public to more easily access Uniform Crime Reporting (UCR) data. Over 18,000 city, university and college, county, state, tribal, and federal law enforcement agencies voluntarily report crime data to the program, and the FBI publishes it in annual reports.
You will need node
and npm
to install and run this project.
git clone git@github.com:18F/crime-data-frontend.git cde && cd cde
npm install
The application expects a few environment variables to interact with the API:
CDE_API
- this should be the URL for the API. To use the public API, set this tohttps://api.usa.gov/crime/fbi/ucr
API_KEY
- this should match the key used by the API. If you are using the public API, sign up for an API key at https://api.data.gov/signup/
You can copy the env.sample
file (cp env.sample .env
), fill in your own values, and then make sure to source .env
before running the build process.
Use npm run watch
to start the continuous webpack
processes and a webserver.
You can lint the code with npm run lint
and run tests with npm run test
.
This project is continuously deployed to cloud.gov with every commit to the master
branch. Right now, you can use the application at https://crime-data-explorer.fr.cloud.gov.
Tagged releases are deployed to https://crime-data-explorer-demo.fr.cloud.gov.
A third, and less formal, environment is available at https://crime-data-explorer-staging.fr.cloud.gov. This is for ad-hoc usage and testing.
Use cf push -f manifest/staging.yml
to deploy. Remember that cf
pushes from your local file structure and won't build the app on its own, so make sure you run npm run build
before pushing.
This app follows semver and has tagged releases by version number. You can see all notable changes in CHANGELOG.md.
Though unit test coverage is decent (check with npm run coverage
, as of cdb2340
it was about 77% of all statements), we run through a few basic user scenarios before tagging a release to check the application.
- Load homepage from
master
branch. Can be local or https://crime-data-explorer.fr.cloud.gov - Select "Explorer" from navigation
- Ensure that a trend chart renders to show "Violent Crime rate in United States"
- Select "Alabama" as the location in the left hand side menu
- Select "Robbery" as the crime in the left hand side menu
- Ensure that the URL is now
/explorer/alabama/robbery
- Ensure that a trend chart renders to show "Robbery rate in Alabama, 2004–2014"
- Scroll down and ensure donut charts, histograms, and tables render to show "Robbery incident details in Alabama, 2004–2014"
- Scroll down and ensure there is a section called "About the data"
- Select "Downloads & Documentation" from the navigation at the top of the page or the footer at the bottom
- Select "Alabama" as the "Location" and "2000" as the "Year". Click download and ensure that a
.zip
file is downloaded - Click the "Download data" link for "Hate crime" under "Bulk downloads" and ensure a file called
hate_crime.csv
is downloaded
- Compile the notable changes into the CHANGELOG.md. You can use the
/compare/:lastVersion...master
endpoint on Github. For example, this/compare
link was used to determine the changes inv1.1.0
- Determine if the version should be increased by a major, minor, or patch version
- Adjust the version number in
package.json
accordingly - Submit a pull request without tagging the commit
- Once the pull request is merged, tag the merge commit as
vX.Y.Z
whereX
,Y
, andZ
reflect the same version number as the now merged change forpackage.json
- Push the tag to Github with
git push origin vX.Y.Z
For the MVP launch of this project (Spring 2017), we’ll explicitly support Chrome, Safari, IE 10+, Firefox, and MS Edge.