Weather Vine is an educational app for consumers to connect more deeply with the wine they enjoy. Explore wines from a region and see how the climate has influenced the very wine one drinks!
- Getting Started
- Running the tests
- OAuth with Google
- Service Oriented Architecture
- Application Code
- Built With
- Contributing
- Versioning
- Authors
- License
- Acknowledgments
To get the web application running, please fork and clone down the repo.
git clone <your@github.account:WeatherVine/front_end.git>
To run this application you will need Ruby 2.5.3 and Rails 5.2.5
-
Install the gem packages
bundle install -
Create the database by running the following command in your terminal
rails db{:drop, :create, :migrate}
RSpec testing suite is utilized for testing this application.
- Run the RSpec suite to ensure everything is passing as expected
bundle exec rspec
To get started with OAuth, please make sure to install the following gems:
gem omniauthgem omniauth-google-oauth2: This specifies a unique provider(Google in our case)gem omniauth-rails_csrf_protection: Make sure no vulnerabilities exist in the code
Run bundle install
This project will also require the gem figaro. Please add this in the development/ test part of the Gemfile.
gem figaro
-
Run
bundle exec figaro install -
This will generate an
application.ymlfile within theconfigfolder.It is imperative that the
application.ymlfile is added to.gitignoreso that theenv[VARS]are not pushed up to production. -
Add
application.ymlto.gitignorelike so:# Ignore application configuration /config/application.yml
Next, we will want to get the necessary variables from Google. Navigate to the Google developer's console: https://console.developers.google.com
- Click
Create a New Project- Fill in the section for name with name of application i.e. WeatherVine
- Click
View Project: Takes user to the dashboard view to set up variables - Scroll down to
Getting Startedtab and click onExplore and enable APIs - Choose
Config Consent Screen: Allows user to choose which Google account they would like to log in with - Fill out the application name i.e. WeatherVine
- If hosting on a website like Heroku, will need to add Heroku website to
Authorized Domainssection before saving
- If hosting on a website like Heroku, will need to add Heroku website to
Now it's time to create the Google credentials. Click on Credentials in the left tab
- Create Oauth CLIENT_ID
- Choose
web applicationsand add name of application here - Add in authorized redirect URI: This makes a true
httprequest to Google and where the callback is added - The callback should look like this:
http://localhost:3000/auth/google_oauth2/callback - Click
Createat this point, the Google credentials for CLIENT_ID and CLIENT_SECRET have been created
Add the credentials inside the application.yml file located within /config
- Make sure to add these in like so with no quotes and all caps for the keys:
- GOOGLE_CLIENT_ID: < add client id here >
- GOOGLE_CLIENT_SECRET: < add client secret here >
Set up middleware: Middle ware is a link that says sign in with Google so that we're not processing the request
- Located in
/config/initializers, add a file calledomniauth.rb - Add the following inside this file:
Whatever is listed as the key for the
Rails.application.config.middleware.use OmniAuth::Builder do provider :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'], :skip_jwt=>true end
ENVhas to match exactly as what exists within theapplication.ymlfile
The following is a depiction of the overall service oriented architecture for this application which includes a Rails Front End application, a Rails Engine on the Back End, and two microservices that call out to a World Weather Online's api and Quini Wine's api:
- Ruby
- Rails
- RSpec
- FactoryBot
- Faker
- Ruby 2.5.3
- Rails 5.2.5
