# abhogal-lab/willisworks architecture

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

- Interactive diagram: https://gitdiagram.com/abhogal-lab/willisworks
- Repository: https://github.com/abhogal-lab/willisworks

## Overview

#### Purpose and entry points
WillisWorks is a browser-based, interactive cerebral-hemodynamics teaching simulator. It is a standalone static application: users download and open `WillisWorks.html`, or access the hosted documentation/application through `docs/index.html`. The long-form model manual and operational specification are in `README.md`.

#### Delivery model and runtime boundary
The repository has no visible backend, package manifest, or service integration. The application executes locally in a web browser, requires no patient data, and persists comparison state in browser memory. Primary runtime artifact: `WillisWorks.html`; hosted/static entry: `docs/index.html`. Images and visual identity are served from `img/`.

#### Core hemodynamic network
The model is a zero-dimensional, lumped resistance network with three arterial sources (left ICA, right ICA, basilar), proximal arterial nodes, and eight distal beds: bilateral ACA, MCA, PCA, and vertebrobasilar territories. It solves nodal pressure and source inflow, then derives territorial flow from distal arterial versus effective outflow pressure. The implemented simulator is contained in `WillisWorks.html`; topology explanation is documented in `README.md`.

#### Active regulation and source constraints
After a pressure-network solve, each territory iteratively adjusts arteriolar resistance toward a target flow determined by CPP, metabolic demand, and PaCO₂. Resistance is bounded by vasodilatory reserve; finite ICA/basilar source reserve can reduce effective source pressure under increased demand, enabling modeled redistribution and steal. This is central application logic in `WillisWorks.html`, with equations and calibration rationale in `README.md`.

#### Structural disease and collateral routing
Lesions add steeply increasing resistance for ICA, M1, A1, P1, or basilar disease. Circle of Willis pathways (ACom/PCom), recruited leptomeningeal links, and EC–IC bypass are separate conductance/support mechanisms, allowing donor-recipient pressure redistribution to be inspected independently. These mechanisms are implemented by the interactive app in `WillisWorks.html` and specified in `README.md`.

#### Oxygen, metabolism, and interpretation
A downstream oxygen layer derives CaO₂, oxygen delivery, OEF, and delivered CMRO₂ from solved CBF. It supports classic OEF-ceiling and flow–diffusion interpretations, with CTH, shunt, neural activation, NVC, and endothelial modifiers. Results are summarized as continuous territory metrics plus educational staging labels; these are explicitly not diagnostic outputs. Primary paths: `WillisWorks.html`, `README.md`.

#### User interaction, views, and simulations
Controls alter a shared model state across teaching and advanced modes. Outputs include cortical map visualization, Model/Staging/Dynamics panels, A/B state comparison, and PNG/CSV/JSON export. Time-resolved simulations reuse the static solver with prescribed trajectories for Suzuki progression, pressure/autoregulation, steno-occlusive progression, and oxygen delivery. The app’s single interactive surface is `WillisWorks.html`; static documentation/navigation is available at `docs/index.html`.

#### Assets and limitations
Visual assets are stored under `img/`, including the logo and explanatory figures referenced by the manual. The model intentionally omits patient-specific geometry, pulse-wave propagation, full venous/capillary networks, validated stenosis-to-resistance mapping, and clinical decision support. License: GPL-3.0-or-later (`LICENSE`).

