Skip to content

Shiny web application for locating and reporting inventory of COVID-19 at-home test kits

License

Notifications You must be signed in to change notification settings

ketchbrookanalytics/covid_test_spotter

Repository files navigation

COVID-19 At-Home Test Spotter

The goal of the COVID-19 At-Home Test Spotter app is to allow users to locate and report the availability of at-home COVID testing kits at retail locations in their state.

It works very similar to the Waze app, in that the “reports” data is entirely user-driven.

The app opens to the “Home” page, which displays the most recently reported test kits available in retail locations:

When the user clicks either the green or red buttons at the top of the page, they are taken to a form prompting them to submit information about when and where they saw test kits in or out of stock:

Installation

  1. Clone this repository to your local machine

  2. Open the covid_test_spotter.Rproj file from the directory on your local machine where you cloned this repository. This should install the {renv} package if you do not already have it installed, but if you don’t see that happen in the console, run install.packages("renv").

  3. Run renv::restore() to install the package dependencies needed to run this app successfully

  4. Edit the global.R script as necessary (see below)

  5. Open the app.R file and execute the code in that script to launch the app

Configuration

In addition to the code repository, this project requires that you have certain Google APIs enabled, a MongoDB database setup, and that you have appropriately established related environment variables.

Google APIs

First, you will need to create a new GCP Project. Refer to this guide to see how to quickly set this up.

Once you are in the GCP Project, you can search for the Maps JavaScript API and Places API in the search bar at the top of the page. This will take you to their respective API pages, where you can click the Enable button to enable these APIs in your project.

  • Maps JavaScript API, for display of the map widget in the UI

  • Places API, for enabling auto-complete in the search box embedded in the map widget

After enabling both APIs, you will need to create an API Key that we can pass to the {googleway} package for use of these APIs within our Shiny app. Note: we highly recommend restricting your API Key to the specific HTTP referrers or IP addresses where your Shiny app will be deployed

MongoDB Atlas Database

For this project, we chose to use MongoDB Atlas, which is a NoSQL cloud database offering. MongoDB provides shared clusters at no cost, which are useful for Proof-of-Concept projects that don’t require high availability.

  • To set up a MongoDB Atlas database, use this Getting Started Guide (Note that you will need to ensure that the IP address of where your app lives is whitelisted by your MongoDB database cluster)

  • Create a config.yml YAML file at the root of this repository, containing the credentials for connecting your Shiny app to your MongoDB Atlas database; you can get your credentials from MongoDB by following these instructions, and an example of what that file should look like can be found in examples/config_example.yml

  • (Optional) You may also want to change (or remove) the query results limit for the number of items to retrieve from the collection; this is set at db_connect.R

Global Environment

There are many ways to set environment variables in R, but we recommend creating a file at the root of this project called .Renviron to accomplish this. In this file, you must establish the following environment variables:

  1. GOOGLE_KEY, for storing your Google API Key, as discussed here
  2. R_CONFIG_ACTIVE, which should always be set to "default"
  3. MONGO_DB, the name of the MongoDB Atlas database, as discussed here
  4. MONGO_COLLECTION, the name of the MongoDB Atlas database collection, as discussed here

For example, the contents of the file should look like:

GOOGLE_KEY=AbCdEfG12345
R_CONFIG_ACTIVE=default
MONGO_DB=my-mongo-db-name
MONGO_COLLECTION=my-mongo-collection-name

CRUD Workflow

In the app, the reporting of at-home test kits in and out of stock is tied to the execution of CRUD operations against the MongoDB database back-end. A simple diagram of how this logic (which is coded in the db_connect.R script) can be seen below:

Questions?

Contact us at [email protected]

About

Shiny web application for locating and reporting inventory of COVID-19 at-home test kits

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages