contact@mightymetrika.com
This is a quick blog post to list some of the essential resources that I needed to get a citizen science app up and running. The app uses:
The post is basically a way for me to bookmark resources that I found useful and also as a way to say thank you to the folks that put these resources up online.
Persistent Data Storage by Dean Attali: https://deanattali.com/blog/shiny-persistent-data-storage/
The main R workflow uses the MySQL section of Dean Attali's Persistent Data Storage. This workflow allows you to get a Shiny app up-and-running where the shiny app collects data , sends results to a database, and displays data from database.
Instead of using MySQL like in the Persistent Data Storage blog, I used PostgreSQL with the RPostgres R package.
Best Practices in Working with Databases > Databases > PostgreSQL: https://solutions.posit.co/connections/db/databases/postgresql/
Posit's Best Practices in Working with Databases has a short section that covers connecting to a PostgreSQL database using RPostgres.
Emily Rieder Using Databases with Shiny: https://www.emilyriederer.com/post/shiny-db/
This blog post shows how to use the RPostgres R package with the DBI R package. Shows useful syntax and discusses best practices and pitfalls.
Both resources above use the RPostgres x DBI R package combination.
Posit's Why Pool: https://rstudio.github.io/pool/articles/why-pool.html
To swap DBI with pool, I used the 'Why Pool?' blog post by Posit. The other articles on the website have good examples as well.
Helena Alexander's How to Configure PostgreSQL for Remote Connections: A Beginner’s Guide: https://blog.devart.com/configure-postgresql-to-allow-remote-connection.html
I used the instructions for Windows to make sure the .conf files and the Windows Firewall were set up correctly.
The Firewalls section of Posit's Accessing Databases with ODBC chapter of the shinyapps.io User Guide: https://docs.posit.co/shinyapps.io/guide/applications/#firewalls
Since I deployed with shinyapps.io, I used these instructions to whitelist the shinyapps.io IP addresses. I also used this same worfklow for whitelisting IP addresses when I needed to test the app by running the Shiny app on one EC2 instance while the PostgreSQL database was on another instance.
Posit forum's How to set a variable in .Renviron: https://forum.posit.co/t/how-to-set-a-variable-in-renviron/5029
I used cderv's response to the OPs question to set up a .Renviron file.
StackOverflow's shinyapps.io won't read environment variables from .Renviron: https://stackoverflow.com/questions/77579704/shinyapps-io-wont-read-environment-variables-from-renviron
I used the StackOverflow post to make sure the .Renviron file was stored in the correct place for deployment on shinyapps.io. I'm not too familiar with security so I don't know if this is good practice or not.
I combined the Posit x StackOverflow post when deploying to shinyapps.io by using the:
bullet point from crderv's Posit forum response since my app.R file was in the main project folder for deployment.
The apps I made are currently on https://www.mightymetrika.com/citsci. The source code for these apps are on GitHub:
I hope to improve on these apps in the future by:
In the coming weeks I'll have a few blog posts about the individual apps in order to document how the data is supposed to map onto the papers from which the replext (replication & extension) simulation tables are based.