Giter Club home page Giter Club logo

prayerapp's Introduction

Build Status Test Coverage Maintainability

PrayerApp

πŸŽ‰πŸŽˆπŸŽ‚πŸΎπŸŽŠπŸ»πŸ’ƒ

Simple app that returns times to pray based on lat, lon, and timestamp.

This app exposes a simple web API for querying prayer times (in the islamic tradition) by space and time. See an example of the deployed app here (Docs here). This app leverages the praytimes.org project to cacluate prayer times. It is worth noting that the version of the praytimes.org library used here requires a patch due to a python scope issue (not sure how to push that patch back upstream, the project seems largely abandoned).

This app is built and tested with Python3.6 and deployed to AWS Lambda using the Serverless Framework through Travis CI. We use Codeclimate to keep track of maintainability and test coverage.

There are currently no limitations on API usage on the /prod endpoint, which is CORS enabled (therefore, possible to use with frontend javascript). This policy will remain if and until there is a good reason to restrict usage.

Table of Contents

System Requirements

Here are the main tools and runtimes that I used to develop this project locally

$ docker -v # Docker version 17.12.0-ce (or greater)

$ docker-compose -v # docker-compose version 1.18.0

$ node -v # v8.1.2, or latest

$ python3 --version # Python 3.6.5, or Py3+

Usage and Installation

From terminal, pull down this repo:

$ git clone https://github.com/mottaquikarim/PrayerApp

Then, assuming docker is running:

$ make test

Will build app and run tests.

Secrets

Secrets are managed through environment variables, fed in via CI (Travis) or manually exported in local environment. To run deployment and/or ftest in local environment, first export all env variables as defined in envvars.sample. NOTE: the app's Dockerfiles copy envvars.sample to envvars, which is used for container builds.

Managing Travis Secrets

In order to run deployment process "for reals" (ie, to deploy to a prod env), the following env variables must be set (securely) in Travis settings:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • CC_TEST_REPORTER_ID
  • GOOGLE_API_KEY

The CC_TEST_REPORTER_ID env variable is for code climate test coverage.

Deployment

Serverless Framework is used to handle deployment. Look at Serverless getting started guide.

Assuming ~/.aws/credentials are exported to your envirnonment, simply run:

$ make clean deploy stage=test

Note that stage is a concept from AWS Lambda, it can be any arbitrary value (which will be reflected in the deployed lambda url, it is used mainly to segment environments).

If you don't have ~/.aws/credentials folder or are not sure why it is needed, please take a look at these docs.

Functional Tests

Robot Framework is used to handle functional tests. To run ftests (assuming deployment credentials are sorted out),

$ make clean deploy ftest stage=test

(Again, worth noting that envvars must be exported in order for ftests to pass)

ToDos

  • Get /city/{city}/{country} support back up
  • Implement endpoint for IFTTT

Clients

If you build a client that consumes this API, please submit a PR so we can showcase it here!

prayerapp's People

Contributors

mottaquikarim avatar

Stargazers

Robert Abreu avatar

Watchers

James Cloos avatar  avatar

Forkers

tmatin100

prayerapp's Issues

Migrate to Location Unaware timezones

This SO answer has more detail.

Rely on ptyz's .astimezone(timezone(TZ_ID)).dst() == timedelta(1) to determine if in DST or not. This will allow for much longer cached timezone api calls to google (cache the timeZoneId field - stored as TZ_ID in the line above - from response for 2 weeks or something).

Also, set the timestamp param in google maps timezone call to 0. Response is dst-unaware:

{
   "dstOffset" : 0,
   "rawOffset" : -18000,
   "status" : "OK",
   "timeZoneId" : "America/New_York",
   "timeZoneName" : "Eastern Standard Time"
}

Note the dstOffset is 0.

Write some tests to determine how coarse lat/lon lookup for timezone can be

Essentially, play with the API making the timezone values further and further imprecise. Compare against most precise value (from geolocation api in browser) and assert quality. Ideally, if lat/lon can be generalized to 1 or 2 precision points, additional google api call needed would be minimized.

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.