# phuijse/montecarlobook architecture

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

- Interactive diagram: https://gitdiagram.com/phuijse/montecarlobook
- Repository: https://github.com/phuijse/montecarlobook

## Overview

1. **Repository role**
   - This is not an application backend or library; it is a **Jupyter Book** that publishes educational content on Monte Carlo methods and MCMC.
   - The main architectural boundary is between **authoring content in notebooks** and **building a static documentation site** for GitHub Pages.

2. **Primary content layer: `lectures/`**
   - The core of the book lives in the `lectures/` directory.
   - Each `.ipynb` notebook is effectively a chapter or lesson: `intro`, `monte_carlo`, `random_numbers`, `random_walk`, `markov`, `mcmc1`, `mcmc2`, and `numpyro`.
   - These notebooks are the main source of narrative, equations, code examples, and generated figures.

3. **Supporting media**
   - `lectures/images/` holds images used by the notebooks.
   - These are part of the instructional content pipeline and are typically embedded into notebook pages during rendering.

4. **Data dependency layer: `data/`**
   - The `data/` directory contains notebook input datasets: `mistery_data.npy` and `mnist_data_fives.pkl`.
   - These are offline assets consumed by the notebooks for demonstrations, simulations, or inference examples.
   - The architecture is “content + local data,” with notebooks reading these files directly rather than fetching data from external services at runtime.

5. **Book structure and navigation**
   - `_toc.yml` defines the book’s table of contents and chapter ordering.
   - This file is the navigation backbone of the site: it determines how notebooks are assembled into a coherent sequence for readers.

6. **Site and build configuration**
   - `_config.yml` contains Jupyter Book configuration such as site metadata, execution behavior, and build settings.
   - Together with `_toc.yml`, it separates **content organization** from **site generation policy**.

7. **Presentation customization**
   - `_static/custom.css` provides site-specific styling overrides.
   - This is the visual customization boundary: content remains in notebooks, while appearance is adjusted at the static-site layer.

8. **Build/runtime model**
   - The book is built with **Jupyter Book**, which converts notebooks into a static website.
   - That means the runtime is primarily **browser-side static hosting**, not a server application.
   - Any notebook code execution happens during authoring/build time, depending on the configured Jupyter Book execution settings.

9. **Publishing target**
   - The README indicates the book is published on **GitHub Pages**.
   - So the deployment architecture is a static site pipeline: source notebooks and configs in the repo, generated HTML hosted externally by GitHub Pages.

10. **Educational flow of the content**
   - The topic progression is conceptual and cumulative: Monte Carlo basics → random walks → Markov processes → Metropolis → MCMC implementation/diagnostics → Bayesian inference with MCMC.
   - This suggests the notebooks are intentionally ordered to support a teaching arc, not independent documentation pages.

11. **Repository boundaries**
   - There is no separate service layer, API layer, or database layer.
   - The only persistent assets are the authored notebooks, local datasets, and static site configuration; everything else is generated from those sources.

12. **What an architecture diagram should emphasize**
   - Inputs: notebooks, images, datasets, config files.
   - Processing: Jupyter Book build pipeline.
   - Output: static website published to GitHub Pages.
   - The key dependency arrows are from `data/` and `lectures/images/` into notebooks, then from notebooks + `_toc.yml` + `_config.yml` into the generated site.

