Code Monkey home page Code Monkey logo

careerfoundry-weather-app's Introduction

CareerFoundry Weather App

Application

In this application you can:

  1. Search for any country or city you want
  2. Select from the auto completion the desired country or city
  3. Click on the Get Weather button
  4. See the weather in the right info card

Demo Link

I deployed the application to Heroku. By the way I've created a Dockerfile in case we wanted to deploy into any containerized environment.

https://cf-weather-app.herokuapp.com

Seperated Gems

While working on the application I decided to split the code into 2 gems, so I can provide something back to the community.

The first gem is called Horus, which is a Ruby wrapper around the OpenWeather API, so users can grap the current weather info by either city, coordinates (latitude, longitude) or zipcode.

You can find the documentation in its GitHub repo.

The second gem is called MapPicker which renders the Google Map, and provides an autocompletion field, so users can pick their desired country or city, or just click anywhere on the map. It gets the latitude and longitude for that picked up location.

Don't forget to use or star them ;)

Minimal Configuration and Setup

In this app we don't need to save to a database, so I removed the ActiveRecord module. We also don't send emails, so I just used the Rails modules that the app needs (ActionView, ActionController, Sprockets). You can check the Gemfile and the config/application.rb for this setup.

BDD

I wrote some features and step definations for the application. I used Cucumber as I used to use this awesome framework.

Cucumber Test Output

TDD

I also wrote some controller tests using RSpec testing framework.

RSpec Test Output

I would also add a test coverage gem like simplecov, so we can get a better insight of how are the tests covering the codebase.

Deployment

I thought of getting a VPS on DigitalOccean and deploy a Kubernetes cluster and provide a dashboard access for it, just to get my hands in more DevOps in this task, then I thought it would be an overkill, so I deployed the app to Heroku.

For the health monitoring, error reporting, auto scalling, and service discovery Kubernetes would do a very well job especially if it's used with Grafana and a timeseries database, so we can have a central place for our logs. I am thinking of this infrastructure for CF actually.

Also I would think of having a CI/CD server setup, for our code review process, and automatic deployments.

Using a SAAS like NewRelic would be good also for knowing the bottlenecks of our codebase performence.

Secrets

I kept all the secret tokens and API keys in the config/secrets.yml, using environment variables. I will send these variables via email, just in case you want to run the application locally.

Code Style

I added the awesome static analyzer Rubocop, to make the code aligned with the Ruby Style Guide, I tried to make the code aligned to it, but there are some minor errors that I thought not to spend time on them, as the idea is delivered of being aligned to the Ruby style guide in most of the code base.

Controller Documentation

I used the awesome API documentation gem Apipie to document controller endpoints. If the app is an API only, this gem would be of the best use, so we can have a central documenation place for the API so the front end developers and any one who want to consume the API can make use of.

careerfoundry-weather-app's People

Contributors

wazery avatar

Watchers

 avatar  avatar  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.