Skip to contents

mpaviewer is a dashboard of marine monitoring data for DBCA staff.

Architecture

  • Data is loaded from a locally saved .rds file, or freshly loaded from Google Drive or the DBCA data catalogue (and then saved as .rds). The locally saved file lives on a persistent volume.

Data

The dashboard runs off a single mpa_data.rds R save file which is produced from a range of source data files (CSV, TXT, SHP).

Archived on the DBCA data catalogue as dataset mpaviewer are: * A link to a Google Drive folder which contains a copy of source data files in the folder/file/data structure expected by mpaviewer::generate_data(). * Links to the deployed dashboard and this GitHub code repository * The mpaviewer data file mpa_data.rds at a specific resource ID expected by mpaviewer::download_data().

Update source data

Data owners can update the Google Drive folder with new data.

Generate dashboard data

Whenever the source data was updated, an analyst must download the contents of the Google Drive folder “mpaviewer” into the directory inst/data of a local clone of the mpaviewer codebase and run mpaviewer::generate_data(), then upload the data file mpa_data.rds to the DBCA data catalogue.

Update the dashboard with new data

A Docker container for ETL periodically executes a script to download source data and process it into the application data.

Until the source data files are all available from the DBCA Data Catalogue, the container simply downloads the pre-processed data file mpa_data.rds from the DBCA data catalogue.

Development

mpaviewer is an RShiny app using Shiny modules, developed using golem.

The commands to develop new functionality are in dev/02_dev.R.

  • Create a GH issue for each task, keep it as small and self-contained as possible.
  • Work on one issue at a time.
  • Once R CMD Check passes and all build errors and warnings are addressed, commit changes.
  • Write descriptive and well-formed commit messages and reference the GH issue.
  • Push and see whether the R CMD Check GH action passes.
  • Bonus points: Build and run the Docker image locally. If that’s not an option, at least make sure that any new package dependencies are added to the Dockerfile.

Release

Once app and Docker image work, create a new version, tag, and push the tag.

styler::style_pkg()
spelling::spell_check_package()
spelling::update_wordlist()

# Code and docs tested, working, committed
usethis::use_version(which="patch")
usethis::use_version(which="minor")
usethis::use_version(which="major")
usethis::edit_file("NEWS.md")

# Document to load new package version. Git commit, tag, and push.
devtools::document()
v <- packageVersion("mpaviewer")
system(glue::glue("git tag -a v{v} -m 'v{v}' && git push && git push --tags"))

Deployment

GitHub Actions are configured to build a new Docker image for every tag starting with “v”, such as “v1.0.0”. The images are pushed to the GitHub container registry ghcr.io. The DBCA maintainer of mpaviewer then updates the tag number (e.g. 1.0.0) in the image run by Kubernetes, which will trigger a hot reload of the image.

The commands to deploy a new version are in dev/03_deploy.R.