# klabhub/bayesfactor architecture

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

- Interactive diagram: https://gitdiagram.com/klabhub/bayesfactor
- Repository: https://github.com/klabhub/bayesfactor

## Overview

##### Main Components
- Bayes Factor Core Module: Represented primarily by the +bf directory and its contained files. This includes the public-facing functions like anova.m, bfFromF.m, bfFromR2.m, regression.m, ttest.m, and ttest2.m. This module provides the API that users will interact with.
- Internal Computational Library: Denoted by the +bf/+internal folder, which contains numerous helper functions (e.g., designMatrix.m, interaction.m, inverseGammaPdf.m, etc.) that implement the mathematical and statistical details behind different tests.
- Installation & Entry Points: Files such as installBayesFactor.m and top-level Contents.m files indicate how the toolbox is packaged and initialized.
- Documentation & Examples: The docs and examples directories show how end users learn about and use the toolbox. This should be depicted as an ancillary component that interacts with the core API.
- Testing and Tools: The tools directory contains unit test scripts and utilities (like bfUnitTest.m and runTest.m) used to validate the functionality of the toolbox.

##### Relationships and Interactions
- The examples and documentation components reference and demonstrate the use of these functions. You might show these as “usage layers” that depend on the Core Module.
- The testing tools are coupled with both the public API and the internal functions. They are used to verify correctness and could be shown as a separate “verification” component interacting with both parts.

##### Relevant Architectural Patterns and Design Principles
- Reusability and Extensibility: The organization encourages reuse of internal functions for various statistical computations, which is important when extending functionality for additional tests.
- Clear Separation of Concerns: Examples, documentation, and tests are clearly separated from the internal computation logic.

##### Incorporate External Dependencies
- You may add a note or component for Matlab’s runtime environment and version requirements (R2017a or later).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Installation & Initialization Subgraph
    subgraph "Installation & Initialization"
        I1["installBayesFactor.m"]:::supplementary
        I2["Contents.m (root)"]:::supplementary
    end

    %% Core Modules
    BF_API["Bayes Factor Toolbox (Public API)<br>anova.m, bfFromF.m, bfFromR2.m, regression.m, ttest.m, ttest2.m"]:::core
    BF_Internal["Internal Library (+bf/internal)<br>designMatrix.m, interaction.m, cauchyPdf.m, inverseGammaPdf.m, ..."]:::internal

    %% Documentation & Examples Subgraph
    subgraph "Documentation & Examples"
        Docs["Documentation<br>docs/index.html"]:::supplementary
        Examples["Examples<br>attitude.mat, gettingStarted.m, commonDesigns.m"]:::supplementary
    end

    %% Testing & Tools
    Tools["Testing & Tools<br>bfUnitTest.m, runTest.m, pWaitBar.m, publishGitPages.m"]:::supplementary

    %% External Dependency
    Matlab["Mathworks Statistics and Machine Learning Toolbox"]:::external

    %% Relationships
    I1 -->|"initializes"| BF_API
    I2 -->|"initializes"| BF_API
    BF_API -->|"calls"| BF_Internal
    BF_API -->|"usage"| Docs
    BF_API -->|"usage"| Examples
    Tools -->|"tests"| BF_API
    Tools -->|"tests"| BF_Internal
    Matlab -->|"supports"| BF_Internal

    %% Click Events
    click BF_API "https://github.com/klabhub/bayesfactor/tree/master/+bf"
    click BF_Internal "https://github.com/klabhub/bayesfactor/tree/master/+bf/+internal"
    click I1 "https://github.com/klabhub/bayesfactor/blob/master/installBayesFactor.m"
    click I2 "https://github.com/klabhub/bayesfactor/blob/master/Contents.m"
    click Docs "https://github.com/klabhub/bayesfactor/tree/master/docs"
    click Examples "https://github.com/klabhub/bayesfactor/tree/master/examples"
    click Tools "https://github.com/klabhub/bayesfactor/tree/master/tools"

    %% Styles
    classDef core fill:#a2cffe,stroke:#333,stroke-width:2px;
    classDef internal fill:#9ee09e,stroke:#333,stroke-width:2px;
    classDef supplementary fill:#ffcc99,stroke:#333,stroke-width:2px;
    classDef external fill:#fdfd96,stroke:#333,stroke-width:2px;
```
