GithubHelp home page GithubHelp logo

ascenda_assignment's Introduction

README

Implementation Overview

Flask is used as the backend framework because of its lightweight-ness and customizability for api servers.

mongodb is used as the db because we are dealing with unstructured data.

docker-compose is used for easy setup.

The logic for merging hotel details from different sources is in Models/HotelDetail.py, where the class takes a parameter of available results, then modularizes the addition of individual detail in the form of a class method. This way, they can be modified/added/removed independently of one another.


Setup

Navigate to a desired folder and clone this repo.

git clone https://github.com/hesingon/ascenda_assignment.git

Go to the repo directory, build and run the project with docker-compose.

cd ascenda_assignment
docker-compose build
docker-compose up

At this point, the api should be accessible at localhost:5000/find_hotels

Either hotel_id or destination_id can be passed in a parameter. e.g.

http://localhost:5000/find_hotels?hotel_id=iJhz
http://localhost:5000/find_hotels?destination_id=5432

Note that the two should not be passed together. If they are both present, the server will only handle hotel_id


Configuration & Settings

You can do a few configurations by changing configs/settings.py.

HOTEL_UPDATE_INTERVAL represents, when server receives a request for a single hotel, how much time in minutes the server should check the supplier urls again for any updates of the hotel.

DESTINATION_UPDATE_INTERVAL similarly represents the time in minutes for updating all hotels in the same destination.

SUPPLIERS_ENDPOINTS are the list of supplier endpoints from which the server will check for updates of hotels periodically.


Design Consideration for Performance

  1. Whenever server receives a request, it queries db first. If db does not contain info for that hotel, or it realized that the hotel was last updated a long time ago, it will query all the supplier endpoints to get and merge the latest info. We check for updates for a configurable interval (e.g. every 3 hours or 1 day).

  2. The querying of multiple supplier APIs is done in a multi-threaded manner with aiohttp to minimise request latency.


More possible improvement

  1. We can include redis as an in-memory db on top of mongodb that allows fast retrieval of the more frequently read destinations.

ascenda_assignment's People

Contributors

hesingon avatar

Watchers

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