# bayesianstellarevolution/base-cpp architecture

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

- Interactive diagram: https://gitdiagram.com/bayesianstellarevolution/base-cpp
- Repository: https://github.com/bayesianstellarevolution/base-cpp

## Overview

##### Project Type & Purpose
- Purpose: BASE-9 recovers star cluster and stellar parameters using Bayesian techniques (MCMC for cluster-level parameters and brute-force numerical integration for stellar quantities).
- Type: This is a research/scientific command-line application that leverages advanced numerical methods and simulation. It is modular in design and supports R interfacing (via the BASE9-Rcpp submodule) for easier usability in the R statistical environment.

##### File Structure for Architectural Components
- Core Engine (base9 directory):
- Contains the heart of the stellar and white dwarf models (e.g., various wd atmosphere/cooling models, isochrone handling, matrix operations).
- Implements key algorithms such as MCMC samplers, filters, star clustering, and transformation methods.
- Houses configuration headers, exception handling, and utility functions.
- R Interface (BASE9-Rcpp directory):
- Provides Rcpp bindings to expose core functionalities to R users. Includes R functions (R/RcppExports.R) and Rcpp generated files.
- Specialized MCMC & Simulation Modules:
- Directories such as multiPopMcmc, singlePopMcmc, sampleMass, sampleWDMass, and simCluster each contain specific executables (with their individual CMakeLists.txt files) tailored to run separate simulation tasks or MCMC implementations.
- Build & Deployment Infrastructure:
- CMakeLists.txt at the top level and within several subdirectories.
- Shell build scripts (build.sh, build_local.sh), Docker configuration, and additional deployment scripts.
- Documentation & Scripts:
- docs directory for manuals and how-to guides.
- scripts directory contains plotting, database, and analysis scripts to aid in deployment and debugging.

##### Main Components & Their Interactions
- Input/Configuration Module:
- Uses YAML and CMake config files (e.g., conf/base9.yaml, Base9Config.h.in) to set parameters and compile-time configurations.
- Core Computational Library:
- The base9 library provides the building blocks: stellar models, white dwarf atmosphere/cooling models, and mathematical tools.
- Modules are structured into “Models,” “Utilities,” “I/O” operations, and “Samplers.”
- MCMC and Simulation Modules:
- Independent executables such as multiPopMcmc, singlePopMcmc, sampleMass, etc., that call into the core library.
- Each of these components initializes and orchestrates the MCMC run or simulation while interacting with shared libraries.
- R Interface Layer:
- The BASE9-Rcpp submodule wraps core functionalities for R integration, allowing statistical analysis and further processing within the R ecosystem.
- External Dependencies & Libraries:
- Dependencies include GSL, Boost, and C++11 std libraries, which are used throughout the project for numerical integration, concurrency, and more.
- Build & Deployment System:
- CMake and shell/docker scripts manage the build process and packaging, ensuring consistency across environments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Subgraph for Input/Configuration & Dependencies
    subgraph "Input/Configuration & Dependencies"
        A["Input/Configuration: YAML (conf/base9.yaml), Base9Config.h.in"]:::config
        K["External Dependencies: GSL,Boost,C++11"]:::external
    end

    %% Subgraph for Core Computational Engine
    subgraph "Core Computational Engine"
        B["Core Engine: Stellar Models & Utilities (base9)"]:::core
    end

    %% Subgraph for MCMC & Simulation Modules
    subgraph "MCMC & Simulation Modules"
        C["MCMC: Multi-Population (multiPopMcmc)"]:::mcmc
        D["MCMC: Single-Population (singlePopMcmc)"]:::mcmc
        E["Simulation: Sample Mass (sampleMass)"]:::mcmc
        F["Simulation: Sample WD Mass (sampleWDMass)"]:::mcmc
        G["Simulation: Cluster (simCluster)"]:::mcmc
    end

    %% R Interface Layer
    H["R Interface: BASE9-Rcpp"]:::interface

    %% Build & Deployment System
    I["Build & Deployment: CMake, build scripts, Docker"]:::build

    %% Documentation & Scripts
    J["Documentation & Scripts: docs, scripts"]:::docs

    %% Data flow connections
    A -->|"configures"| B
    K -->|"dependencies"| B

    B -->|"calls"| C
    B -->|"calls"| D
    B -->|"calls"| E
    B -->|"calls"| F
    B -->|"calls"| G
    B -->|"exposes"| H

    %% Build system dependencies to all layers
    I -->|"builds"| A
    I -->|"builds"| B
    I -->|"builds"| C
    I -->|"builds"| D
    I -->|"builds"| E
    I -->|"builds"| F
    I -->|"builds"| G
    I -->|"builds"| H
    I -->|"builds"| J

    %% Styles and Colors
    classDef config fill:#ffebcd,stroke:#333,stroke-width:2px;
    classDef core fill:#f0e68c,stroke:#333,stroke-width:2px;
    classDef mcmc fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef interface fill:#98fb98,stroke:#333,stroke-width:2px;
    classDef build fill:#ffe4b5,stroke:#333,stroke-width:2px;
    classDef docs fill:#d3d3d3,stroke:#333,stroke-width:2px;
    classDef external fill:#ffc0cb,stroke:#333,stroke-width:2px;

    %% Click Events
    click A "https://github.com/bayesianstellarevolution/base-cpp/blob/master/conf/base9.yaml"
    click B "https://github.com/bayesianstellarevolution/base-cpp/tree/master/base9/"
    click C "https://github.com/bayesianstellarevolution/base-cpp/blob/master/multiPopMcmc/McmcApplication.cpp"
    click D "https://github.com/bayesianstellarevolution/base-cpp/blob/master/singlePopMcmc/McmcApplication.cpp"
    click E "https://github.com/bayesianstellarevolution/base-cpp/blob/master/sampleMass/sampleMass.cpp"
    click F "https://github.com/bayesianstellarevolution/base-cpp/blob/master/sampleWDMass/sampleWDMass.cpp"
    click G "https://github.com/bayesianstellarevolution/base-cpp/blob/master/simCluster/simCluster.cpp"
    click H "https://github.com/bayesianstellarevolution/base-cpp/tree/master/BASE9-Rcpp/src"
    click I "https://github.com/bayesianstellarevolution/base-cpp/blob/master/CMakeLists.txt"
    click J "https://github.com/bayesianstellarevolution/base-cpp/tree/master/docs/"
```
