# johnpaulpatigas/pfas-digital-playground architecture

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

- Interactive diagram: https://gitdiagram.com/johnpaulpatigas/pfas-digital-playground
- Repository: https://github.com/johnpaulpatigas/pfas-digital-playground

## Overview

PFAS toxicokinetic modeling playground for exploring exposure and population risk among Filipino women. Users configure cohort and exposure parameters, choose a PFAS compound and sampling method, then run simulations and inspect risk summaries, sensitivity, charts, and exports. The app also provides a method-comparison view and scientific/reference pages. The principal flow is evidenced by the routed pages, PlaygroundPage, and simulation modules; chart and analysis relationships rely on the SOURCE INDEX where full source was not excerpted. The worker implementation is included, but its dispatch path is not asserted.

Main entry points: [`src/pages/PlaygroundPage.tsx`](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/pages/PlaygroundPage.tsx) (Playground page), [`src/simulation/runSimulationAsync.ts`](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/runSimulationAsync.ts) (Async runner), [`src/App.tsx`](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/App.tsx) (App routes), [`src/simulation/toxicokinetics.ts`](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/toxicokinetics.ts) (Toxicokinetics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application and pages"]
  node_router["App routes<br/>[App.tsx]"]
  node_home["Home page<br/>[HomePage.tsx]"]
  node_playground["Playground page<br/>[PlaygroundPage.tsx]"]
  node_compare["Method comparison<br/>[ComparePage.tsx]"]
  node_docs["Documentation<br/>[DocsPage.tsx]"]
  node_guide["Scientific guide"]
end

subgraph group_inputs["Scenario and controls"]
  node_presets["Cohort presets<br/>[presets.ts]"]
  node_parameters["Parameter controls"]
  node_distribution["Distribution selector"]
  node_parameter_guide["Parameter guide"]
  node_state["Simulation state"]
end

subgraph group_simulation["Simulation engine"]
  node_compounds["PFAS profiles<br/>[pfasCompounds.ts]"]
  node_async_runner["Async runner"]
  node_worker["Simulation worker"]
  node_mc["Monte Carlo<br/>[monteCarlo.ts]"]
  node_lhs["Latin hypercube<br/>[latinHypercube.ts]"]
  node_hybrid["Hybrid sampler<br/>[monteCarloLhs.ts]"]
  node_distributions["Distribution sampling<br/>[distributions.ts]"]
  node_toxicokinetics["Toxicokinetics<br/>[toxicokinetics.ts]"]
end

subgraph group_analysis["Results and analysis"]
  node_statistics["Statistics<br/>[statistics.ts]"]
  node_summary["Summary panel<br/>[SummaryPanel.tsx]"]
  node_exceedance["Exceedance analysis"]
  node_charts["Simulation charts"]
  node_export["Data export<br/>[exportUtils.ts]"]
  node_console["Execution console"]
end

node_user(("User"))

node_user -->|"opens app"| node_router
node_router -->|"routes to"| node_home
node_router -->|"routes to"| node_playground
node_router -->|"routes to"| node_compare
node_router -->|"routes to"| node_docs
node_router -->|"routes to"| node_guide
node_user -->|"configures and runs"| node_playground
node_playground -->|"renders"| node_parameters
node_playground -->|"renders"| node_summary
node_playground -->|"renders"| node_exceedance
node_playground -->|"renders"| node_charts
node_playground -->|"uses"| node_export
node_playground -->|"renders"| node_console
node_parameters -->|"updates"| node_state
node_parameters -->|"renders"| node_distribution
node_parameters -->|"loads cohort presets"| node_presets
node_parameter_guide -->|"uses cohort presets"| node_presets
node_parameter_guide -->|"reads state"| node_state
node_playground -->|"executes simulation"| node_async_runner
node_async_runner -->|"dispatches by method"| node_mc
node_async_runner -->|"dispatches by method"| node_lhs
node_async_runner -->|"dispatches by method"| node_hybrid
node_mc -->|"samples from"| node_distributions
node_lhs -->|"samples from"| node_distributions
node_hybrid -->|"uses"| node_mc
node_hybrid -->|"uses"| node_lhs
node_mc -->|"calculates outcomes"| node_toxicokinetics
node_lhs -->|"calculates outcomes"| node_toxicokinetics
node_async_runner -->|"calculates summaries"| node_statistics
node_async_runner -->|"calculates compound summaries"| node_toxicokinetics
node_toxicokinetics -->|"uses profiles"| node_compounds
node_async_runner -->|"returns results to page"| node_state
node_summary -->|"reads results"| node_state
node_charts -->|"reads results"| node_state
node_exceedance -->|"uses risk calculations"| node_toxicokinetics
node_compare -->|"runs comparisons"| node_async_runner
node_compare -->|"uses statistics"| node_statistics
node_worker -->|"dispatches sampling"| node_mc
node_worker -->|"dispatches sampling"| node_lhs
node_worker -->|"dispatches sampling"| node_hybrid
node_worker -->|"calculates summaries"| node_statistics
node_worker -->|"calculates compound summaries"| node_toxicokinetics

click node_router "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/App.tsx"
click node_home "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/pages/HomePage.tsx"
click node_playground "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/pages/PlaygroundPage.tsx"
click node_compare "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/pages/ComparePage.tsx"
click node_docs "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/pages/DocsPage.tsx"
click node_guide "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/pages/ScientificGuidePage.tsx"
click node_presets "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/features/scenarios/presets.ts"
click node_parameters "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/features/playground/ParameterSidebar.tsx"
click node_distribution "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/features/playground/DistributionSelector.tsx"
click node_parameter_guide "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/features/playground/ParameterGuideModal.tsx"
click node_state "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/stores/useSimulationStore.ts"
click node_compounds "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/pfasCompounds.ts"
click node_async_runner "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/runSimulationAsync.ts"
click node_worker "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/workers/simulationWorker.ts"
click node_mc "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/monteCarlo.ts"
click node_lhs "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/latinHypercube.ts"
click node_hybrid "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/monteCarloLhs.ts"
click node_distributions "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/distributions.ts"
click node_toxicokinetics "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/toxicokinetics.ts"
click node_statistics "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/statistics.ts"
click node_summary "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/features/statistics/SummaryPanel.tsx"
click node_exceedance "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/features/playground/ExceedanceAnalyzer.tsx"
click node_charts "https://github.com/johnpaulpatigas/pfas-digital-playground/tree/main/src/features/charts"
click node_export "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/utils/exportUtils.ts"
click node_console "https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/features/playground/SimulationConsole.tsx"

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_router,node_home,node_playground,node_compare,node_docs,node_guide,node_user toneBlue
class node_presets,node_parameters,node_distribution,node_parameter_guide,node_state toneAmber
class node_compounds,node_async_runner,node_worker,node_mc,node_lhs,node_hybrid,node_distributions,node_toxicokinetics toneMint
class node_statistics,node_summary,node_exceedance,node_charts,node_export,node_console toneRose
```

## Components

### Application and pages

- [App routes](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/App.tsx): `src/App.tsx`
- [Home page](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/pages/HomePage.tsx): `src/pages/HomePage.tsx`
- [Playground page](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/pages/PlaygroundPage.tsx): `src/pages/PlaygroundPage.tsx`
- [Method comparison](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/pages/ComparePage.tsx): `src/pages/ComparePage.tsx`
- [Documentation](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/pages/DocsPage.tsx): `src/pages/DocsPage.tsx`
- [Scientific guide](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/pages/ScientificGuidePage.tsx): `src/pages/ScientificGuidePage.tsx`

### Scenario and controls

- [Cohort presets](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/features/scenarios/presets.ts): `src/features/scenarios/presets.ts`
- [Parameter controls](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/features/playground/ParameterSidebar.tsx): `src/features/playground/ParameterSidebar.tsx`
- [Distribution selector](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/features/playground/DistributionSelector.tsx): `src/features/playground/DistributionSelector.tsx`
- [Parameter guide](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/features/playground/ParameterGuideModal.tsx): `src/features/playground/ParameterGuideModal.tsx`
- [Simulation state](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/stores/useSimulationStore.ts): `src/stores/useSimulationStore.ts`

### Simulation engine

- [PFAS profiles](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/pfasCompounds.ts): `src/simulation/pfasCompounds.ts`
- [Async runner](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/runSimulationAsync.ts): `src/simulation/runSimulationAsync.ts`
- [Simulation worker](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/workers/simulationWorker.ts): `src/simulation/workers/simulationWorker.ts`
- [Monte Carlo](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/monteCarlo.ts): `src/simulation/monteCarlo.ts`
- [Latin hypercube](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/latinHypercube.ts): `src/simulation/latinHypercube.ts`
- [Hybrid sampler](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/monteCarloLhs.ts): `src/simulation/monteCarloLhs.ts`
- [Distribution sampling](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/distributions.ts): `src/simulation/distributions.ts`
- [Toxicokinetics](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/toxicokinetics.ts): `src/simulation/toxicokinetics.ts`

### Results and analysis

- [Statistics](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/simulation/statistics.ts): `src/simulation/statistics.ts`
- [Summary panel](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/features/statistics/SummaryPanel.tsx): `src/features/statistics/SummaryPanel.tsx`
- [Exceedance analysis](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/features/playground/ExceedanceAnalyzer.tsx): `src/features/playground/ExceedanceAnalyzer.tsx`
- [Simulation charts](https://github.com/johnpaulpatigas/pfas-digital-playground/tree/main/src/features/charts): `src/features/charts`
- [Data export](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/utils/exportUtils.ts): `src/utils/exportUtils.ts`
- [Execution console](https://github.com/johnpaulpatigas/pfas-digital-playground/blob/main/src/features/playground/SimulationConsole.tsx): `src/features/playground/SimulationConsole.tsx`

### Other components

- **User**

## Connections

- User → App routes: opens app (evidence: `src/App.tsx`)
- App routes → Home page: routes to (evidence: `src/App.tsx`)
- App routes → Playground page: routes to (evidence: `src/App.tsx`)
- App routes → Method comparison: routes to (evidence: `src/App.tsx`)
- App routes → Documentation: routes to (evidence: `src/App.tsx`)
- App routes → Scientific guide: routes to (evidence: `src/App.tsx`)
- User → Playground page: configures and runs (evidence: `src/pages/PlaygroundPage.tsx`)
- Playground page → Parameter controls: renders (evidence: `src/pages/PlaygroundPage.tsx`)
- Playground page → Summary panel: renders (evidence: `src/pages/PlaygroundPage.tsx`)
- Playground page → Exceedance analysis: renders (evidence: `src/pages/PlaygroundPage.tsx`)
- Playground page → Simulation charts: renders (evidence: `src/pages/PlaygroundPage.tsx`)
- Playground page → Data export: uses (evidence: `src/pages/PlaygroundPage.tsx`)
- Playground page → Execution console: renders (evidence: `src/pages/PlaygroundPage.tsx`)
- Parameter controls → Simulation state: updates (evidence: `src/features/playground/ParameterSidebar.tsx`)
- Parameter controls → Distribution selector: renders (evidence: `src/features/playground/ParameterSidebar.tsx`)
- Parameter controls → Cohort presets: loads cohort presets (evidence: `src/features/playground/ParameterSidebar.tsx`)
- Parameter guide → Cohort presets: uses cohort presets (evidence: `src/features/playground/ParameterGuideModal.tsx`)
- Parameter guide → Simulation state: reads state (evidence: `src/features/playground/ParameterGuideModal.tsx`)
- Playground page → Async runner: executes simulation (evidence: `src/pages/PlaygroundPage.tsx`)
- Async runner → Monte Carlo: dispatches by method (evidence: `src/simulation/runSimulationAsync.ts`)
- Async runner → Latin hypercube: dispatches by method (evidence: `src/simulation/runSimulationAsync.ts`)
- Async runner → Hybrid sampler: dispatches by method (evidence: `src/simulation/runSimulationAsync.ts`)
- Monte Carlo → Distribution sampling: samples from (evidence: `src/simulation/monteCarlo.ts`)
- Latin hypercube → Distribution sampling: samples from (evidence: `src/simulation/latinHypercube.ts`)
- Hybrid sampler → Monte Carlo: uses (evidence: `src/simulation/monteCarloLhs.ts`)
- Hybrid sampler → Latin hypercube: uses (evidence: `src/simulation/monteCarloLhs.ts`)
- Monte Carlo → Toxicokinetics: calculates outcomes (evidence: `src/simulation/monteCarlo.ts`)
- Latin hypercube → Toxicokinetics: calculates outcomes (evidence: `src/simulation/latinHypercube.ts`)
- Async runner → Statistics: calculates summaries (evidence: `src/simulation/runSimulationAsync.ts`)
- Async runner → Toxicokinetics: calculates compound summaries (evidence: `src/simulation/runSimulationAsync.ts`)
- Toxicokinetics → PFAS profiles: uses profiles (evidence: `src/simulation/toxicokinetics.ts`)
- Async runner → Simulation state: returns results to page (evidence: `src/pages/PlaygroundPage.tsx`)
- Summary panel → Simulation state: reads results (evidence: `src/features/statistics/SummaryPanel.tsx`)
- Simulation charts → Simulation state: reads results (evidence: `src/features/charts/CDFChart.tsx`)
- Exceedance analysis → Toxicokinetics: uses risk calculations (evidence: `src/features/playground/ExceedanceAnalyzer.tsx`)
- Method comparison → Async runner: runs comparisons (evidence: `src/pages/ComparePage.tsx`)
- Method comparison → Statistics: uses statistics (evidence: `src/pages/ComparePage.tsx`)
- Simulation worker → Monte Carlo: dispatches sampling (evidence: `src/simulation/workers/simulationWorker.ts`)
- Simulation worker → Latin hypercube: dispatches sampling (evidence: `src/simulation/workers/simulationWorker.ts`)
- Simulation worker → Hybrid sampler: dispatches sampling (evidence: `src/simulation/workers/simulationWorker.ts`)
- Simulation worker → Statistics: calculates summaries (evidence: `src/simulation/workers/simulationWorker.ts`)
- Simulation worker → Toxicokinetics: calculates compound summaries (evidence: `src/simulation/workers/simulationWorker.ts`)
