Plumber API best practices

While there is a lot of documentation on how to best write plumber APIs, there is not too much on best practices. I am curious if there are any project organization best practices. For example, when creating a new plumber API in the RStudio IDE, a plumber.R file will be created stored within a subdirectory with said API name creating a project structure like

api.Rproj/
├── api/
│   ├── plumber.R
│   ├── R/
│   ├── data/

This seems counter to intuition which would suggest something along the lines of

api.Rproj/
├── plumber.R
├── R/
├── data/

Additionally, I have previously read about entrypoint.R files as well. But it appears that this is also deprecated.

The Docker hosting portion of the plumber docs suggest a lot of flexibility in structure as well.

Is there any strong opinion on how plumber APIs should be structured and organized?

If the plumber api is part of a single R package.

api.Rproj/
├──R/
├──data/
├──inst/
│   ├── api
│   │   ├── plumber.R

If you deploy via Docker and use multiple packages. Keep api code to a minimum and package the rest of the R code in a separate package.

api.Rproj/
├── api/
│   ├── plumber.R
├──Dockerfile
├──...

General rules, you do you.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.