# bartongroup/dexdash architecture

> Architecture diagram of the GitHub repository bartongroup/dexdash, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bartongroup/dexdash
- Repository: https://github.com/bartongroup/dexdash

## Overview

##### Project type and purpose
- This is an R package that implements a Shiny web application for interactive downstream analysis of differential-expression (DE) results.
- It uses modular Shiny components for plots, enrichment, feature lookup, and global controls.
- It relies on external functional-term data (GO, KEGG, Reactome) and the fenr package for enrichment.

##### Main architectural components
A. Presentation Layer (Shiny UI modules)
- mod_global_input: file‐upload and dataset selection controls
- mod_volma_plot: volcano & MA plot interface
- mod_feature_info: gene name/description lookup
- mod_feature_plot: expression pattern plots
- mod_enrichment: enrichment result tables/plots
- mod_communication: notification & messaging UI
- explorer.R: assembles UI layout with these modules

B. Application Layer (Server logic & utilities)
- Server functions in each module handle reactive inputs, call processing functions
- util.R: shared helper functions (data checks, reshaping)
- dex dash API functions:
– dexdash_set() creates the central data object
– download_feature_information() fetches annotations from inst/extdata/species.json or web
– download_functional_terms(), prepare_functional_terms() interface to fenr

C. Data Layer
- Input data frames:
– DE results, raw expression/abundance, experimental design, gene metadata
- Cached datasets in inst/extdata (species.json)
- Prepared functional terms (GO/KEGG/Reactome) stored in memory

D. External Services & Libraries
- fenr package for fast functional enrichment
- CRAN/Bioconductor for GO, KEGG, Reactome queries
- R/Shiny runtime environment

E. Dev & Deployment Infrastructure
- renv: reproducible package environment (dependencies)
- tests: testthat suite for app logic and data downloads
- vignettes: Quarto/SASS assets for documentation

##### Relationships and data flows
- User (Browser) → Shiny Server (presented by explorer.R)
- UI modules capture user actions → Server modules
- Server modules read the central dexset object + downloaded annotations → util & fenr calls → generate plots/tables
- Data download modules call external services or use inst/extdata → populate in‐memory data
- All modules reactively update UI in response to data changes
- Tests validate each stage (data loading, plotting, enrichment)

