# Shiny apps

This directory is the bind-mount source for the Shiny Server container on
backend01 (`rocker/shiny-verse:4`, port 8083, behind Nginx at
`https://shiny.ruohomaki.fi`). Each subdirectory with an `app.R` becomes a
hosted app at `https://shiny.ruohomaki.fi/<subdir>/`.

## Apps

| Path | Purpose | Status |
|---|---|---|
| `landing/` | Minimal landing page; verifies the deploy path end-to-end | Placeholder |
| `demo/` | The four-output analytical app the concept paper describes (Phase 5) | Pending |

## Conventions

- Every app is a single `app.R` file with `ui`, `server`, and
  `shinyApp(ui, server)` at the bottom. Multi-file structure
  (`ui.R`/`server.R`/`global.R`) is fine too but `app.R` is canonical.
- Database credentials and Mongo URI come from the container's environment
  (provided by `docker run --env-file ~/shiny/.env`). Apps use
  `Sys.getenv()` directly -- no `.Renviron` is bind-mounted.
- The reference connection helpers in `R/utils/db_connect.R` and
  `R/utils/mongo_connect.R` work as-is inside the container; source them
  with paths relative to the bind mount root (e.g. `../utils/...`).

## Local development

From an RStudio session that has the env vars loaded:

```r
shiny::runApp("R/shiny/landing")   # http://127.0.0.1:<port>
```

The same code runs unchanged in the container; only the env-var source
differs (local `.Renviron` vs container `--env-file`).
