Giter VIP home page Giter VIP logo

garussell / road_trip_planner_be Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 730 KB

This is an API that exposes 6 endpoints to find weather condition at roadtrip location. It utilizes Weather API and MapQuest Geolocation API to obtain roadtrip and weather info, Unsplash API for destination photo, and OpenLibary API to get books about location, and assigns secureRandom API keys.

Ruby 99.76% HTML 0.24%
apikey-authentication authentication-backend endpoints jsonapi caching error-serializer facades poros services vcr

road_trip_planner_be's Introduction

Road Trip Planner - Project README

Back-End API

Front-End Repo

Screenshot 2023-12-17 at 6 36 22 AM Screenshot 2023-12-17 at 6 36 09 AM

Table of Contents

  1. Learning Goals
  2. Project Description
  3. Example Code
  4. Setup
  5. Data Structure
  6. End Points
  7. Suggestions for Use
  8. Contributors

Learning Goals

  • Expose API with integration of multiple APIs, including requiring an authentication token.
  • Utilize ErrorSerializer and JSONAPI formatting.
  • Impliment caching to speed up process when search query includes location / city & state or latitude & longitude.
  • Complete application based on criteria from other developers.
  • Practice robust testing for poros, services, facades, and requests using mocking tool VCR.

Project Description

Road Trip Planner BE is a back-end project that exposes multiple API endpoints to make data available from MapQuest API, Unspash API, Open Library API, and Weather API. It allows the front-end to obtain JSON data that contains weather forecast information for a city, where the city and state are passed in the URL body as a location param. This API also utilizes OpenLibrary API to search for books about the destination location. Additionally, there is an endpoint that retrieves a background image from Unsplash API.

Example Code

Screenshot 2023-09-26 at 9 41 02 AM Screenshot 2023-09-26 at 9 43 01 AM Screenshot 2023-09-26 at 9 44 00 AM Screenshot 2023-09-26 at 9 44 18 AM

Setup

How to Use

  • Fork/Clone the BE repo
  • bundle install
  • rails s to start server at localhost:3000
  • Hit the endpoints with Postman or your front-end
  • Optionally: visit the front-end repo, fork/clone,
  • npm install then nmp start - select Y to run on localhost:3001 for React

Data Structure

  • data attribute contains id=null, type="forecast", and attributes.
  • attributes is an object that contains weather information: current_weather
  • current_weather holds the weather data as last_updated (format "2023-04-07 16:30"), temperature (float / Fahrenheit), feels_like (float / Fahrenheit), humidity (int or float), uvi (int or float), visibility (int or float), condition (string), icon (png string for current weather condition)
  • daily_weather holds array of next 5 days of weather data: date (format "2023-04-07"), sunrise (format "07:13 AM"), sunset (format "08:07 PM"), max_temp (float / Fahrenheit), min_temp (float / Fahrenheit), condition (string), icon (png string for weather condition)
  • hourly_weather holds array of 24 hours data for current day‘‘‘: time (format "22:00"), temperature (float / Fahrenheit), conditions (string / per hour), icon (png string for weather condition per hour)

End-Points

  • Get data as one endpoint: GET /api/v1/data - takes in 'location' as a param.
  • Get weather for a city: GET /api/v0/forecast?location=cincinatti,oh - data can be sent as params, units are optional ("imperial" or "metric") - Units default to imperial.
  • User Registration: POST /api/v0/users - raw data needs to be sent in the body of the request
  • Login: POST /api/v0/sessions - raw data needs to be sent in the body of the request
  • Create Roadtrip: POST /api/v0/road_trip - raw data needs to be sent in the body of the request, units are optional but can be passed as params ("imperial" or "metric") - Units default to imperial.
  • Search Books: GET /api/v0/book_search?location=#{location}&quantity=#{quantity} - data can be sent as params (location); quantity: optional, units: optional ("imperial" or "metric"). Units default to imperial.
  • Backgrounds: GET api/v0/backgrounds?location=#{location} - will return a photo of that location

Suggestions for Use

  1. Clone the application: Create a clone of this repository
  2. Obtain an API key: Sign-up with email, password, and confirmation password to receive a response with your unique API key (currently no limits)

Contributors

road_trip_planner_be's People

Contributors

garussell avatar

Stargazers

 avatar

Watchers

 avatar

road_trip_planner_be's Issues

add ui for obtaining API key

It exists right now at 'users' endpoint and API key can be manually obtained by back-end developer by passing email and password as raw JSON through the body of the request.

It would be more intuitive to create a back-end interface that allows developers to sign up for an API key, but this is a minor touch.

personalize-rebrand

One idea is to add another API service like moviedb to get movies to watch during the road trip.

After adding something unique, change the name of the repo and update 1. Terminal, 2. Resume, 3. Portfolio Website, 4. other references to it.

Also, built a React app with this back end?

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.