# r-causal/causal_inference_r_workshop architecture

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

- Interactive diagram: https://gitdiagram.com/r-causal/causal_inference_r_workshop
- Repository: https://github.com/r-causal/causal_inference_r_workshop

## Overview

##### Main components
- Workshop Content: This comprises the slides (both raw Quarto/HTML files and compiled PDFs) and exercise files (QMD documents). These represent the educational content that is delivered via a workshop website.
- Build & Configuration: The Quarto configuration files (e.g., _quarto.yml, README.qmd, README.Rmd) and the R project file (causal_inference_r_workshop.Rproj) provide the build environment. They specify how the documents are rendered and packaged.
- Extensions & Customizations: The _extensions directory contains additional extensions (e.g., related to styling, extra functionalities like the “kakashi” extension) which the Quarto build process uses. This also includes specialized SCSS files and configuration files (like _extension.yml) for customizing the output.
- Package-Based Installation: The repository is paired with an R package (causalworkshop) that facilitates the local installation of course materials, emphasizing how the materials are deployed both locally and in a cloud environment.
- Assets & Dependencies: The project makes heavy use of external libraries (e.g., reveal.js libraries, Quarto HTML assets, style libraries) that are used to generate interactive slides and web pages.

##### Relationships and interactions between components
- Source Documents → Renderer: The exercise and slide documents (QMD files) are rendered using Quarto with configurations defined in _quarto.yml and the R project settings.
- Extensions/CSS → Build Output: Custom extensions placed under _extensions contribute additional styles and behaviors (e.g., via sass/scss files) to the final rendered slides and HTML pages.
- Package Integration: The causalworkshop R package acts as an external service for installing dependencies and materials. It downloads and configures the project locally in the user's environment.
- Assets Integration: Static assets (images, CSS, JavaScript libraries) included in the slides folders (both raw and published pdf directories) are bundled with the final website.

##### Architectural patterns and design principles
- Static Site Generation: The project follows a static site generation approach where all content is pre-rendered into HTML/PDF formats using Quarto.
- Separation of Concerns: There is a clear separation between content (slides and exercises), build configuration (Quarto config, R project), and customization (extensions, theme files). This aligns well with modular design principles.
- Declarative Build: The system uses declarative documents (in .qmd files) that are processed by Quarto. This simplifies versioning, maintenance, and reproducibility of the teaching materials.
- Extensibility: With the _extensions directory and external package integration, the system is set up to be extended in the future (e.g., for additional themes, content types or interactive elements).

##### Relevant technologies
- R and RStudio: The project is an R project (with causal_inference_r_workshop.Rproj) relying on R packages.
- Quarto: Used for document rendering, compiling QMD files to HTML and PDF slides.
- Reveal.js: Provides the interactive, slide-based presentation functionality (visible in the many reveal.js library files).
- CSS/JavaScript Libraries: Various assets supporting styling and interactivity.
- Git and GitHub: Version control (as seen from the .gitignore and repository structure).

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Content Layer
    subgraph "Content Layer"
        SC["Slides Source (QMD)"]:::content
        EX["Exercise Documents"]:::content
    end

    %% Build & Configuration Layer
    subgraph "Build & Configuration"
        QC["Quarto Config"]:::build
        RP["R Project"]:::build
        RM["README.md"]:::build
        RQ["README.qmd"]:::build
    end

    %% Extensions & Customizations
    subgraph "Extensions & Customizations"
        EXT["Extensions Folder"]:::extensions
        KEXT["Kakashi Extension"]:::extensions
        EC["Extension Config"]:::extensions
        KS["Kakashi SCSS"]:::extensions
    end

    %% Build Process
    subgraph "Build Process"
        QBE["Quarto Build Engine"]:::build
    end

    %% Output & Deployment Layer
    subgraph "Output & Deployment"
        RS["Rendered Site (Static WebPages&Slides)"]:::output
        SP["Slides PDF Output"]:::output
        CW["causalworkshop Package"]:::external
        AS["Static Assets & Libraries"]:::external
    end

    %% Relationships: Feeding inputs into the build engine
    SC -->|"feeds"| QBE
    EX -->|"feeds"| QBE
    QC -->|"configures"| QBE
    RP -->|"configures"| QBE
    RM -->|"informs"| QBE
    RQ -->|"informs"| QBE
    EXT -->|"customizes"| QBE
    KEXT -->|"customizes"| QBE
    EC -->|"configures"| QBE
    KS -->|"styles"| QBE

    %% Build outputs
    QBE -->|"builds"| RS
    QBE -->|"generates"| SP

    %% External integrations
    AS -->|"integrates"| RS
    CW -->|"deploys"| RS

    %% Click Events for Build & Content components
    click SC "https://github.com/r-causal/causal_inference_r_workshop/tree/master/slides/raw"
    click SP "https://github.com/r-causal/causal_inference_r_workshop/tree/master/slides/pdf"
    click EX "https://github.com/r-causal/causal_inference_r_workshop/tree/master/exercises"
    click QC "https://github.com/r-causal/causal_inference_r_workshop/blob/master/_quarto.yml"
    click RP "https://github.com/r-causal/causal_inference_r_workshop/blob/master/causal_inference_r_workshop.Rproj"
    click RM "https://github.com/r-causal/causal_inference_r_workshop/blob/master/README.md"
    click RQ "https://github.com/r-causal/causal_inference_r_workshop/blob/master/README.qmd"
    click EXT "https://github.com/r-causal/causal_inference_r_workshop/tree/master/_extensions"
    click KEXT "https://github.com/r-causal/causal_inference_r_workshop/tree/master/_extensions/malcolmbarrett/kakashi"
    click EC "https://github.com/r-causal/causal_inference_r_workshop/blob/master/_extensions/malcolmbarrett/kakashi/_extension.yml"
    click KS "https://github.com/r-causal/causal_inference_r_workshop/blob/master/_extensions/malcolmbarrett/kakashi/kakashi.scss"

    %% Styles
    classDef content fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef build fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef extensions fill:#FFFF99,stroke:#333,stroke-width:1px;
    classDef output fill:#FFB6C1,stroke:#333,stroke-width:1px;
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px;
```
