Coder Social home page Coder Social logo

brewery-react-app's Introduction

A brewery react app that implements search functionality. The user can search the breweries based on the location like san diego, address, state,city and number.Used this api https://www.openbrewerydb.org.

The code is hosted on this url:

https://hidden-tor-29864.herokuapp.com/

The front page appears like this (https://user-images.githubusercontent.com/82792752/125203075-7885bd80-e294-11eb-8511-fe21cb1fd1c9.png)

The user can type his search query like the place of the brewery Examle place: San Diego and the code returns the list of breweries that have san diego in the text box.Sample search of san doego look like this. Please dont forget to click the search button after typing the search query.

Screen Shot 2021-07-11 at 10 10 43 PM

The user also has the option to click on the Remove button after the user clicks Search and gets a list of breweries based on the search query text.Once the remove button is clicked then the screen is empty with no breweries.

The user can also click on the address and the user is redirected to the google maps that shows the exact location of the place based on the address.

Also on clicking on the website link the user is redirected to the brewery website.

Code repo:

The code repo comprises of the app.py backend flask application and the frontend React application code ( App.js).

In the app.py file there is an @app.route method that implements the GET api call.The frontend react application calls this api vis the fetch method url https://hidden-tor-29864.herokuapp.com/breweries/search?query=${input}.The backend code then takes in this api call from the frontend server, passes the input given by the user in the search bar present in the frontend as a parameter and then calls the external api server via the url https://api.openbrewerydb.org/breweries/search?query=' str(list).Here list is the input parameter that the frontend passes to the backend.The results of the query are returned to the frontend fetch function in json format.

Screen Shot 2021-07-11 at 10 49 22 PM

Now lets consider the App.js frontend file present in src folder.

In this file the statements Screen Shot 2021-07-11 at 10 54 29 PM are used to store the number of breweries (num) and input to pass it as a parameter when calling the backend api as well as clearing the screen when the remove button is pressed.The return statement is rendered whenever the input or num variable changes.The return statement comprises of the search bar,search button and remove button.When the search button is clicked then the brewery function to fetch the results based on the input of the search bar on frontend is run and a list of breweries is obtained based on the input.When the Remove button is clicked then the input variable (input) state and num state variable is set to 0 so that no contents are displayed.

Call Stack:

Untitled Diagram (6)

The React frontend first calls the flask backend via https://hidden-tor-29864.herokuapp.com/breweries/search?query=${input}. The flask backend then calls the external brewery api server via https://api.openbrewerydb.org/breweries/search?query=' str(list).The external api server fetches the contents from an openbrewery postgresql database server and then returns it back to the external api server.Then the external api server returns the content to the flask backend server and the flask backend server back to the frontend react application where the results are displayed.

brewery-react-app's People

Contributors

varun1369 avatar

Watchers

Varun Manjunath 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.