flowchart LR
A[UI inputs<br/>species, island, trend line] --> B[filtered_data<br/>reactive expression]
B --> C[summary_text<br/>renderPrint]
B --> D[penguin_plot<br/>renderPlot]
E[Show species flashcard<br/>actionButton] --> F[penguin_card<br/>eventReactive]
A --> F
F --> G[scrape_penguin_card<br/>Wikipedia text and image]
G --> H[observeEvent<br/>side effect]
H --> I[show_penguin_modal<br/>flashcard]
J[Validation<br/>req, validate, need] --> B
J --> F
J --> D
Reactivity
As dashboards grow, simple filters become more fragile
A reactive object stores logic that depends on user inputs.
When the inputs change, Shiny knows which outputs need to update.
Reactive objects must be called with parentheses. E.g. filtered_penguins()
flowchart LR
A[Start / Next button] --> B[observeEvent]
B --> C[Update quiz_step]
C --> D[renderUI]
D --> E[Intro, question, result]
B --> F[Store answer]
F --> G[quiz_answers]
The app stores a small piece of state: quiz_step(). When the user clicks Start, Next, Back, or Restart, observeEvent() updates that state. The UI is generated dynamically with renderUI().
Shiny and Google Cloud Run
What is Google Cloud Run?
Google Cloud Run is a managed service for running containerized (e.g. Docker) applications without having to manage a server.
It handles the infrastructure around the app but lets us define the app, packages, container, memory, CPU, and access settings.
flowchart TD
A[Shiny app] --> B[Docker container]
B --> C[Cloud Run service]
C --> D[Public URL]
C --> E[Logs and revisions]
C --> F[Scaling]
Google Cloud Key Elements
Project: the workspace where Google Cloud resources live.
Console: the browser interface for managing Google Cloud.
Cloud Run: the service that runs our Shiny app as a containerized web app.
Cloud Build and Artifact Registry: the services that build and store the container image before Cloud Run runs it.
Deployment Essentials
Checklist:
a Google Cloud account and a project
billing enabled for that project
the Cloud Run API enabled
the Cloud Build API enabled
the Artifact Registry API enabled
an app folder with app.R and Dockerfile
Workflow:
Shiny app files → Dockerfile → Cloud Build → Artifact Registry → Cloud Run service → public URL
What is Docker?
Docker packages an app with everything it needs to run. For Shiny:
App code,
R version,
R packages,
System libraries,
Command start up
flowchart TD
A[Shiny app] --> E[Docker image]
B[R packages] --> E
C[System libraries] --> E
D[Startup command] --> E
E --> F[Container]
F --> G[Running dashboard]
FROM rocker/shiny:4.4.0 chooses the starting environment, here an image that already contains R and Shiny.
RUN install2.r ... installs the R packages the app needs.
WORKDIR /srv/shiny-server and COPY . /srv/shiny-server create the app folder inside the container and copy your local files into it.
ENV PORT=8080 and EXPOSE 8080 sets the port the app will use, should match the service.
CMD ["R", "-e", "..."] tells the container what to do when it starts (e.g. run the Shiny app)
Why Shiny on Cloud Run?
Closer to production cloud workflows: Docker logic can be reused for Shiny apps, APIs, Python services, background jobs, or other web apps.
Fine-grained resource control: adjust CPU, memory, concurrency, minimum instances, and maximum instances instead of buying into a fixed publishing platform.
More flexible runtime environment: you can include system libraries, non-R tools, Python, command-line utilities, or unusual package requirements.
Live Demo
Thank you for your attention!
About the FIRSA Project
Disclaimer:
This project has received funding from the European Union Marie Skłodowska-Curie Postdoctoral Fellowships / ERA Fellowships action under grant agreement No. 101180601 under the title: Understanding FinTech Regulatory Sandbox Development in Europe (FIRSA).