Giter Site home page Giter Site logo

orchard-backend's Introduction

orchard-backend

This is the implementation of the backend for the orchard restaurant assessment dataset.

How it works and what it does

This repo:

  1. Creates an SQLite database based on the https://nycopendata.socrata.com/api/views/xx67-kt59/rows.csv?accessType=DOWNLOAD dataset.
  2. Starts an endpoint to retrieve top 10 restaurants (based on the date of grading and no worse than a grade of 'B') based on the cuisine provided.

Installation

  1. Install the dependencies. This project uses Python 3, so all the modules have to be Python 3 version.

    Run:

    pip install pandas sqlalchemy flask

    This should install all the necessary dependencies for Python.

    Also, make sure your machine has an Apache server up and running.

    If it doesn't, consider following the following instructions:

    On Ubuntu:
    sudo apt install apache2
    sudo service apache2 start
    Macs come with Apache server by default, but in case it is not running, run the command:
    sudo apachectl -k start
    On Windows:
    Watch this video https://www.youtube.com/watch?v=A_NGnq31d18

  2. Create the database: Make sure the dataset is in the same directpory with the python scripts(in the repo directory.) Then run:
    python db.py
    This will create the database file as well as initialize the model for the database.
    Then run:
    python etl_job.py
    This will load the data into the database with the following schema:

    #restaurant model 
    class Restaurant(Base):
        __tablename__ = 'restaurants' 
        id = Column(Integer, primary_key=True, autoincrement=False) 
        name = Column(String) 
        boro = Column(String) 
        building = Column(String)
        street = Column(String) 
        zip = Column(Integer) 
        phone = Column(String) 
        cuisine = Column(String)
      
    
    #inspection model
    class Inspection(Base): 
        __tablename__ = 'inspections' 
        id = Column(Integer, primary_key=True)
        rest_id = Column(Integer, ForeignKey(Restaurant.id))
        inspection_date = Column(Date)
        action = Column(String)
        violation_code = Column(String) 
        violation_desc = Column(String) 
        is_critical = Column(Boolean) 
        score = Column(Integer) 
        grade = Column(String) 
        grade_date = Column(Date)
        record_date = Column(Date)
        inspection_type = Column(String)
    
  3. Finally, to start the endpoint handler, run: python microservices.py This will start the backend running.
    The service is available at route: http://host:port/best-places?cuisine=YOUR_CUISINE

   # NOTE
   If you want the app to run on a specific port, change this line in microservices.py:
        app.run(host='0.0.0.0')
   To
        app.run(host='0.0.0.0', port=YOUR_PORT)

orchard-backend's People

Contributors

alexloyko 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.