Main entry points: [`WillisWorks.html`](https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html) (Arterial resistance network), [`docs/index.html`](https://github.com/abhogal-lab/willisworks/blob/main/docs/index.html) (Hosted entry), [`README.md`](https://github.com/abhogal-lab/willisworks/blob/main/README.md) (Model manual), [`img`](https://github.com/abhogal-lab/willisworks/tree/main/img) (Visual assets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_delivery["Static delivery"]
  node_browser(("Web browser<br/>runtime"))
  node_app["WillisWorks app<br/>static application<br/>[WillisWorks.html]"]
  node_docs["Hosted entry<br/>static documentation<br/>[index.html]"]
  node_manual["Model manual<br/>specification<br/>[README.md]"]
  node_assets["Visual assets<br/>static assets"]
end

subgraph group_solver["Hemodynamic model"]
  node_network{{"Arterial resistance network<br/>0D pressure solver<br/>[WillisWorks.html]"}}
  node_sources["ICA &amp; basilar sources<br/>source constraints<br/>[WillisWorks.html]"]
  node_territories["Eight distal territories<br/>territorial flow<br/>[WillisWorks.html]"]
  node_autoregulation{{"Active autoregulation<br/>iterative resistance control<br/>[WillisWorks.html]"}}
  node_collaterals["Collateral &amp; bypass routing<br/>conductance mechanisms<br/>[WillisWorks.html]"]
  node_lesions["Structural lesions<br/>disease resistance<br/>[WillisWorks.html]"]
  node_oxygen["Oxygen &amp; metabolism<br/>downstream physiology<br/>[WillisWorks.html]"]
end

subgraph group_experience["Teaching experience"]
  node_shared_state[("Shared model state<br/>simulation state<br/>[WillisWorks.html]")]
  node_controls["Teaching &amp; advanced controls<br/>interaction layer<br/>[WillisWorks.html]"]
  node_interpretation["Educational staging<br/>interpretation layer<br/>[WillisWorks.html]"]
  node_views["Map &amp; analysis panels<br/>visualization<br/>[WillisWorks.html]"]
  node_dynamics["Time-resolved simulations<br/>trajectory runner<br/>[WillisWorks.html]"]
  node_exports["PNG / CSV / JSON export<br/>output<br/>[WillisWorks.html]"]
end

node_docs -->|"hosts entry"| node_app
node_browser -->|"executes"| node_app
node_app -->|"uses"| node_assets
node_manual -.->|"specifies"| node_app
node_controls -->|"updates"| node_shared_state
node_shared_state -->|"configures"| node_network
node_sources -->|"feeds"| node_network
node_lesions -->|"adds resistance"| node_network
node_collaterals -->|"adds pathways"| node_network
node_network -->|"solves pressures"| node_territories
node_territories -->|"provides flow"| node_autoregulation
node_autoregulation -->|"iterates resistance"| node_network
node_territories -->|"provides CBF"| node_oxygen
node_oxygen -->|"supplies metrics"| node_interpretation
node_territories -->|"supplies flow state"| node_views
node_interpretation -->|"supplies stages"| node_views
node_shared_state -->|"seeds scenarios"| node_dynamics
node_dynamics -->|"repeats solver"| node_network
node_views -->|"exports results"| node_exports
node_shared_state -->|"exports A/B state"| node_exports

click node_app "https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html"
click node_docs "https://github.com/abhogal-lab/willisworks/blob/main/docs/index.html"
click node_manual "https://github.com/abhogal-lab/willisworks/blob/main/README.md"
click node_assets "https://github.com/abhogal-lab/willisworks/tree/main/img"
click node_shared_state "https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html"
click node_controls "https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html"
click node_network "https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html"
click node_sources "https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html"
click node_territories "https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html"
click node_autoregulation "https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html"
click node_collaterals "https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html"
click node_lesions "https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html"
click node_oxygen "https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html"
click node_interpretation "https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html"
click node_views "https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html"
click node_dynamics "https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html"
click node_exports "https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html"

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_browser,node_app,node_docs,node_manual,node_assets toneBlue
class node_network,node_sources,node_territories,node_autoregulation,node_collaterals,node_lesions,node_oxygen toneAmber
class node_shared_state,node_controls,node_interpretation,node_views,node_dynamics,node_exports toneMint
```

## Components

### Static delivery

Standalone files served or opened directly in a browser.

- **Web browser**: runtime · Executes the simulator locally with in-memory comparison state.
- [WillisWorks app](https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html): static application · Primary interactive simulator and implementation. · `WillisWorks.html`
- [Hosted entry](https://github.com/abhogal-lab/willisworks/blob/main/docs/index.html): static documentation · Hosted documentation and application entry point. · `docs/index.html`
- [Model manual](https://github.com/abhogal-lab/willisworks/blob/main/README.md): specification · Documents equations, topology, calibration, and limitations. · `README.md`
- [Visual assets](https://github.com/abhogal-lab/willisworks/tree/main/img): static assets · Logo and explanatory figures. · `img`

### Hemodynamic model

Interactive lumped-network simulation inside the HTML application.

- [Arterial resistance network](https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html): 0D pressure solver · Solves nodal pressure and source inflow across three sources and distal beds. · `WillisWorks.html`
- [ICA & basilar sources](https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html): source constraints · Finite reserve reduces effective source pressure under demand. · `WillisWorks.html`
- [Eight distal territories](https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html): territorial flow · ACA, MCA, PCA, and vertebrobasilar beds derive flow from pressure gradients. · `WillisWorks.html`
- [Active autoregulation](https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html): iterative resistance control · Adjusts bounded arteriolar resistance toward CPP, metabolic, and PaCO₂ targets. · `WillisWorks.html`
- [Collateral & bypass routing](https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html): conductance mechanisms · ACom/PCom, leptomeningeal, and EC–IC support redistribute pressure. · `WillisWorks.html`
- [Structural lesions](https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html): disease resistance · ICA, M1, A1, P1, and basilar disease add steep resistance. · `WillisWorks.html`
- [Oxygen & metabolism](https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html): downstream physiology · Derives CaO₂, delivery, OEF, and delivered CMRO₂ from CBF. · `WillisWorks.html`

### Teaching experience

Controls, interpretation, visualization, and export share one model state.

- [Shared model state](https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html): simulation state · Control settings and A/B comparison state held in browser memory. · `WillisWorks.html`
- [Teaching & advanced controls](https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html): interaction layer · `WillisWorks.html`
- [Educational staging](https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html): interpretation layer · Continuous metrics are summarized as non-diagnostic teaching labels. · `WillisWorks.html`
- [Map & analysis panels](https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html): visualization · Cortical map plus Model, Staging, and Dynamics panels. · `WillisWorks.html`
- [Time-resolved simulations](https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html): trajectory runner · Reuses the static solver for prescribed progression and regulation scenarios. · `WillisWorks.html`
- [PNG / CSV / JSON export](https://github.com/abhogal-lab/willisworks/blob/main/WillisWorks.html): output · `WillisWorks.html`

## Connections

- Hosted entry → WillisWorks app: hosts entry
- Web browser → WillisWorks app: executes
- WillisWorks app → Visual assets: uses
- Model manual → WillisWorks app: specifies
- Teaching & advanced controls → Shared model state: updates
- Shared model state → Arterial resistance network: configures
- ICA & basilar sources → Arterial resistance network: feeds
- Structural lesions → Arterial resistance network: adds resistance
- Collateral & bypass routing → Arterial resistance network: adds pathways
- Arterial resistance network → Eight distal territories: solves pressures
- Eight distal territories → Active autoregulation: provides flow
- Active autoregulation → Arterial resistance network: iterates resistance
- Eight distal territories → Oxygen & metabolism: provides CBF
- Oxygen & metabolism → Educational staging: supplies metrics
- Eight distal territories → Map & analysis panels: supplies flow state
- Educational staging → Map & analysis panels: supplies stages
- Shared model state → Time-resolved simulations: seeds scenarios
- Time-resolved simulations → Arterial resistance network: repeats solver
- Map & analysis panels → PNG / CSV / JSON export: exports results
- Shared model state → PNG / CSV / JSON export: exports A/B state
