# moosa-r/rbioapi architecture

> Architecture diagram of the GitHub repository moosa-r/rbioapi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/moosa-r/rbioapi
- Repository: https://github.com/moosa-r/rbioapi

## Overview

#### Purpose and Runtime
`rbioapi` is an R package that provides a consistent, user-facing API over biological web services. Users load the package and call exported `rba_<service>_<resource>` functions; package startup behavior is in `R/zzz.R`, namespace/export wiring in `NAMESPACE`, and package dependencies/metadata in `DESCRIPTION`.

#### Entry Points and Shared Request Layer
Public calls are organized by remote service but rely on common request, validation, parsing, error, and option behavior implemented in shared modules. The principal cross-cutting boundary is from R-facing resource functions to HTTP requests and normalized R objects.
- `R/internal_functions.R`
- `R/helper_functions.R`
- `R/zzz.R`

Global or per-call options govern timeout, retry, diagnostics, verbosity, saving raw responses, error skipping, and request metadata. `rba_connection_test()`, pagination, and metadata support are package-wide operational entry points rather than service-specific APIs.

#### Service Adapter Families
Each supported external service has a dedicated adapter module exposing resource-oriented functions. These modules encode endpoint-specific arguments and response transformation while conforming to the shared `rba_*` conventions.
- Enrichr: `R/enrichr.R`
- JASPAR: `R/jaspar.R`
- miEAA and PANTHER: `R/mieaa.R`, `R/panther.R`
- STRING: `R/stringdb.R`

The external-service boundary includes Enrichr, JASPAR, miEAA, PANTHER, STRING, Reactome, and UniProt. Ensembl is also contacted for connection checking according to the README.

#### Reactome Split: Content vs. Analysis Workflows
Reactome is separated into content-service access and analysis-service workflows. Content access covers pathway/entity/search/export-style resources; analysis handles submission, token/status, result retrieval, imports, downloads, and PDFs. This separation reflects materially different control flows: mostly synchronous content requests versus analysis jobs that may require token/status polling and artifact retrieval.
- `R/reactome_content.R`
- `R/reactome_analysis.R`

#### UniProt Domain Adapters
UniProt is decomposed by resource domain rather than held in one endpoint module. The package supports protein, proteome, taxonomy, UniParc, coordinate, and proteomics-oriented calls, each translating service-specific requests into R results through the common infrastructure.
- `R/uniprot_proteins.R`
- `R/uniprot_taxonomy.R`
- `R/uniprot_proteomes.R`
- `R/uniprot_uniparc.R`
- `R/uniprot_coordinates.R`
- `R/uniprot_proteomics.R`

#### Data, Pagination, and Provenance Flow
Typical flow is: caller supplies validated arguments and optional call-scoped options → service adapter builds and executes HTTP request(s) → shared parsers convert responses to lists/data frames → result may retain raw-response files and request metadata. Metadata includes calls, HTTP responses, timestamps, and parsers when enabled.

For paginated endpoints, `rba_pages()` evaluates a quoted resource call repeatedly with requested page values and returns a page-keyed collection; individual page results retain their own metadata. Multi-request operations likewise aggregate request provenance on the returned result.

#### Distribution and Documentation Boundary
This is a CRAN-oriented R package, not a hosted application. User documentation is generated from the README/vignettes and installed Rd manuals; service-specific vignettes describe intended workflows.
- `README.Rmd`
- `vignettes/rbioapi.Rmd`
- `vignettes/rbioapi_reactome.Rmd`
- `vignettes/rbioapi_uniprot.Rmd`

CI is GitHub Actions-based R CMD checking, with package documentation site generation configured separately.
- `.github/workflows/R-CMD-check.yaml`
- `.github/workflows/pkgdown.yaml`