##### Architectural patterns and principles to highlight
- Modularization: each UI/Server piece encapsulated as its own Shiny module
- Single source of truth: dexset object built by dexdash_set()
- Layered separation: UI vs. processing vs. data vs. external

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Shiny Server
    User["User/Browser"]:::external
    User --> ShinyServer["Shiny Server"]:::external

    %% Shiny App Container
    subgraph "Shiny App"
        direction TB

        subgraph "Presentation Layer" 
            direction TB
            mg_input["mod_global_input.R"]:::ui
            mg_volma["mod_volma_plot.R"]:::ui
            mg_feat_info["mod_feature_info.R"]:::ui
            mg_feat_plot["mod_feature_plot.R"]:::ui
            mg_enrich["mod_enrichment.R"]:::ui
            mg_comm["mod_communication.R"]:::ui
            explorer["explorer.R"]:::ui
        end

        subgraph "Application Layer"
            direction TB
            ut_util["util.R"]:::processing
            f_dexdash_set["dexdash_set()"]:::processing
            f_download_feature["download_feature_information()"]:::processing
            f_download_terms["download_functional_terms()"]:::processing
            f_prepare_terms["prepare_functional_terms()"]:::processing
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        InputDF["Input Data Frames"]:::data
        data_species["inst/extdata/species.json"]:::data
        data_terms["Functional Terms (GO/KEGG/Reactome)"]:::data
    end

    %% External Services
    subgraph "External Services & Libraries"
        direction TB
        fenr["fenr package"]:::external
        APIs["GO/KEGG/Reactome APIs"]:::external
    end

    %% Development Infrastructure
    subgraph "Dev & Deployment Infrastructure"
        direction TB
        renv_lock["renv.lock"]:::infra
        renv_activate["renv/activate.R"]:::infra
        renv_settings["renv/settings.json"]:::infra
        test_app["tests/testthat/test_app.R"]:::infra
        test_download["tests/testthat/test_download_terms.R"]:::infra
        test_enrich["tests/testthat/test_enrichment.R"]:::infra
        test_feat_info["tests/testthat/test_feature_info.R"]:::infra
        test_feat_plot["tests/testthat/test_feature_plot.R"]:::infra
        test_data_obj["tests/test_data/test_object.rds"]:::infra
        vig_dexdash["vignettes/dexdash.qmd"]:::infra
        vig_css["vignettes/css/styles.scss"]:::infra
        pkg_description["DESCRIPTION"]:::infra
        pkg_namespace["NAMESPACE"]:::infra
        pkg_rbuildignore[".Rbuildignore"]:::infra
        pkg_gitignore[".gitignore"]:::infra
    end

    %% Connections: UI to Server
    mg_input --> ut_util
    mg_volma --> ut_util
    mg_feat_info --> ut_util
    mg_feat_plot --> ut_util
    mg_enrich --> ut_util
    mg_comm --> ut_util
    explorer --> mg_input

    %% Server processing flows
    ut_util --> f_dexdash_set
    f_dexdash_set --> mg_volma
    f_dexdash_set --> mg_feature_plot
    mg_feat_info --> f_download_feature
    f_download_feature --> data_species
    mg_enrich --> f_download_terms
    f_download_terms --> APIs
    f_prepare_terms --> APIs
    f_download_terms --> data_terms
    f_prepare_terms --> data_terms

    %% Data layer to Application layer
    InputDF --> ut_util
    data_species --> f_download_feature
    data_terms --> f_prepare_terms

    %% External services
    fenr --> f_prepare_terms
    APIs --> f_download_terms

    %% Shiny Server hosting
    ShinyServer --> explorer

    %% Dev infra support
    renv_lock -.-> ShinyServer
    renv_activate -.-> ShinyServer
    renv_settings -.-> ShinyServer
    test_app -.-> ut_util
    test_download -.-> f_download_terms
    test_enrich -.-> f_prepare_terms
    test_feat_info -.-> f_download_feature
    test_feat_plot -.-> mg_feat_plot
    test_data_obj -.-> f_dexdash_set
    vig_dexdash -.-> explorer
    vig_css -.-> explorer
    pkg_description -.-> ShinyServer
    pkg_namespace -.-> ShinyServer
    pkg_rbuildignore -.-> ShinyServer
    pkg_gitignore -.-> ShinyServer

    %% Click events
    click mg_input "https://github.com/bartongroup/dexdash/blob/main/R/mod_global_input.R"
    click mg_volma "https://github.com/bartongroup/dexdash/blob/main/R/mod_volma_plot.R"
    click mg_feat_info "https://github.com/bartongroup/dexdash/blob/main/R/mod_feature_info.R"
    click mg_feat_plot "https://github.com/bartongroup/dexdash/blob/main/R/mod_feature_plot.R"
    click mg_enrich "https://github.com/bartongroup/dexdash/blob/main/R/mod_enrichment.R"
    click mg_comm "https://github.com/bartongroup/dexdash/blob/main/R/mod_communication.R"
    click explorer "https://github.com/bartongroup/dexdash/blob/main/R/explorer.R"
    click ut_util "https://github.com/bartongroup/dexdash/blob/main/R/util.R"
    click f_dexdash_set "https://github.com/bartongroup/dexdash/blob/main/man/dexdash_set.Rd"
    click f_download_feature "https://github.com/bartongroup/dexdash/blob/main/man/download_feature_information.Rd"
    click f_download_terms "https://github.com/bartongroup/dexdash/blob/main/man/download_functional_terms.Rd"
    click f_prepare_terms "https://github.com/bartongroup/dexdash/blob/main/man/prepare_functional_terms.Rd"
    click data_species "https://github.com/bartongroup/dexdash/blob/main/inst/extdata/species.json"
    click renv_lock "https://github.com/bartongroup/dexdash/blob/main/renv.lock"
    click renv_activate "https://github.com/bartongroup/dexdash/blob/main/renv/activate.R"
    click renv_settings "https://github.com/bartongroup/dexdash/blob/main/renv/settings.json"
    click test_app "https://github.com/bartongroup/dexdash/blob/main/tests/testthat/test_app.R"
    click test_download "https://github.com/bartongroup/dexdash/blob/main/tests/testthat/test_download_terms.R"
    click test_enrich "https://github.com/bartongroup/dexdash/blob/main/tests/testthat/test_enrichment.R"
    click test_feat_info "https://github.com/bartongroup/dexdash/blob/main/tests/testthat/test_feature_info.R"
    click test_feat_plot "https://github.com/bartongroup/dexdash/blob/main/tests/testthat/test_feature_plot.R"
    click test_data_obj "https://github.com/bartongroup/dexdash/blob/main/tests/test_data/test_object.rds"
    click vig_dexdash "https://github.com/bartongroup/dexdash/blob/main/vignettes/dexdash.qmd"
    click vig_css "https://github.com/bartongroup/dexdash/blob/main/vignettes/css/styles.scss"
    click pkg_description "https://github.com/bartongroup/dexdash/tree/main/DESCRIPTION"
    click pkg_namespace "https://github.com/bartongroup/dexdash/tree/main/NAMESPACE"
    click pkg_rbuildignore "https://github.com/bartongroup/dexdash/blob/main/.Rbuildignore"
    click pkg_gitignore "https://github.com/bartongroup/dexdash/blob/main/.gitignore"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333
    classDef processing fill:#90EE90,stroke:#333
    classDef data fill:#FFFFE0,stroke:#333
    classDef external fill:#FFA500,stroke:#333
    classDef infra fill:#D3D3D3,stroke:#333
```
