Skip to content

Druwerd/weather

Repository files navigation

README

Rails app to get weather from US address using OpenWeather API.

Application Design

diagram

The Rails WeatherController#current action calls Services::OpenWeatherConnector which is encapsulates calling the OpenWeather API and build a response.

OpenWeatherConnector uses the open-weather-ruby-client gem.

OpenWeatherConnector uses OpenWeatherResponseBuilder to build a data response for the WeatherController. OpenWeatherResponseBuilder is based on the factory design pattern. This will allow us to easily extend the application to support multiple API data sources or multiple endpoint as we add features.

Scalability

This application is stateless and runs without a database. There is a database version is on a separate branch: with-db for future feature expansion that may require a db.

To scale up the application you could setup your infrastructure architecture such that web application instances and Redis cluster nodes as are dynamically increased as load increases. See example diagram below.

Additionally you could serve static assets such as images, css, javascript from a CDN.

infra

Dependencies

  • Ruby 3
  • Rails 7
  • Redis

App Setup for local development

bundle
bin/setup
cp .env.sample .env

Edit .env with your OpenWeather API key.

Run app

bin/dev

Testing

Run test with:

rspec

Documentation

This project is documented using YARD.

Existing code documenation is located the doc folder of the project: open doc/index.html

To regenerate the docs run: rake yard

Screenshots

Homepage homepage

With Invalid Fields valid fields

With Valid Fields valid fields

Cache Miss cache miss

Cache Hit cache hit

About

Rails app to get current weather

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published