# cambiahealth/nbstripout architecture

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

- Interactive diagram: https://gitdiagram.com/cambiahealth/nbstripout
- Repository: https://github.com/cambiahealth/nbstripout

## Overview

nbstripout is a command-line utility and Git filter that cleans notebook content before it is committed, while leaving the on-disk notebook unchanged when used as a filter. The principal workflow reads a Jupyter notebook, applies configurable cleanup, and writes cleaned output or reports whether changes would occur. Zeppelin notebooks have a separate output-stripping path. The CLI also installs, removes, and reports Git filter configuration. The excerpts show the CLI-to-cleanup call and cleanup behavior; other relationships below are documented in the README, so unsampled implementation details are not inferred.

Main entry points: [`nbstripout/_nbstripout.py`](https://github.com/cambiahealth/nbstripout/blob/main/nbstripout/_nbstripout.py) (Command handling), [`nbstripout/_utils.py`](https://github.com/cambiahealth/nbstripout/blob/main/nbstripout/_utils.py) (Jupyter cleanup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and Git setup"]
  node_cli["Command handling<br/>[_nbstripout.py]"]
  node_git_setup["Filter setup<br/>[_nbstripout.py]"]
end

subgraph group_cleaning["Notebook cleaning"]
  node_jupyter["Jupyter cleanup<br/>[_utils.py]"]
  node_zeppelin["Zeppelin cleanup<br/>[_utils.py]"]
end

node_user(("User or Git"))
node_notebook["Notebook data"]
node_git[("Git configuration")]
node_nbformat["nbformat parser"]

node_user -->|"runs command"| node_cli
node_cli -->|"reads notebook"| node_nbformat
node_cli -->|"calls cleanup"| node_jupyter
node_cli -->|"dispatches mode"| node_zeppelin
node_jupyter -->|"cleans content"| node_notebook
node_zeppelin -->|"clears results"| node_notebook
node_cli -->|"writes output"| node_notebook
node_user -->|"installs filter"| node_git_setup
node_git_setup -->|"configures filter"| node_git
node_git -->|"runs clean filter"| node_cli

click node_cli "https://github.com/cambiahealth/nbstripout/blob/main/nbstripout/_nbstripout.py"
click node_git_setup "https://github.com/cambiahealth/nbstripout/blob/main/nbstripout/_nbstripout.py"
click node_jupyter "https://github.com/cambiahealth/nbstripout/blob/main/nbstripout/_utils.py"
click node_zeppelin "https://github.com/cambiahealth/nbstripout/blob/main/nbstripout/_utils.py"

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_cli,node_git_setup,node_user toneBlue
class node_jupyter,node_zeppelin,node_git toneAmber
class node_notebook,node_nbformat toneIndigo
```

## Components

### CLI and Git setup

- [Command handling](https://github.com/cambiahealth/nbstripout/blob/main/nbstripout/_nbstripout.py): `nbstripout/_nbstripout.py`
- [Filter setup](https://github.com/cambiahealth/nbstripout/blob/main/nbstripout/_nbstripout.py): `nbstripout/_nbstripout.py`

### Notebook cleaning

- [Jupyter cleanup](https://github.com/cambiahealth/nbstripout/blob/main/nbstripout/_utils.py): `nbstripout/_utils.py`
- [Zeppelin cleanup](https://github.com/cambiahealth/nbstripout/blob/main/nbstripout/_utils.py): `nbstripout/_utils.py`

### Other components

- **User or Git**
- **Notebook data**
- **Git configuration**
- **nbformat parser**

## Connections

- User or Git → Command handling: runs command (evidence: `README.md`)
- Command handling → nbformat parser: reads notebook (evidence: `nbstripout/_nbstripout.py`)
- Command handling → Jupyter cleanup: calls cleanup (evidence: `nbstripout/_nbstripout.py`)
- Command handling → Zeppelin cleanup: dispatches mode (evidence: `README.md`)
- Jupyter cleanup → Notebook data: cleans content (evidence: `nbstripout/_utils.py`)
- Zeppelin cleanup → Notebook data: clears results (evidence: `nbstripout/_utils.py`)
- Command handling → Notebook data: writes output (evidence: `README.md`)
- User or Git → Filter setup: installs filter (evidence: `README.md`)
- Filter setup → Git configuration: configures filter (evidence: `README.md`)
- Git configuration → Command handling: runs clean filter (evidence: `README.md`)
