Git Product home page Git Product logo

weather_forecast's Introduction

README

This is a demo application showing a basic weather forecast UI.

To run all tests:

  • rails spec

To run application locally:

  • Note: there is no DB requirements (the default SQLite DB is left enabled, but no migrations/schema exist).
  • bin/rails dev:cache (to enable dev mode caching)
  • bin/dev

Docker instructions:

image construction

  • From within the project directory:
  • docker build -t forecast .

container launch

  • docker run --rm -it -p 3000:3000 --env RAILS_MASTER_KEY= forecast
  • application is server at http://localhost:3000

Design Notes

For the most part the application does not employ objects. The functonality is encapsulated in extensions of existing Rails classes as methods implmented in controllers or helpers.

There are 2 controllers for the foreacast UI - "Addresses" and "Forecasts".

The Addresses controller provides search suggestions to the UI's input form. As values are entered, there is a slight delay before the query is sent to the controller. The responses are returned via a Turbo stream handler, so updates are dynamically populated on the form. This functionality provies a convenient way for the user to enter an address, see completions, then select one of those.

Once the text field is populated, there are also inputs that contain the geolocation data points for that address. The form submission sends this to the Forecasts controller, which in turn queries an open weather API endpoint for releveant weather conditions and a 7 day forecast. Again, the response is a Turbo stream. The forecast is then updated on the page withou a full reload.

In both controllers the handling is kept to a minimum - we defer the API interactions to the helper methods. This allows for separation of logic which in turn made is easier to test and refactor.

The UI CSS is entirely Tailwind CSS. Each element uses the Tailwind convention of "inline" CSS classes.

weather_forecast's People

Contributors

jjeffers avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.