A week long project, completed during my time at Turing. It is an API only Ruby on Rails backend that utilizes: the Mapquest API for geo-coordiantes and directions, OpenWeather API for current, hourly and daily weather and Google Places API for pictures from the locations.
The Project Scope:
- to be able to get forecasts for cities that users specify (using the geo-coordinates returned from Mapquest to get the weather data from OpenWeather)
- return a background image for those cities (using Google Places API to search for images from the city)
- Allow users to register and return to them a unique API key, which was needed to access some of our endpoints
- allow User login via hashed passwords with Bcrypt
- Allow users to create a RoadTrip, in which they designate an origin and destination city, and return to them the forecasted weather for their arrival time! (using the forecast data from the API in goal 1 and the Mapquest directions API to estimate the arrival time)
This project required the use of all of the external API's working in conjuncture to provide the users with a seamless experience.
link to lucid charts process diagrams
- Ruby version ![Version][version-badge]
Testing
- service returns parsed data (or simple data as in GeoLocationService.get_coordinates())
- facade takes service send to Serializer
- Serializer formats data to JSON
- controller renders data to the client via specified API endpoints.
Steps to returning forecast object
- coordinates = GeoLocationService.get_coordinates(location_name)
- forecast = ForcastService.get_forecast(coordinates)
- ForecastFacade.format_forcast(forecast)
- forecasts controller index calls facade and renders json
GET http://localhost:3000/api/v1/forecast?location=grand+blanc,mi
{
"data": {
"id": null,
"type": "forecast",
"attributes": {
"current_weather": {
"datetime": "2021-11-12T16:45:37.000-07:00",
"sunrise": "2021-11-12T05:23:19.000-07:00",
"sunset": "2021-11-12T15:14:12.000-07:00",
"temperature": 38.52,
"feels_like": 38.52,
"humidity": 82,
"uvi": 0,
"visibility": 10000,
"conditions": "Clouds + overcast clouds",
"icon": "04n"
},
"daily_weather": [
{
"date": "2021-11-12T10:00:00.000-07:00",
"sunrise": "2021-11-12T05:23:19.000-07:00",
"sunset": "2021-11-12T15:14:12.000-07:00",
"max_temp": 48.54,
"min_temp": 35.64,
"conditions": "Rain + light rain",
"icon": "10d"
}... * 5 days
],
"hourly_weather": [
{
"time": "2021-11-12T16:00:00.000-07:00",
"temp": 38.8,
"conditions": "Clouds + overcast clouds",
"icon": "04n"
}... * 8 hours
]
}
}GET http://localhost:3000/api/v1/backgrounds?location=detroit,mi
{
"data": {
"id": null,
"type": "image",
"attributes": {
"image_url": "https://lh3.googleusercontent.com/places/AAcXr8qnLw24WJ63Gz-6VsY1mmKdVEymztBCWEaqW-NZJ21VOjVHnaZootIC4VsYgOuy_oumb2iChYauRsI5FgwzlxpzkqNOqRtc-e4=s1600-w800",
"location": "detroit,mi"
}
}
}POST http://localhost:3000/api/v1/road_trip
{
"origin": "los angeles, ca",
"destination": "new york, ny",
"api_key": ""
}Response Body:
{
":data": {
":id": null,
":type": "roadtrip",
":attributes": {
":start_city": "los angeles, ca",
":end_city": "new york, ny",
":travel_time": "40 hours 21 minutes",
":weather_at_eta": {
":temperature": 41.63,
":conditions": "few clouds"
}
}
}
}POST http://localhost:3000/api/v1/road_trip
{
"origin": "denver,co",
"destination": "london,uk",
"api_key": ""
}Response Body:
{
":data": {
":id": null,
":type": "roadtrip",
":attributes": {
":start_city": "denver,co",
":end_city": "london,uk",
":travel_time": "impossible",
":weather_at_eta": {}
}
}
}- Database creation / initialization in the terminal:
- bundle install
- rails db:{create,migrate}
- How to run the test suite
- bundle exec rspec
- Deployment instructions
- rails s