Giter VIP home page Giter VIP logo

rithm-coding-challenge's Introduction

Rithm Coding Challenge

Requirements

Build a full stack application that does the following:

Backend

Write an API endpoint that returns a filtered set of users from the csv provided below.

  • Your API endpoint URL is /users
  • Your API responds in the above format with valid GeoJSON
  • Your API should correctly filter any combination of API parameters
  • Your API should utilize a database
  • Your API should support paginating the number of resulting users
  • This should be built using Express or Flask
  • Your API should be tested

API Structure

Parameter Description
fav_color Your favorite color
dist Maximum match distance in miles
origin lat/long string of your location
min_age Minimum age preference
max_age Maximum age preference

Given the following request:

GET /users?fav_color=red&dist=100&origin=37.774929,-122.419416&min_age=21&max_age=29

The expected response should contain the following:

{
  "metadata": {
    "path": "/users",
    "query": {
      "fav_color": "red",
      "dist": 100,
      "origin": "37.774929,-122.419416",
      "min_age": 21,
      "max_age": 29
    }
  },
  "num_results": 1,
  "results": [
    {
      "type": "user",
      "locationHistory": {
        "type": "FeatureCollection",
        "features": [
          {
            "type": "Feature",
            "properties": {
              "city": "Oakland"
            },
            "geometry": {
              "type": "Point",
              "coordinates": [-122.2711, 37.8044]
            }
          },
          {
            "type": "Feature",
            "properties": {
              "city": "San Francisco"
            },
            "geometry": {
              "type": "Point",
              "coordinates": [-122.419416, 37.774929]
            }
          }
        ]
      },
      "properties": {
        "id": 1,
        "name": "Taylor Swift",
        "age": 27,
        "fav_color": "red"
      }
    }
  ]
}

All query parameters are optional. If a query parameter is missing or the value is invalid, you should skip the related filter.

All minimum and maximum fields should be inclusive (e.g. min_age=21&max_age=23 should return users with an age of 21, 22, or 23).

Frontend

Your application should have a frontend that displays a form and allows a user to input a favorite color, distance, origin and min and max age. When the form is submitted, a map should render with markers for the location of the users found. You can use Mapbox, Leaflet or any provider for this functionality.

How to Use

To clone and run this application, you'll need Git and Node.js (which comes with npm) installed on your computer. From your command line:

# Clone this repository & the companion backend repo
$ git clone https://jdegand.github.io/rithm-coding-challenge

# Install dependencies
$ npm install

# need to import csv file into mongo database - can input data manually or use mongoimport - check data shape in leaflet.ejs
mongoimport --uri mongodb+srv://<USERNAME>:<PASSWORD>@cluster.mongodb.net/<DATABASE> --collection <NAME> --type csv/json --file <FILENAME> 

# Add MONGO_URI variable in an .env file 
$ npm start

# To test app, you need to run npm start and then in another terminal - npm run test

Thoughts

  • For mongodb geojson, longitude needs to be listed before latitude but leaflet needs latitude before longitude.
  • The shortening of longitude and latitude in the csv causes problems if you want to use a csv converter website. Need to edit the file on github and give them full names before pasting the data in the converter.
  • The ages of all the celebs are wrong in the csv and not just because they are out-of-date - they were wrong initially.
  • Installing mongoimport is convoluted. It is much quicker to manually add the data directly to atlas.
  • I converted the data to geojson with a converter and then input the data one object at a time using the insert button.
  • Client.connect's use of callbacks is deprecated - need to refactor or use 'mongodb-legacy' package.
  • I resisted using mongoose here - it makes it easier to connect to mongo but no other real use in this application.
  • Documentation on using express without mongoose is surprisingly sparse and mostly out-of-date.
  • Need to look into having a variable zoom level on a leaflet map.
  • (0,0) location is all blue ocean and you can be fooled thinking the map didn't load in correctly. It would better to have a more zoomed out view for that case.
  • $gt / $lt is not inclusive - need $gte / $lte
  • meters to miles - divide by 1609
  • miles to meters - multiply by 1609
  • Had many failures on getting the right formula to test this app
  • A Mocha and Chai implementation similar to the RedditJS tests did not translate to this app.
  • Mocha and Chai (in particular) seems to be an outdated way of testing.
  • Mixing promises and callbacks seems to cause problems with chai.
  • Had to search on github to find something that would work when testing the application
  • Tests are similar to this
  • Instead of using cheerio, could have used a jquery plugin
  • I am sure there are better ways to test this but I don't want to devote a ton of time to this
  • If I had used react, I would have used cypress

Screenshots

Useful Resources

rithm-coding-challenge's People

Contributors

jdegand avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.