# phuijse/machinelearningbook architecture

> Architecture diagram of the GitHub repository phuijse/machinelearningbook, 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/machinelearningbook
- Repository: https://github.com/phuijse/machinelearningbook

## Overview

1. This repository is not an application backend or service; it is a Jupyter Book–based machine learning textbook. The primary artifact is a static website generated from notebooks and Markdown-like book structure, then published to GitHub Pages.

2. The source-of-truth content lives under `contents/`. Each topic area is organized as a chapter-like subtree:
   - `supervised_learning/`
   - `neural_networks/`
   - `reinforcement_learning/`
   These folders contain the actual instructional notebooks, figures, and small supporting datasets/models.

3. The book is divided into three major educational subsystems:
   - Supervised learning: linear/logistic regression, SVMs, trees, ensembles, metrics, feature engineering, validation.
   - Neural networks: tensor basics, training, image handling, data augmentation, CNNs, transfer learning.
   - Reinforcement learning: Q-learning, policy gradients, DQN variants, and related experiments.
   This chapter structure is what should appear as the main content boundary in any architecture diagram.

4. The notebook layer is the core computation/teaching layer. Files such as `*.ipynb` are both narrative and executable examples. They likely mix explanatory text, plots, and code using Python libraries such as scikit-learn and PyTorch, as noted in the README. There is no separate service layer between the notebooks and the published site.

5. Data and experiment artifacts are stored close to the notebooks that use them:
   - `contents/neural_networks/data/food5k/` contains training/validation image data for image classification examples.
   - `contents/reinforcement_learning/metrics/` contains CSV logs such as rewards, loss, epsilon, and episode length.
   - `contents/reinforcement_learning/modelos/` contains serialized models in `.pkl` form.
   - `contents/reinforcement_learning/dqn_breakout.zip` appears to be an experiment asset or environment bundle.
   These are important because the book is not purely narrative; it includes reproducible ML experiments with local assets.

6. The rendering and publishing boundary is controlled by Jupyter Book configuration at the repository root:
   - `_config.yml` defines site/book behavior.
   - `_toc.yml` defines navigation and chapter order.
   - `_static/custom.css` customizes presentation/styling.
   - `_static/` holds additional site-level assets.
   This is the configuration layer that turns notebook content into a navigable book.

7. The build flow is:
   - author/edit notebooks and assets in `contents/`
   - run notebooks to produce outputs, figures, and tables
   - build the book with `jupyter-book build .`
   - publish the generated HTML with `ghp-import`
   The output is a static site, so runtime behavior after publishing is limited to browser-side rendering of HTML/CSS/JS.

8. The repository boundary between source and generated output is important. Source files are the notebooks and config; generated content is produced into `_build/html/` during compilation and is not the hand-authored source. In an architecture diagram, treat `_build/` as a derived artifact, not a subsystem.

9. The README and README-described workflow indicate the project is maintained as a continuously evolving educational resource, with GitHub Pages as the deployment target. The publishing chain therefore depends on GitHub as hosting infrastructure, but the book itself does not depend on a server-side application runtime.

10. The repo also contains top-level documentation metadata:
    - `LICENSE`
    - `.gitignore`
    - `_toc.yml`
    - `_config.yml`
    These support the content pipeline rather than the machine learning examples themselves. They form the minimal platform layer around the notebook chapters.

11. There is a clear separation between pedagogical content and supporting assets:
    - notebooks explain concepts and contain executable demos
    - data/images/models/metrics support those demos
    - Jupyter Book turns both into a static publication
    This separation is the main design pattern of the repository.

12. If you draw the architecture, the simplest accurate shape is: authored notebook chapters and asset folders on one side, Jupyter Book configuration and build tooling in the middle, and a static GitHub Pages site on the other side. The ML libraries are embedded inside the notebook execution layer rather than exposed as standalone components.

