# insightsengineering/teal architecture

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

- Interactive diagram: https://gitdiagram.com/insightsengineering/teal
- Repository: https://github.com/insightsengineering/teal

## Overview

##### Project type and purpose
- This is an R package (“teal”) that provides a Shiny‐based interactive exploratory data‐analysis framework. It is not a standalone web app, but a library/framework that application authors use to assemble Shiny apps by supplying data and plugging in “teal modules.”

##### File structure
- Top‐level package structure:
- DESCRIPTION, NAMESPACE, R/, inst/, man/, tests/, vignettes/ – typical R package.
- inst/css, inst/js: static front‐end assets (CSS/JS) for Shiny.
- R/: contains core drivers, module definitions, data‐handling utilities, validation, logging, reporter, code‐repro modules.
- Key files in R/:
- TealAppDriver.R – initializes the Shiny app (init(), app$ui, app$server).
- tdata.R, teal_data_module.* – data ingestion & slicing.
- module_*.R – UI/server logic for filter panels, data summary, transform, bookmarking, snapshots, session info.
- teal_reporter.R, reporter_previewer_module.R – reporting engine.
- teal_modifiers.R, code utilities – reproducibility/tracking.
- utils.R, validations.R – shared helpers & input checks.
- External workflows/config: .github/workflows (CI, docs, release), .gitlab-ci.yml – continuous integration & deployment pipelines.

##### README for additional insights
- Describes how users call init(data =…, modules = list(module1, module2,…)).
- Lists core dependent packages: teal.data (data loader), teal.widgets (UI components), teal.slice (filter panel), teal.code (reproducibility), teal.logger (logging), teal.reporter (reports).
- Emphasizes modular structure: each “teal module” is a Shiny module with UI + server.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "User"
        User["User"] 
    end

    subgraph "Shiny Runtime"
        UI["Shiny UI"]:::assets
        Server["Shiny Server"]:::core
        UI --> Server
    end

    subgraph "teal Package"
        subgraph "Core Engine"
            Driver["TealAppDriver"]:::core
            ModuleManager["Module Manager"]:::core
            DataManager["Data Manager"]:::core
            FilterManager["Filter/Slice Manager"]:::core
            Transform["Transform Module"]:::core
            Reporter["Reporting Engine"]:::core
            CodeRecorder["Code Recorder"]:::core
            Utils["Core Utilities & Validation"]:::utils
            Driver --> ModuleManager
            Driver --> DataManager
            ModuleManager --> FilterManager
            ModuleManager --> Transform
            ModuleManager --> Reporter
            ModuleManager --> CodeRecorder
            DataManager --> ModuleManager
            FilterManager --> ModuleManager
            Utils --> Driver
        end

        subgraph "Teal Modules"
            Bookmark["Bookmark Manager"]:::extension
            Snapshot["Snapshot Manager"]:::extension
            DataSummary["Data Summary"]:::extension
            SessionInfo["Session Info"]:::extension
            LandingPopup["Landing Popup"]:::extension
            NestedTabs["Nested Tabs"]:::extension
            ModuleManager --> Bookmark
            ModuleManager --> Snapshot
            ModuleManager --> DataSummary
            ModuleManager --> SessionInfo
            ModuleManager --> LandingPopup
            ModuleManager --> NestedTabs
        end
    end

    subgraph "External Dependencies"
        ShinyPkg["shiny"]:::external
        TealData["teal.data"]:::external
        TealWidgets["teal.widgets"]:::external
        TealSlice["teal.slice"]:::external
        TealCode["teal.code"]:::external
        TealLogger["teal.logger"]:::external
        TealReporter["teal.reporter"]:::external
        DataManager --> TealData
        ModuleManager -->|uses| TealWidgets
        FilterManager --> TealSlice
        Reporter --> TealReporter
        CodeRecorder --> TealCode
        ModuleManager --> TealLogger
        ShinyPkg -.-> UI
        ShinyPkg -.-> Server
    end

    User --> UI
    User --> DataSummary
    User --> Bookmark

    %% Click Events
    click UI "https://github.com/insightsengineering/teal/tree/main/inst/css"
    click UI "https://github.com/insightsengineering/teal/tree/main/inst/js"
    click Driver "https://github.com/insightsengineering/teal/blob/main/R/TealAppDriver.R"
    click ModuleManager "https://github.com/insightsengineering/teal/blob/main/R/modules.R"
    click DataManager "https://github.com/insightsengineering/teal/blob/main/R/tdata.R"
    click DataManager "https://github.com/insightsengineering/teal/blob/main/R/module_init_data.R"
    click DataManager "https://github.com/insightsengineering/teal/blob/main/R/module_teal_data.R"
    click DataManager "https://github.com/insightsengineering/teal/blob/main/R/teal_data_utils.R"
    click FilterManager "https://github.com/insightsengineering/teal/blob/main/R/module_filter_manager.R"
    click FilterManager "https://github.com/insightsengineering/teal/blob/main/R/module_filter_data.R"
    click FilterManager "https://github.com/insightsengineering/teal/blob/main/R/teal_slices.R"
    click FilterManager "https://github.com/insightsengineering/teal/blob/main/R/teal_slices-store.R"
    click Transform "https://github.com/insightsengineering/teal/blob/main/R/module_transform_data.R"
    click Transform "https://github.com/insightsengineering/teal/blob/main/R/teal_transform_module.R"
    click Reporter "https://github.com/insightsengineering/teal/blob/main/R/teal_reporter.R"
    click Reporter "https://github.com/insightsengineering/teal/blob/main/R/reporter_previewer_module.R"
    click CodeRecorder "https://github.com/insightsengineering/teal/blob/main/R/teal_modifiers.R"
    click CodeRecorder "https://github.com/insightsengineering/teal/blob/main/R/teal_data_module-eval_code.R"
    click CodeRecorder "https://github.com/insightsengineering/teal/blob/main/R/teal_data_module-within.R"
    click Bookmark "https://github.com/insightsengineering/teal/blob/main/R/module_bookmark_manager.R"
    click Snapshot "https://github.com/insightsengineering/teal/blob/main/R/module_snapshot_manager.R"
    click DataSummary "https://github.com/insightsengineering/teal/blob/main/R/module_data_summary.R"
    click SessionInfo "https://github.com/insightsengineering/teal/blob/main/R/module_session_info.R"
    click LandingPopup "https://github.com/insightsengineering/teal/blob/main/R/landing_popup_module.R"
    click NestedTabs "https://github.com/insightsengineering/teal/blob/main/R/module_nested_tabs.R"
    click Utils "https://github.com/insightsengineering/teal/blob/main/R/utils.R"
    click Utils "https://github.com/insightsengineering/teal/blob/main/R/validate_inputs.R"
    click Utils "https://github.com/insightsengineering/teal/blob/main/R/validations.R"

    classDef core fill:#d0e1f9,stroke:#2b6cb0,color:#2b6cb0;
    classDef extension fill:#d4f8d4,stroke:#2f855a,color:#2f855a;
    classDef external fill:#fef3c7,stroke:#dd6b20,color:#dd6b20;
    classDef assets fill:#e9d8fd,stroke:#805ad5,color:#805ad5;
    classDef utils fill:#f0f0f0,stroke:#718096,color:#718096;
```
