Rails app to get weather from US address using OpenWeather API.
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.
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.
- Ruby 3
- Rails 7
- Redis
bundle
bin/setup
cp .env.sample .env
Edit .env with your OpenWeather API key.
bin/dev
Run test with:
rspec
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