Main entry points: [`contents/reinforcement_learning`](https://github.com/phuijse/machinelearningbook/tree/main/contents/reinforcement_learning) (Reinforcement Learning), [`contents/neural_networks`](https://github.com/phuijse/machinelearningbook/tree/main/contents/neural_networks) (Neural Networks), [`contents/supervised_learning`](https://github.com/phuijse/machinelearningbook/tree/main/contents/supervised_learning) (Supervised Learning), [`_config.yml`](https://github.com/phuijse/machinelearningbook/blob/main/_config.yml) (Book config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_content["Content"]
  node_supervised_learning["Supervised Learning<br/>chapter"]
  node_supervised_notebooks["Model notebooks<br/>notebook set"]
  node_neural_networks["Neural Networks<br/>chapter"]
  node_nn_notebooks["Vision notebooks<br/>notebook set"]
  node_nn_food5k[("Food5k data<br/>image dataset")]
  node_reinforcement_learning["Reinforcement Learning<br/>chapter"]
  node_rl_notebooks["RL notebooks<br/>notebook set"]
  node_rl_metrics[("Metrics logs<br/>experiment data")]
  node_rl_models[("Saved models<br/>serialized models")]
end

subgraph group_platform["Platform"]
  node_book_config["Book config<br/>[_config.yml]"]
  node_book_toc["Book TOC<br/>navigation config<br/>[_toc.yml]"]
  node_site_css["Custom CSS<br/>presentation css<br/>[custom.css]"]
  node_static_assets["Static assets<br/>site assets"]
  node_build_book{{"Build book<br/>jupyter-book build"}}
  node_ghp_publish{{"Publish site<br/>ghp-import deploy"}}
end

subgraph group_output["Published output"]
  node_generated_site["HTML build<br/>derived site"]
  node_github_pages["GitHub Pages<br/>hosting"]
  node_reader_site["Browser site<br/>static web app"]
end

node_supervised_learning -->|"contains"| node_supervised_notebooks
node_neural_networks -->|"contains"| node_nn_notebooks
node_neural_networks -->|"uses"| node_nn_food5k
node_reinforcement_learning -->|"contains"| node_rl_notebooks
node_reinforcement_learning -->|"logs"| node_rl_metrics
node_reinforcement_learning -->|"persists"| node_rl_models
node_book_config -->|"configures"| node_build_book
node_book_toc -->|"orders"| node_build_book
node_site_css -->|"styles"| node_build_book
node_static_assets -->|"bundles"| node_build_book
node_supervised_learning -->|"feeds"| node_build_book
node_neural_networks -->|"feeds"| node_build_book
node_reinforcement_learning -->|"feeds"| node_build_book
node_build_book -->|"produces"| node_generated_site
node_generated_site -->|"deploys"| node_ghp_publish
node_ghp_publish -->|"hosts"| node_github_pages
node_github_pages -->|"renders"| node_reader_site

click node_supervised_learning "https://github.com/phuijse/machinelearningbook/tree/main/contents/supervised_learning"
click node_neural_networks "https://github.com/phuijse/machinelearningbook/tree/main/contents/neural_networks"
click node_nn_food5k "https://github.com/phuijse/machinelearningbook/tree/main/contents/neural_networks/data/food5k"
click node_reinforcement_learning "https://github.com/phuijse/machinelearningbook/tree/main/contents/reinforcement_learning"
click node_rl_metrics "https://github.com/phuijse/machinelearningbook/tree/main/contents/reinforcement_learning/metrics"
click node_rl_models "https://github.com/phuijse/machinelearningbook/tree/main/contents/reinforcement_learning/modelos"
click node_book_config "https://github.com/phuijse/machinelearningbook/blob/main/_config.yml"
click node_book_toc "https://github.com/phuijse/machinelearningbook/blob/main/_toc.yml"
click node_site_css "https://github.com/phuijse/machinelearningbook/blob/main/_static/custom.css"
click node_static_assets "https://github.com/phuijse/machinelearningbook/tree/main/_static"

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_supervised_learning,node_supervised_notebooks,node_neural_networks,node_nn_notebooks,node_nn_food5k,node_reinforcement_learning,node_rl_notebooks,node_rl_metrics,node_rl_models toneBlue
class node_book_config,node_book_toc,node_site_css,node_static_assets,node_build_book,node_ghp_publish toneAmber
class node_generated_site,node_github_pages,node_reader_site toneMint
```

## Components

### Content

Authored notebook chapters and their local experiment assets.

- [Supervised Learning](https://github.com/phuijse/machinelearningbook/tree/main/contents/supervised_learning): chapter · Notebook chapter covering linear and logistic models, SVMs, trees, ensembles, metrics, features, and validation. · `contents/supervised_learning`
- **Model notebooks**: notebook set · Executable teaching notebooks for supervised learning workflows.
- [Neural Networks](https://github.com/phuijse/machinelearningbook/tree/main/contents/neural_networks): chapter · Notebook chapter for tensors, training, image handling, augmentation, CNNs, and transfer learning. · `contents/neural_networks`
- **Vision notebooks**: notebook set · Executable notebooks for neural network concepts and experiments.
- [Food5k data](https://github.com/phuijse/machinelearningbook/tree/main/contents/neural_networks/data/food5k): image dataset · Training and validation images used by the vision examples. · `contents/neural_networks/data/food5k`
- [Reinforcement Learning](https://github.com/phuijse/machinelearningbook/tree/main/contents/reinforcement_learning): chapter · Notebook chapter covering Q-learning, policy gradients, DQN variants, and experiments. · `contents/reinforcement_learning`
- **RL notebooks**: notebook set · Executable notebooks for reinforcement learning methods and demos.
- [Metrics logs](https://github.com/phuijse/machinelearningbook/tree/main/contents/reinforcement_learning/metrics): experiment data · CSV traces for rewards, loss, epsilon, and episode length. · `contents/reinforcement_learning/metrics`
- [Saved models](https://github.com/phuijse/machinelearningbook/tree/main/contents/reinforcement_learning/modelos): serialized models · Persisted policy/value artifacts used by reinforcement learning experiments. · `contents/reinforcement_learning/modelos`

### Platform

Jupyter Book configuration, styling, and publishing workflow.

- [Book config](https://github.com/phuijse/machinelearningbook/blob/main/_config.yml): jupyter-book config · Site and book behavior settings for the generated textbook. · `_config.yml`
- [Book TOC](https://github.com/phuijse/machinelearningbook/blob/main/_toc.yml): navigation config · Chapter order and navigation structure for the book. · `_toc.yml`
- [Custom CSS](https://github.com/phuijse/machinelearningbook/blob/main/_static/custom.css): presentation css · Repository-specific styling for the rendered book. · `_static/custom.css`
- [Static assets](https://github.com/phuijse/machinelearningbook/tree/main/_static): site assets · Additional site-level files bundled with the book build. · `_static`
- **Build book**: jupyter-book build · Transforms authored notebooks and configuration into static HTML.
- **Publish site**: ghp-import deploy · Publishes the generated HTML to GitHub Pages.

### Published output

Derived static site and GitHub Pages deployment target.

- **HTML build**: derived site · Compiled static output produced during the book build.
- **GitHub Pages**: hosting · Static hosting target for the published textbook.
- **Browser site**: static web app · Final browser-facing textbook experience served as HTML/CSS/JS.

## Connections

- Supervised Learning → Model notebooks: contains · Chapter content is implemented as executable notebooks.
- Neural Networks → Vision notebooks: contains · Notebook-based instruction and experiments live in the chapter.
- Neural Networks → Food5k data: uses · Vision notebooks consume the local image dataset.
- Reinforcement Learning → RL notebooks: contains · Chapter notebooks combine exposition with runnable RL code.
- Reinforcement Learning → Metrics logs: logs · Experiments write training traces and evaluation metrics.
- Reinforcement Learning → Saved models: persists · RL workflows store trained artifacts for reuse.
- Book config → Build book: configures · Site settings drive the book build.
- Book TOC → Build book: orders · Navigation structure shapes the generated book hierarchy.
- Custom CSS → Build book: styles · Custom presentation is bundled into the build.
- Static assets → Build book: bundles · Extra static files are included in the site output.
- Supervised Learning → Build book: feeds · Authored content is compiled into the static book.
- Neural Networks → Build book: feeds · Authored content is compiled into the static book.
- Reinforcement Learning → Build book: feeds · Authored content is compiled into the static book.
- Build book → HTML build: produces · The build emits the HTML site under _build/html.
- HTML build → Publish site: deploys · Generated HTML is published to the hosting target.
- Publish site → GitHub Pages: hosts · GitHub Pages serves the published book.
- GitHub Pages → Browser site: renders · Readers interact with the static site in the browser.
