# plotly/dash-pivottable architecture

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

- Interactive diagram: https://gitdiagram.com/plotly/dash-pivottable
- Repository: https://github.com/plotly/dash-pivottable

## Overview

##### Main Components

a. Frontend Layer:
- React Component (PivotTable.react.js)
- Webpack Bundle (dash_pivottable.dev.js)
- Demo Application (App.js)

b. Python Layer:
- Dash Component Wrapper (PivotTable.py)
- Data Handling Layer (data.py)
- Testing Infrastructure (tests/)

c. R Layer:
- R Package Interface (R/dashPivotTable.R)
- R Dependencies

##### Component Relationships

**[Data Sources] → [Python/R Interface Layer] → [Dash Component] → [React PivotTable] → [User Interface]**

Use the following structure:

##### Top Level (User Interface)
- Filters, drag-drop areas, and visualization options

##### Middle Layer (Component Implementation)
- React Component (PivotTable.react.js)
- Connection to the underlying react-pivottable library
- Input data
- Configuration options
- User interactions
- Callback outputs

##### Bottom Layer (Backend Integration)
- Python wrapper (dash_pivottable)
- R package interface
- Data processing components

- Blue: Frontend components
- Green: Data processing layers
- Orange: Integration layers
- Gray: External dependencies

Important Elements to Highlight:

##### Data Flow
- How data moves from source through the Python/R layer
- How it's processed by the React component
- Demonstrate callback patterns

##### Configuration Options
- Main parameters (hiddenAttributes, menuLimit, etc.)
- How they affect the component

##### Integration Points
- Dash callback interface
- R package bindings
- React component communication

Special Considerations:

##### Multi-Language Support
- Boundaries between Python, R, and JavaScript
- How the different languages interact

##### Build Process
- Webpack bundling step
- How the component is packaged for different platforms

##### Testing Layer
- Test infrastructure
- Percy visual testing integration

Abstraction Level:
- Keep main component interaction visible
- Abstract internal react-pivottable implementation details
- Integration points between languages

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        UI_PIVOT["Interactive Pivot Table"]
        UI_FILTERS["Filters & Controls"]
        UI_DRAG["Drag & Drop Areas"]
        UI_VIZ["Visualization Options"]
    end

    subgraph FRONTEND["Frontend Implementation"]
        REACT["React PivotTable Component"]:::frontend
        WEBPACK["Webpack Bundle"]:::frontend
        DEMO["Demo Application"]:::frontend
        REACT_LIB["react-pivottable Library"]:::external
    end

    subgraph BACKEND["Backend Integration"]
        subgraph PYTHON["Python Layer"]
            DASH_WRAP["Dash Component Wrapper"]:::python
            DATA_HANDLE["Data Handling Layer"]:::python
            TESTS["Testing Infrastructure"]:::python
        end

        subgraph R["R Layer"]
            R_PKG["R Package Interface"]:::r
            R_DEPS["R Dependencies"]:::r
        end
    end

    subgraph CONFIG["Configuration & Build"]
        WEBPACK_CONFIG["Webpack Config"]:::config
        PY_CONFIG["Python Package Config"]:::config
        ENTRY_POINTS["Package Entry Points"]:::config
    end

    subgraph TEST["Testing Layer"]
        TEST_CALLBACK["Callback Tests"]:::test
        TEST_PERCY["Percy Visual Tests"]:::test
        TEST_DATA["Demo Data"]:::test
    end

    %% Relationships
    UI_PIVOT --> UI_FILTERS
    UI_PIVOT --> UI_DRAG
    UI_PIVOT --> UI_VIZ

    REACT --> REACT_LIB
    REACT --> WEBPACK
    DEMO --> REACT

    DASH_WRAP --> REACT
    DATA_HANDLE --> DASH_WRAP
    R_PKG --> DASH_WRAP

    TESTS --> TEST_CALLBACK
    TESTS --> TEST_PERCY

    %% Data Flow
    DATA_HANDLE --> UI_PIVOT
    R_PKG --> UI_PIVOT

    %% Click Events
    click REACT "https://github.com/plotly/dash-pivottable/blob/master/src/lib/components/PivotTable.react.js"
    click WEBPACK "https://github.com/plotly/dash-pivottable/blob/master/dash_pivottable/dash_pivottable.dev.js"
    click DEMO "https://github.com/plotly/dash-pivottable/blob/master/src/demo/App.js"
    click DASH_WRAP "https://github.com/plotly/dash-pivottable/blob/master/dash_pivottable/PivotTable.py"
    click DATA_HANDLE "https://github.com/plotly/dash-pivottable/blob/master/data.py"
    click TESTS "https://github.com/plotly/dash-pivottable/tree/master/tests/"
    click R_PKG "https://github.com/plotly/dash-pivottable/blob/master/R/dashPivotTable.R"
    click WEBPACK_CONFIG "https://github.com/plotly/dash-pivottable/blob/master/webpack.config.js"
    click PY_CONFIG "https://github.com/plotly/dash-pivottable/blob/master/setup.py"
    click R_DEPS "https://github.com/plotly/dash-pivottable/tree/master/DESCRIPTION"
    click TEST_DATA "https://github.com/plotly/dash-pivottable/blob/master/data/tips.RData"
    click TEST_CALLBACK "https://github.com/plotly/dash-pivottable/blob/master/tests/test_callbacks.py"
    click TEST_PERCY "https://github.com/plotly/dash-pivottable/blob/master/tests/test_percy.py"
    click ENTRY_POINTS "https://github.com/plotly/dash-pivottable/blob/master/dash_pivottable/__init__.py"

    %% Styling
    classDef frontend fill:#3498db
    classDef python fill:#2ecc71
    classDef r fill:#e67e22
    classDef external fill:#95a5a6
    classDef config fill:#34495e
    classDef test fill:#9b59b6

    %% Legend
    subgraph Legend
        FRONTEND_L["Frontend"]:::frontend
        PYTHON_L["Python"]:::python
        R_L["R"]:::r
        EXTERNAL_L["External"]:::external
        CONFIG_L["Configuration"]:::config
        TEST_L["Testing"]:::test
    end
```