Main entry points: [`lectures/images`](https://github.com/phuijse/montecarlobook/tree/main/lectures/images) (Lecture images), [`lectures/mcmc1.ipynb`](https://github.com/phuijse/montecarlobook/blob/main/lectures/mcmc1.ipynb) (MCMC I), [`lectures/monte_carlo.ipynb`](https://github.com/phuijse/montecarlobook/blob/main/lectures/monte_carlo.ipynb) (Monte Carlo), [`lectures/random_numbers.ipynb`](https://github.com/phuijse/montecarlobook/blob/main/lectures/random_numbers.ipynb) (Random Numbers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Authoring content"]
  node_intro["Intro<br/>notebook chapter<br/>[intro.ipynb]"]
  node_monte_carlo["Monte Carlo<br/>notebook chapter<br/>[monte_carlo.ipynb]"]
  node_random_numbers["Random Numbers<br/>notebook chapter"]
  node_random_walk["Random Walk<br/>notebook chapter<br/>[random_walk.ipynb]"]
  node_markov["Markov<br/>notebook chapter<br/>[markov.ipynb]"]
  node_mcmc1["MCMC I<br/>notebook chapter<br/>[mcmc1.ipynb]"]
  node_mcmc2["MCMC II<br/>notebook chapter<br/>[mcmc2.ipynb]"]
  node_numpyro["NumPyro<br/>notebook chapter<br/>[numpyro.ipynb]"]
  node_lecture_images["Lecture images<br/>media assets"]
  node_data_assets[("Data assets<br/>local datasets")]
end

subgraph group_control["Book structure"]
  node_readme["README<br/>overview<br/>[README.md]"]
  node_toc["TOC<br/>navigation config<br/>[_toc.yml]"]
  node_config["Config<br/>[_config.yml]"]
  node_custom_css["Custom CSS<br/>style override<br/>[custom.css]"]
end

subgraph group_delivery["Build and publish"]
  node_jupyter_book{{"Jupyter Book<br/>build pipeline"}}
  node_site["GitHub Pages<br/>static site"]
end

node_readme -->|"describes"| node_jupyter_book
node_toc -->|"orders"| node_jupyter_book
node_config -->|"configures"| node_jupyter_book
node_custom_css -->|"styles"| node_site
node_lecture_images -->|"embedded in"| node_intro
node_lecture_images -->|"embedded in"| node_monte_carlo
node_lecture_images -->|"embedded in"| node_random_numbers
node_lecture_images -->|"embedded in"| node_random_walk
node_lecture_images -->|"embedded in"| node_markov
node_lecture_images -->|"embedded in"| node_mcmc1
node_lecture_images -->|"embedded in"| node_mcmc2
node_lecture_images -->|"embedded in"| node_numpyro
node_data_assets -->|"feeds examples"| node_mcmc1
node_data_assets -->|"feeds examples"| node_numpyro
node_intro -->|"flows to"| node_monte_carlo
node_monte_carlo -->|"flows to"| node_random_numbers
node_random_numbers -->|"flows to"| node_random_walk
node_random_walk -->|"flows to"| node_markov
node_markov -->|"flows to"| node_mcmc1
node_mcmc1 -->|"flows to"| node_mcmc2
node_mcmc2 -->|"flows to"| node_numpyro
node_intro -->|"build input"| node_jupyter_book
node_monte_carlo -->|"build input"| node_jupyter_book
node_random_numbers -->|"build input"| node_jupyter_book
node_random_walk -->|"build input"| node_jupyter_book
node_markov -->|"build input"| node_jupyter_book
node_mcmc1 -->|"build input"| node_jupyter_book
node_mcmc2 -->|"build input"| node_jupyter_book
node_numpyro -->|"build input"| node_jupyter_book
node_jupyter_book -->|"publishes"| node_site

click node_readme "https://github.com/phuijse/montecarlobook/blob/main/README.md"
click node_intro "https://github.com/phuijse/montecarlobook/blob/main/lectures/intro.ipynb"
click node_monte_carlo "https://github.com/phuijse/montecarlobook/blob/main/lectures/monte_carlo.ipynb"
click node_random_numbers "https://github.com/phuijse/montecarlobook/blob/main/lectures/random_numbers.ipynb"
click node_random_walk "https://github.com/phuijse/montecarlobook/blob/main/lectures/random_walk.ipynb"
click node_markov "https://github.com/phuijse/montecarlobook/blob/main/lectures/markov.ipynb"
click node_mcmc1 "https://github.com/phuijse/montecarlobook/blob/main/lectures/mcmc1.ipynb"
click node_mcmc2 "https://github.com/phuijse/montecarlobook/blob/main/lectures/mcmc2.ipynb"
click node_numpyro "https://github.com/phuijse/montecarlobook/blob/main/lectures/numpyro.ipynb"
click node_lecture_images "https://github.com/phuijse/montecarlobook/tree/main/lectures/images"
click node_data_assets "https://github.com/phuijse/montecarlobook/tree/main/data"
click node_toc "https://github.com/phuijse/montecarlobook/blob/main/_toc.yml"
click node_config "https://github.com/phuijse/montecarlobook/blob/main/_config.yml"
click node_custom_css "https://github.com/phuijse/montecarlobook/blob/main/_static/custom.css"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_intro,node_monte_carlo,node_random_numbers,node_random_walk,node_markov,node_mcmc1,node_mcmc2,node_numpyro,node_lecture_images,node_data_assets toneBlue
class node_readme,node_toc,node_config,node_custom_css toneAmber
class node_jupyter_book,node_site toneMint
```

## Components

### Authoring content

Notebook-based chapters and supporting media

- [Intro](https://github.com/phuijse/montecarlobook/blob/main/lectures/intro.ipynb): notebook chapter · Opening lesson for the book · `lectures/intro.ipynb`
- [Monte Carlo](https://github.com/phuijse/montecarlobook/blob/main/lectures/monte_carlo.ipynb): notebook chapter · Core Monte Carlo concepts and examples · `lectures/monte_carlo.ipynb`
- [Random Numbers](https://github.com/phuijse/montecarlobook/blob/main/lectures/random_numbers.ipynb): notebook chapter · Random number generation and sampling foundations · `lectures/random_numbers.ipynb`
- [Random Walk](https://github.com/phuijse/montecarlobook/blob/main/lectures/random_walk.ipynb): notebook chapter · Stochastic motion and simulation patterns · `lectures/random_walk.ipynb`
- [Markov](https://github.com/phuijse/montecarlobook/blob/main/lectures/markov.ipynb): notebook chapter · Markov chains and transition structure · `lectures/markov.ipynb`
- [MCMC I](https://github.com/phuijse/montecarlobook/blob/main/lectures/mcmc1.ipynb): notebook chapter · Metropolis-style sampling foundations · `lectures/mcmc1.ipynb`
- [MCMC II](https://github.com/phuijse/montecarlobook/blob/main/lectures/mcmc2.ipynb): notebook chapter · Diagnostics, refinements, and extended MCMC topics · `lectures/mcmc2.ipynb`
- [NumPyro](https://github.com/phuijse/montecarlobook/blob/main/lectures/numpyro.ipynb): notebook chapter · Probabilistic programming and Bayesian inference · `lectures/numpyro.ipynb`
- [Lecture images](https://github.com/phuijse/montecarlobook/tree/main/lectures/images): media assets · Figures and images embedded in notebook chapters · `lectures/images`
- [Data assets](https://github.com/phuijse/montecarlobook/tree/main/data): local datasets · Offline datasets consumed by examples and exercises · `data`

### Book structure

Navigation, configuration, and presentation

- [README](https://github.com/phuijse/montecarlobook/blob/main/README.md): overview · Project summary and publishing context · `README.md`
- [TOC](https://github.com/phuijse/montecarlobook/blob/main/_toc.yml): navigation config · Book order and chapter structure · `_toc.yml`
- [Config](https://github.com/phuijse/montecarlobook/blob/main/_config.yml): build config · Jupyter Book settings and execution policy · `_config.yml`
- [Custom CSS](https://github.com/phuijse/montecarlobook/blob/main/_static/custom.css): style override · Site-specific visual styling · `_static/custom.css`

### Build and publish

Jupyter Book generation and static hosting

- **Jupyter Book**: build pipeline · Converts notebooks and config into a static site
- **GitHub Pages**: static site · Published HTML documentation hosted as a static site

## Connections

- README → Jupyter Book: describes · README documents the publishing model
- TOC → Jupyter Book: orders · TOC defines the book sequence
- Config → Jupyter Book: configures · Build and execution settings flow into the book build
- Custom CSS → GitHub Pages: styles · Custom CSS overrides the rendered output
- Lecture images → Intro: embedded in · Images are used within notebook pages
- Lecture images → Monte Carlo: embedded in · Images are used within notebook pages
- Lecture images → Random Numbers: embedded in · Images are used within notebook pages
- Lecture images → Random Walk: embedded in · Images are used within notebook pages
- Lecture images → Markov: embedded in · Images are used within notebook pages
- Lecture images → MCMC I: embedded in · Images are used within notebook pages
- Lecture images → MCMC II: embedded in · Images are used within notebook pages
- Lecture images → NumPyro: embedded in · Images are used within notebook pages
- Data assets → MCMC I: feeds examples · Local datasets support demonstrations and inference exercises
- Data assets → NumPyro: feeds examples · Local datasets support demonstrations and inference exercises
- Intro → Monte Carlo: flows to · Conceptual progression through the book
- Monte Carlo → Random Numbers: flows to · Conceptual progression through the book
- Random Numbers → Random Walk: flows to · Conceptual progression through the book
- Random Walk → Markov: flows to · Conceptual progression through the book
- Markov → MCMC I: flows to · Conceptual progression through the book
- MCMC I → MCMC II: flows to · Conceptual progression through the book
- MCMC II → NumPyro: flows to · Conceptual progression through the book
- Intro → Jupyter Book: build input · Chapters are compiled into the site
- Monte Carlo → Jupyter Book: build input · Chapters are compiled into the site
- Random Numbers → Jupyter Book: build input · Chapters are compiled into the site
- Random Walk → Jupyter Book: build input · Chapters are compiled into the site
- Markov → Jupyter Book: build input · Chapters are compiled into the site
- MCMC I → Jupyter Book: build input · Chapters are compiled into the site
- MCMC II → Jupyter Book: build input · Chapters are compiled into the site
- NumPyro → Jupyter Book: build input · Chapters are compiled into the site
- Jupyter Book → GitHub Pages: publishes · Build output is deployed as a static website
