code-challenge icon indicating copy to clipboard operation
code-challenge copied to clipboard

Parserator challenge

Open NoahAppelbaum opened this issue 1 year ago • 0 comments

Overview

This PR consists of two major parts:

  • A backend JSON API endpoint, which parses U.S. address strings using usaddress
  • JavaScript for the previously built static frontend, which provides a simple form for a user to enter an address, calls the API, and renders the returned parsed address information in the UI

This PR also includes tests for the API endpoint, and a few other small fixes and adjustments (enumerated below)

Closes #XXX

Demo

Functioning app with network request: Screenshot 2024-07-12 at 10 40 56 AM

Displaying an error message: Screenshot 2024-07-12 at 10 41 33 AM

Tests passing Screenshot 2024-07-12 at 10 42 45 AM

Notes

Other changes:

  • Added npm to the apt-get... line in the Dockerfile, to fix an npm not found error when building
  • In the Index.html template, changed the inline display: none styling on the address results div to use Bootstrap's d-none utility class. This maintains consistency with the rest of the page's styling, and makes manipulating the div's styling through JavaScript more straightforward.
  • This coding challenge was completed by me, Noah Appelbaum

Testing Instructions

How to Test

  • Build with
    docker-compose build
    
  • Run tests with
    docker-compose -f docker-compose.yml -f tests/docker-compose.yml run --rm app
    

New Test Cases

  • test_api_parse_succeeds -- The API should respond successfully, with expected JSON, on a valid address
  • test_api_parse_succeeds_on_empty_string -- the API should respond successfully on an empty string, consistent with the output of usaddress and expected frontend behavior
  • test_api_parse_raises_error -- The API should raise an error on an invalid address input
  • test_api_parse_raises_error_on_missing_address_string -- The API should raise an error when missing address input (from a malformed request, e.g.)

NoahAppelbaum avatar Jul 12 '24 16:07 NoahAppelbaum