I created an endpoint that returns a list of GeoJSON objects based on the filters given. The project is deployed on Heroku. Here is a sample url: https://lita-listing-app.herokuapp.com/listings?min_bed=3&max_bed=5&min_bath=3&max_price=200000
It took me a total of 4 hours to get everything working, with unit tests. Unfortunately, setting up Heroku took more time than expected, as I am not familiar with it.
All the endpoints are defined in routes.py.
The model of a Listing is define in models/listings.py
I created a migration script to insert all the data from the CSV file to MongoDB. This is something I have to run manually once using a one-off Dyno. If you were to deploy this yourself to Heroku, you will need to run the following commands:
heroku run bash
<< Once inside the Dyno>>
python manage shell
>> from listings_migration import run
>> run()
This will kick off the migration.
To run the tests, enter the following command:
py.test tests/
I ended up using Flask with Blueprints, JSON Schema for validation, and MongoDB as my data store. I like Flask with Blueprints, as the routing maps directly onto the function call. I also like JSON Schema, because the json file acts like an API documentation. I ended up using MongoDB for the sake of ramp up time. I am familiar with it, and it was really quick to set up. MongoDB also has a geo-spatial indexes, which might be a useful feature for querying locations of the houses.
If I had more time, I would love to work on pagination of the results, since the endpoint is super slow as it is querying a lot of data. This would be the highest priority.
Secondly, I would like to add a nearby feature, where you can give it a lat/lng and a radius, and it will return houses near that area.
Lastly, I would love to add a front-end portion to the API. This would be a lot more work, but I think it would be fun.