Main entry points: [`R/internal_functions.R`](https://github.com/moosa-r/rbioapi/blob/master/R/internal_functions.R) (HTTP request layer), [`R/helper_functions.R`](https://github.com/moosa-r/rbioapi/blob/master/R/helper_functions.R) (Options and validation), [`R/reactome_analysis.R`](https://github.com/moosa-r/rbioapi/blob/master/R/reactome_analysis.R) (Reactome analysis), [`R/uniprot_proteins.R`](https://github.com/moosa-r/rbioapi/blob/master/R/uniprot_proteins.R) (UniProt domain adapters)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_package["Package surface"]
  node_metadata["Package metadata"]
  node_namespace["Exports and namespace<br/>R namespace"]
  node_startup["Package startup<br/>R initialization<br/>[zzz.R]"]
  node_public_api["rba_* public API<br/>R resource functions"]
end

subgraph group_shared["Shared request layer"]
  node_options["Options and validation<br/>shared R helpers<br/>[helper_functions.R]"]
  node_request_layer["HTTP request layer<br/>shared R infrastructure"]
  node_results[("Parsed R results<br/>lists and data frames")]
  node_pagination["Pagination and metadata<br/>shared operations"]
end

subgraph group_adapters["Service adapters"]
  node_enrichr["Enrichr adapter<br/>service adapter<br/>[enrichr.R]"]
  node_jaspar["JASPAR adapter<br/>service adapter<br/>[jaspar.R]"]
  node_mieaa_panther["miEAA and PANTHER<br/>service adapters<br/>[mieaa.R]"]
  node_stringdb["STRING adapter<br/>service adapter<br/>[stringdb.R]"]
  node_reactome_content["Reactome content<br/>service adapter<br/>[reactome_content.R]"]
  node_reactome_analysis["Reactome analysis<br/>job workflow adapter"]
  node_uniprot["UniProt domain adapters<br/>service adapters<br/>[uniprot_proteins.R]"]
end

subgraph group_distribution["Distribution"]
  node_readme["README and user guides<br/>package documentation<br/>[README.Rmd]"]
  node_vignette_reactome["Reactome vignette<br/>workflow documentation"]
  node_vignette_uniprot["UniProt vignette<br/>workflow documentation"]
  node_ci["R CMD check CI<br/>GitHub Actions workflow<br/>[R-CMD-check.yaml]"]
  node_pkgdown["Documentation site CI<br/>GitHub Actions workflow<br/>[pkgdown.yaml]"]
end

node_web_services{{"Biological web services<br/>external APIs"}}
node_ensembl{{"Ensembl<br/>external connectivity target"}}

node_metadata -->|"defines package"| node_namespace
node_namespace -->|"exports"| node_public_api
node_startup -->|"initializes"| node_options
node_public_api -->|"validates options"| node_options
node_options -->|"configures requests"| node_request_layer
node_public_api -->|"routes calls"| node_enrichr
node_public_api -->|"routes calls"| node_jaspar
node_public_api -->|"routes calls"| node_mieaa_panther
node_public_api -->|"routes calls"| node_stringdb
node_public_api -->|"routes calls"| node_reactome_content
node_public_api -->|"routes calls"| node_reactome_analysis
node_public_api -->|"routes calls"| node_uniprot
node_pagination -.->|"re-evaluates resource calls"| node_public_api
node_request_layer -->|"parses and records metadata"| node_results
node_enrichr -->|"builds requests"| node_request_layer
node_jaspar -->|"builds requests"| node_request_layer
node_mieaa_panther -->|"builds requests"| node_request_layer
node_stringdb -->|"builds requests"| node_request_layer
node_reactome_content -->|"content requests"| node_request_layer
node_reactome_analysis -->|"jobs and polling"| node_request_layer
node_uniprot -->|"builds requests"| node_request_layer
node_request_layer -->|"HTTP"| node_web_services
node_request_layer -.->|"connection check"| node_ensembl
node_readme -.->|"documents"| node_public_api
node_vignette_reactome -.->|"documents workflow"| node_reactome_analysis
node_vignette_uniprot -.->|"documents workflow"| node_uniprot
node_ci -.->|"checks package"| node_metadata
node_pkgdown -.->|"publishes docs"| node_readme

click node_metadata "https://github.com/moosa-r/rbioapi/blob/master/DESCRIPTION"
click node_namespace "https://github.com/moosa-r/rbioapi/blob/master/NAMESPACE"
click node_startup "https://github.com/moosa-r/rbioapi/blob/master/R/zzz.R"
click node_options "https://github.com/moosa-r/rbioapi/blob/master/R/helper_functions.R"
click node_request_layer "https://github.com/moosa-r/rbioapi/blob/master/R/internal_functions.R"
click node_pagination "https://github.com/moosa-r/rbioapi/blob/master/R/internal_functions.R"
click node_enrichr "https://github.com/moosa-r/rbioapi/blob/master/R/enrichr.R"
click node_jaspar "https://github.com/moosa-r/rbioapi/blob/master/R/jaspar.R"
click node_mieaa_panther "https://github.com/moosa-r/rbioapi/blob/master/R/mieaa.R"
click node_stringdb "https://github.com/moosa-r/rbioapi/blob/master/R/stringdb.R"
click node_reactome_content "https://github.com/moosa-r/rbioapi/blob/master/R/reactome_content.R"
click node_reactome_analysis "https://github.com/moosa-r/rbioapi/blob/master/R/reactome_analysis.R"
click node_uniprot "https://github.com/moosa-r/rbioapi/blob/master/R/uniprot_proteins.R"
click node_readme "https://github.com/moosa-r/rbioapi/blob/master/README.Rmd"
click node_vignette_reactome "https://github.com/moosa-r/rbioapi/blob/master/vignettes/rbioapi_reactome.Rmd"
click node_vignette_uniprot "https://github.com/moosa-r/rbioapi/blob/master/vignettes/rbioapi_uniprot.Rmd"
click node_ci "https://github.com/moosa-r/rbioapi/blob/master/.github/workflows/R-CMD-check.yaml"
click node_pkgdown "https://github.com/moosa-r/rbioapi/blob/master/.github/workflows/pkgdown.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_metadata,node_namespace,node_startup,node_public_api toneBlue
class node_options,node_request_layer,node_results,node_pagination toneAmber
class node_enrichr,node_jaspar,node_mieaa_panther,node_stringdb,node_reactome_content,node_reactome_analysis,node_uniprot toneMint
class node_readme,node_vignette_reactome,node_vignette_uniprot,node_ci,node_pkgdown toneRose
class node_web_services,node_ensembl toneNeutral
```

## Components

### Package surface

- [Package metadata](https://github.com/moosa-r/rbioapi/blob/master/DESCRIPTION): R package metadata · `DESCRIPTION`
- [Exports and namespace](https://github.com/moosa-r/rbioapi/blob/master/NAMESPACE): R namespace · `NAMESPACE`
- [Package startup](https://github.com/moosa-r/rbioapi/blob/master/R/zzz.R): R initialization · `R/zzz.R`
- **rba_* public API**: R resource functions · Resource-oriented calls are organized by remote service.

### Shared request layer

- [Options and validation](https://github.com/moosa-r/rbioapi/blob/master/R/helper_functions.R): shared R helpers · Applies call-scoped timeout, retry, diagnostics, and error behavior. · `R/helper_functions.R`
- [HTTP request layer](https://github.com/moosa-r/rbioapi/blob/master/R/internal_functions.R): shared R infrastructure · Executes requests and normalizes errors and responses. · `R/internal_functions.R`
- **Parsed R results**: lists and data frames · Can retain raw files and request provenance.
- [Pagination and metadata](https://github.com/moosa-r/rbioapi/blob/master/R/internal_functions.R): shared operations · Repeats quoted resource calls and aggregates page-level provenance. · `R/internal_functions.R`

### Service adapters

- [Enrichr adapter](https://github.com/moosa-r/rbioapi/blob/master/R/enrichr.R): service adapter · `R/enrichr.R`
- [JASPAR adapter](https://github.com/moosa-r/rbioapi/blob/master/R/jaspar.R): service adapter · `R/jaspar.R`
- [miEAA and PANTHER](https://github.com/moosa-r/rbioapi/blob/master/R/mieaa.R): service adapters · `R/mieaa.R`
- [STRING adapter](https://github.com/moosa-r/rbioapi/blob/master/R/stringdb.R): service adapter · `R/stringdb.R`
- [Reactome content](https://github.com/moosa-r/rbioapi/blob/master/R/reactome_content.R): service adapter · Synchronous pathway, entity, search, and export resources. · `R/reactome_content.R`
- [Reactome analysis](https://github.com/moosa-r/rbioapi/blob/master/R/reactome_analysis.R): job workflow adapter · Submits analysis jobs, polls status, and retrieves artifacts. · `R/reactome_analysis.R`
- [UniProt domain adapters](https://github.com/moosa-r/rbioapi/blob/master/R/uniprot_proteins.R): service adapters · Protein, taxonomy, proteome, UniParc, coordinate, and proteomics resources. · `R/uniprot_proteins.R`

### Distribution

- [README and user guides](https://github.com/moosa-r/rbioapi/blob/master/README.Rmd): package documentation · Introduces package and service workflows. · `README.Rmd`
- [Reactome vignette](https://github.com/moosa-r/rbioapi/blob/master/vignettes/rbioapi_reactome.Rmd): workflow documentation · `vignettes/rbioapi_reactome.Rmd`
- [UniProt vignette](https://github.com/moosa-r/rbioapi/blob/master/vignettes/rbioapi_uniprot.Rmd): workflow documentation · `vignettes/rbioapi_uniprot.Rmd`
- [R CMD check CI](https://github.com/moosa-r/rbioapi/blob/master/.github/workflows/R-CMD-check.yaml): GitHub Actions workflow · `.github/workflows/R-CMD-check.yaml`
- [Documentation site CI](https://github.com/moosa-r/rbioapi/blob/master/.github/workflows/pkgdown.yaml): GitHub Actions workflow · `.github/workflows/pkgdown.yaml`

### Other components

- **Biological web services**: external APIs · Enrichr, JASPAR, miEAA, PANTHER, STRING, Reactome, and UniProt.
- **Ensembl**: external connectivity target · Used by package connection checking.

## Connections

- Package metadata → Exports and namespace: defines package
- Exports and namespace → rba_* public API: exports
- Package startup → Options and validation: initializes
- rba_* public API → Options and validation: validates options
- Options and validation → HTTP request layer: configures requests
- rba_* public API → Enrichr adapter: routes calls
- rba_* public API → JASPAR adapter: routes calls
- rba_* public API → miEAA and PANTHER: routes calls
- rba_* public API → STRING adapter: routes calls
- rba_* public API → Reactome content: routes calls
- rba_* public API → Reactome analysis: routes calls
- rba_* public API → UniProt domain adapters: routes calls
- Pagination and metadata → rba_* public API: re-evaluates resource calls
- HTTP request layer → Parsed R results: parses and records metadata
- Enrichr adapter → HTTP request layer: builds requests
- JASPAR adapter → HTTP request layer: builds requests
- miEAA and PANTHER → HTTP request layer: builds requests
- STRING adapter → HTTP request layer: builds requests
- Reactome content → HTTP request layer: content requests
- Reactome analysis → HTTP request layer: jobs and polling
- UniProt domain adapters → HTTP request layer: builds requests
- HTTP request layer → Biological web services: HTTP
- HTTP request layer → Ensembl: connection check
- README and user guides → rba_* public API: documents
- Reactome vignette → Reactome analysis: documents workflow
- UniProt vignette → UniProt domain adapters: documents workflow
- R CMD check CI → Package metadata: checks package
- Documentation site CI → README and user guides: publishes docs
