Table of Contents
This was a solo project completed during the final week of module 3 of 4 at Turing School of Software & Design. The goal of this project was to create a successful web application to plan road trips. This app allows users to see the current weather for any given location, as well as the forecasted weather at the destination during the estimated time of arrival.
This project was completed with a focus on service-oriented architecture. It was designed to aggregate data from multiple endpoints of three different external APIs, and expose a token-authenticated API that satisfied the requirements given from the front-end team.
- Clone the repo
git clone git@github.com/hschmid516/sweater-weather.git
- Run bundle
bundle install
- Run migrations
rails db:{create,migrate}
- Install Figaro
bundle exec figaro:install
- Get API keys for the following APIs
- Add API keys to application.yml
Get weather data for a given location
{
"data": {
"id": null,
"type": "forecast",
"attributes": {
"current_weather": {
"datetime": "2021-11-16T20:29:34.000-07:00",
"sunrise": "2021-11-16T05:26:08.000-07:00",
"sunset": "2021-11-16T15:30:52.000-07:00",
"temperature": 60.19,
"feels_like": 60.1,
"humidity": 89,
"uvi": 0,
"visibility": 10000,
"conditions": "broken clouds",
"icon": "04n"
},
"daily_weather": [
{
"date": "2021-11-16",
"sunrise": "2021-11-16T05:26:08.000-07:00",
"sunset": "2021-11-16T15:30:52.000-07:00",
"max_temp": 64.22,
"min_temp": 38.52,
"conditions": "broken clouds",
"icon": "04d"
},
...
],
"hourly_weather": [
{
"time": "20:00:00",
"temperature": 60.19,
"conditions": "broken clouds",
"icon": "04n"
},
...
]
}
}
}
Get image for a given city
{
"data": {
"id": null,
"type": "image",
"attributes": {
"image": {
"location": "Denver Colorado",
"image_url": "https://images.unsplash.com/photo-1634507307799-ace9b49840b7?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwyNzU0ODR8MHwxfHNlYXJjaHwxfHxkZW52ZXIlMkNjb3xlbnwwfHx8fDE2MzcxMDkzNjQ&ixlib=rb-1.2.1&q=80&w=1080",
"credit": {
"source": "https://unsplash.com/",
"user": "dillydallying",
"user_url": "https://unsplash.com/@dillydallying",
"name": "Dillon Wanner"
}
}
}
}
}
Register a user
- Content-Type: application/json
- Accept: application/json
{
"email": "whatever@example.com",
"password": "password",
"password_confirmation": "password"
}
{
"data": {
"type": "users",
"id": "1",
"attributes": {
"email": "whatever@example.com",
"api_key": "jgn983hy48thw9begh98h4539h4"
}
}
}
User login
- Content-Type: application/json
- Accept: application/json
{
"email": "whatever@example.com",
"password": "password"
}
{
"data": {
"type": "users",
"id": "1",
"attributes": {
"email": "whatever@example.com",
"api_key": "jgn983hy48thw9begh98h4539h4"
}
}
}
Create a road trip
- Content-Type: application/json
- Accept: application/json
{
"origin": "Denver,CO",
"destination": "Pueblo,CO",
"api_key": "53ZqhpECyRoKUheAX6v6hXCc"
}
{
"data": {
"id": null,
"type": "roadtrip",
"attributes": {
"start_city": "Denver, CO",
"end_city": "Estes Park, CO",
"travel_time": "2 hours, 13 minutes"
"weather_at_eta": {
"temperature": 59.4,
"conditions": "partly cloudy with a chance of meatballs"
}
}
}
}
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request