GithubHelp home page GithubHelp logo

guoyu07 / hotel-search-agoda Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bajaj/hotel-search-agoda

0.0 0.0 0.0 25 KB

agoda sde test

License: Other

Scala 60.78% HTML 38.80% JavaScript 0.42%

hotel-search-agoda's Introduction

Http service for hotel search

Test for Agoda SDE.

Usage

$ sbt run

Sample respone for hotelSearchApi: http://localhost:9000/hotel/search?apiKey=cool&cityName=Ashburn&sort=DESC

[
  {
    "hotelId": 22,
    "room": "Sweet Suite",
    "price": 14000
  },
  {
    "hotelId": 21,
    "room": "Deluxe",
    "price": 7000
  },
  {
    "hotelId": 20,
    "room": "Superior",
    "price": 4444
  },
  {
    "hotelId": 17,
    "room": "Deluxe",
    "price": 2800
  },
  {
    "hotelId": 25,
    "room": "Deluxe",
    "price": 1900
  },
  {
    "hotelId": 12,
    "room": "Deluxe",
    "price": 1800
 },
  {
    "hotelId": 7,
    "room": "Deluxe",
    "price": 1600
  },
  {
    "hotelId": 24,
    "room": "Superior",
    "price": 1400
  },
  {
    "hotelId": 3,
    "room": "Sweet Suite",
    "price": 1300
  },
  {
    "hotelId": 5,
    "room": "Sweet Suite",
    "price": 1200
  },
  {
    "hotelId": 10,
        "room": "Superior",
        "price": 1100
      },
      {
        "hotelId": 19,
        "room": "Superior",
        "price": 1000
  },
  {
    "hotelId": 16,
    "room": "Superior",
    "price": 800
  }
]

Incase of rate limit execeeded.

 HttpStatus Code: 429 (Too many request)
 Rate limit crossed

Assumption

  • Search will be made by city name rather than id as mentioned in the test

Architecture

         
   Client Request
        |
        |
        v
+------------------------+  Check rate limit   +--------------------+        
| HotelSearch Controller |-------------------->| RateLimit Service |
+------------------------+                     +--------------------+     
        |                                               | 
        | After success rate limit                      | get config for api-key
        v                                               v
+---------------------+                       +-----------------------+
| HotelSearch Service |                       |    Config service     |  
+---------------------+                       +-----------------------+
        |
        |
        v
+-----------------------+
| HotelSearch DataLayer |
| (reads from csv)      |
+-----------------------+

     

Components & Data Structures

  • Hotel Service

    • Caches the hotel data returned from the hotel data layer
    • It used Concurrent Trie map for storing the info. Key been the city name and value is the list of hotels
  • RateLimit Service

    • Stores the request details with respect to apikey
    • for each api key its stores list of request. For storing this it uses concurrent trie hashmap
    • It also stores the suspended state of the apikey.
  • Config service

    • Stores key value pair. It uses concurrent trie hashmap of the same.

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.