Code Monkey home page Code Monkey logo

weathergrid's Introduction

Weather

Simple webapp displaying a grid of weather forecasts. A deployment of this using Bay Area locales is running at https://alecholmes.com/weather.

The frontend is implemented completely in index.html without using any third party dependencies.

Weather data is stored in a public JSON blob which is periodically updated by the backend.

The backend is a Golang CLI app that will run as an AWS lambda if no arguments are provided. See main.tf for all the necessary boilerplate to deploy the backend.

Building and deploying the lambda

Prerequisites:

  • OpenWeather API key
  • AWS account
  • Golang toolchain
  • Terraform
make build-aws-lambda

cd terraform
terraform apply

Terraform will need to run in the context of an AWS user with the following permission policies (these can be scoped down):

  • IAMFullAccess
  • AmazonS3FullAccess
  • CloudWatchEventsFullAccess
  • AWSLambda_FullAccess

To run Terraform locally, AWS credentials can be set in environment variables:

export AWS_ACCESS_KEY_ID=your_access_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
export AWS_REGION=your_region # e.g. us-east-1

Creating weather snapshot JSON locally

# If -snapshot-to-s3 is omitted, the snapshot is written to stdout instead.
go run ./cmd/syncweather -local -config config/config.json -snapshot-to-s3

Notes

The OpenWeather API free tier only allows 1000 API calls per day. Since there is an API call for each location, the number of locations and lambda frequency must be tweaked to remain within this limit. If data is updated hourly, there can be no more than 41 locations.

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.