Skip to content

Web app that provides real-time weather updates for US and Canadian locations, leveraging OpenWeather and Geocodio APIs with caching for optimized performance.

Notifications You must be signed in to change notification settings

kayleiburke/weather-forecaster

Repository files navigation

Weather Forecaster 🌤️

Weather Forecaster is a simple web application that retrieves and displays the current weather forecast based on a provided address. Powered by OpenWeather API and Geocodio API, it provides real-time weather updates and caches results for optimized performance.

🖥️ Live Demo

A live version of the site is deployed on Heroku:

🚀 Features

  • Search Weather by Address: Enter any address (U.S. or Canada) to get the current weather details, including temperature, description, and icon
  • Error Handling: Handles invalid addresses gracefully with user-friendly messages
  • User Interface with Bootstrap: Clean and responsive design powered by Bootstrap for better user experience
  • API Usage Limits:
    • Geocodio API: Allows 2,500 requests per day and 1,000 requests per minute (source)
    • OpenWeather API: Allows 1,000,000 requests per month and 60 requests per minute (source)
  • Caching for Efficiency: Forecast data is cached for 30 minutes based on zip codes to optimize performance and ensure that repeated requests do not unnecessarily consume OpenWeather API calls
    • In production, Redis-backed caching ensures consistent performance and scalability across multiple workers
    • In development, caching is performed in-memory for simplicity

🛠️ Technologies Used

  • Framework: Ruby on Rails
  • APIs:
  • Frontend: Bootstrap CSS for styling
  • Deployment: Heroku
  • Cache Backend:
    • Production: Redis Cloud (Heroku Add-on) (30MB)
    • Development: In-memory caching (64MB)

📦 Installation

  1. Install dependencies

    bundle install
    
  2. Create API Keys

    Sign up for free accounts at:

    Generate API keys from each service after signing up.

  3. Set up environment variables

    Create a .env file with the following variables:

    GEOCODIO_API_KEY=your_geocodio_api_key
    OPENWEATHER_API_KEY=your_openweather_api_key
    
  4. Run the server

    rails server
    
  5. Access the application

    Visit http://localhost:3000 in your browser.

🧪 Running Tests

This project uses RSpec for testing. Tests can be run with the following command:

bundle exec rspec

⚙️ Usage

  1. Search for Weather:
    • On the homepage, enter an address (e.g., One Apple Park Way, Cupertino, CA 95014) or a more general location (e.g., California or Toronto, Canada).
    • Note: The address can be either specific or broad (e.g., a street address, city, or state). However, it must be within the US or Canada, as Geocodio only supports these regions.
    • Click Get Forecast to view the weather details.
    Screenshot 2024-10-27 at 1 36 00 AM
  2. Caching:
    • Results are cached for 30 minutes to enhance speed and limit API requests.
    • If you search the same address within the cache period, the app will display the cached result.
    Screenshot 2024-10-27 at 1 35 26 AM
  3. Error Handling:
    • If an invalid address is entered, an error message will be displayed asking the user to try again.
    Screenshot 2024-10-27 at 1 37 39 AM

About

Web app that provides real-time weather updates for US and Canadian locations, leveraging OpenWeather and Geocodio APIs with caching for optimized performance.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published