# ucla-cdl/prior-weaver architecture

> Architecture diagram of the GitHub repository ucla-cdl/prior-weaver, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ucla-cdl/prior-weaver
- Repository: https://github.com/ucla-cdl/prior-weaver

## Overview

PriorWeaver is a web application for eliciting Bayesian priors by turning domain assumptions into an editable representative dataset, fitted prior distributions, and prior-predictive visual checks. The principal workflow moves through model setup, variable and relationship specification, and reviewing or adjusting results; the README also describes flexible iteration across these stages. The frontend components and context relationships are supported by excerpts and the SOURCE INDEX. Backend internals beyond the Bambi parser were not sampled, so backend capability links are limited to explicit API calls or README-described behavior.

Main entry points: [`src/containers/Workspace.jsx`](https://github.com/ucla-cdl/prior-weaver/blob/main/src/containers/Workspace.jsx) (Elicitation workspace), [`src/App.js`](https://github.com/ucla-cdl/prior-weaver/blob/main/src/App.js) (App router), [`src/contexts/VariableContext.jsx`](https://github.com/ucla-cdl/prior-weaver/blob/main/src/contexts/VariableContext.jsx) (Variables and parameters), [`src/contexts/EntityContext.jsx`](https://github.com/ucla-cdl/prior-weaver/blob/main/src/contexts/EntityContext.jsx) (Representative entities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["App entry and navigation"]
  node_app["App router<br/>[App.js]"]
  node_routes["Route definitions<br/>[routes.js]"]
  node_home["Home overview<br/>[Home.jsx]"]
  node_admin["Admin view<br/>[Admin.jsx]"]
  node_docs["Documentation view<br/>[Doc.jsx]"]
end

subgraph group_elicitation["Prior elicitation workspace"]
  node_workspace["Elicitation workspace<br/>[Workspace.jsx]"]
  node_navbar["Workspace navigation<br/>[NavBar.jsx]"]
  node_intro["Model setup<br/>[IntroPage.jsx]"]
  node_modelpanel["Model panel<br/>[ModelPanel.jsx]"]
  node_variableplot["Univariate plot<br/>[VariablePlot.jsx]"]
  node_bivariateplot["Bivariate plot<br/>[BiVariablePlot.jsx]"]
  node_sankeyplot["Multivariate plot"]
  node_parameterplot["Parameter plot<br/>[ParameterPlot.jsx]"]
  node_results["Prior results<br/>[ResultsPanel.jsx]"]
end

subgraph group_state["Shared elicitation state"]
  node_workspacectx["Workspace settings"]
  node_variablectx["Variables and parameters"]
  node_entityctx["Representative entities<br/>[EntityContext.jsx]"]
  node_selectionctx["Selection and filtering"]
end

subgraph group_backend["Model and service backend"]
  node_backend["PriorWeaver API<br/>[main.py]"]
  node_parser["Bambi model parser<br/>[bambi_parser.py]"]
end

node_analyst(("Domain analyst"))

node_analyst -.->|"opens application"| node_home
node_app -->|"uses paths"| node_routes
node_app -->|"routes to"| node_workspace
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_admin
node_app -->|"routes to"| node_docs
node_app -->|"provides state"| node_workspacectx
node_app -->|"provides state"| node_variablectx
node_app -->|"provides state"| node_entityctx
node_app -->|"provides state"| node_selectionctx
node_workspace -->|"renders setup"| node_intro
node_workspace -->|"renders navigation"| node_navbar
node_workspace -->|"renders panel"| node_modelpanel
node_workspace -->|"renders plot"| node_variableplot
node_workspace -->|"renders plot"| node_bivariateplot
node_workspace -->|"renders plot"| node_sankeyplot
node_workspace -->|"renders plots"| node_parameterplot
node_workspace -->|"renders results"| node_results
node_intro -.->|"parses model"| node_backend
node_variablectx -->|"requests parsing"| node_backend
node_workspacectx -->|"fetches settings"| node_backend
node_workspacectx -->|"loads records"| node_backend
node_entityctx -->|"saves record"| node_backend
node_backend -->|"parses Bambi code"| node_parser
node_variablectx -->|"uses model settings"| node_workspacectx
node_entityctx -->|"reads user mode"| node_workspacectx
node_entityctx -->|"uses variables"| node_variablectx
node_selectionctx -->|"filters by variables"| node_variablectx
node_variableplot -->|"reads variables"| node_variablectx
node_variableplot -->|"reads entities"| node_entityctx
node_variableplot -->|"uses selection"| node_selectionctx
node_bivariateplot -->|"reads variables"| node_variablectx
node_bivariateplot -->|"reads entities"| node_entityctx
node_bivariateplot -->|"uses selection"| node_selectionctx
node_sankeyplot -->|"reads variables"| node_variablectx
node_sankeyplot -->|"reads entities"| node_entityctx
node_sankeyplot -->|"updates selection"| node_selectionctx
node_parameterplot -->|"reads parameters"| node_variablectx
node_parameterplot -->|"reads entities"| node_entityctx
node_results -->|"reads parameters"| node_variablectx
node_results -->|"reads entities"| node_entityctx
node_results -->|"updates distribution"| node_backend
node_analyst -.->|"specifies assumptions"| node_workspace
node_analyst -.->|"reviews prior checks"| node_results

click node_app "https://github.com/ucla-cdl/prior-weaver/blob/main/src/App.js"
click node_routes "https://github.com/ucla-cdl/prior-weaver/blob/main/src/shared/routes.js"
click node_home "https://github.com/ucla-cdl/prior-weaver/blob/main/src/containers/Home.jsx"
click node_admin "https://github.com/ucla-cdl/prior-weaver/blob/main/src/containers/Admin.jsx"
click node_docs "https://github.com/ucla-cdl/prior-weaver/blob/main/src/containers/Doc.jsx"
click node_workspace "https://github.com/ucla-cdl/prior-weaver/blob/main/src/containers/Workspace.jsx"
click node_navbar "https://github.com/ucla-cdl/prior-weaver/blob/main/src/components/NavBar.jsx"
click node_intro "https://github.com/ucla-cdl/prior-weaver/blob/main/src/components/IntroPage.jsx"
click node_modelpanel "https://github.com/ucla-cdl/prior-weaver/blob/main/src/components/ModelPanel.jsx"
click node_variableplot "https://github.com/ucla-cdl/prior-weaver/blob/main/src/components/VariablePlot.jsx"
click node_bivariateplot "https://github.com/ucla-cdl/prior-weaver/blob/main/src/components/BiVariablePlot.jsx"
click node_sankeyplot "https://github.com/ucla-cdl/prior-weaver/blob/main/src/components/ParallelSankeyPlot.jsx"
click node_parameterplot "https://github.com/ucla-cdl/prior-weaver/blob/main/src/components/ParameterPlot.jsx"
click node_results "https://github.com/ucla-cdl/prior-weaver/blob/main/src/components/ResultsPanel.jsx"
click node_workspacectx "https://github.com/ucla-cdl/prior-weaver/blob/main/src/contexts/WorkspaceContext.jsx"
click node_variablectx "https://github.com/ucla-cdl/prior-weaver/blob/main/src/contexts/VariableContext.jsx"
click node_entityctx "https://github.com/ucla-cdl/prior-weaver/blob/main/src/contexts/EntityContext.jsx"
click node_selectionctx "https://github.com/ucla-cdl/prior-weaver/blob/main/src/contexts/SelectionContext.jsx"
click node_backend "https://github.com/ucla-cdl/prior-weaver/blob/main/main.py"
click node_parser "https://github.com/ucla-cdl/prior-weaver/blob/main/bambi_parser.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_app,node_routes,node_home,node_admin,node_docs toneBlue
class node_workspace,node_navbar,node_intro,node_modelpanel,node_variableplot,node_bivariateplot,node_sankeyplot,node_parameterplot,node_results toneAmber
class node_workspacectx,node_variablectx,node_entityctx,node_selectionctx toneMint
class node_backend,node_parser toneRose
class node_analyst toneIndigo
```

## Components

### App entry and navigation

- [App router](https://github.com/ucla-cdl/prior-weaver/blob/main/src/App.js): `src/App.js`
- [Route definitions](https://github.com/ucla-cdl/prior-weaver/blob/main/src/shared/routes.js): `src/shared/routes.js`
- [Home overview](https://github.com/ucla-cdl/prior-weaver/blob/main/src/containers/Home.jsx): `src/containers/Home.jsx`
- [Admin view](https://github.com/ucla-cdl/prior-weaver/blob/main/src/containers/Admin.jsx): `src/containers/Admin.jsx`
- [Documentation view](https://github.com/ucla-cdl/prior-weaver/blob/main/src/containers/Doc.jsx): `src/containers/Doc.jsx`

### Prior elicitation workspace

- [Elicitation workspace](https://github.com/ucla-cdl/prior-weaver/blob/main/src/containers/Workspace.jsx): `src/containers/Workspace.jsx`
- [Workspace navigation](https://github.com/ucla-cdl/prior-weaver/blob/main/src/components/NavBar.jsx): `src/components/NavBar.jsx`
- [Model setup](https://github.com/ucla-cdl/prior-weaver/blob/main/src/components/IntroPage.jsx): `src/components/IntroPage.jsx`
- [Model panel](https://github.com/ucla-cdl/prior-weaver/blob/main/src/components/ModelPanel.jsx): `src/components/ModelPanel.jsx`
- [Univariate plot](https://github.com/ucla-cdl/prior-weaver/blob/main/src/components/VariablePlot.jsx): `src/components/VariablePlot.jsx`
- [Bivariate plot](https://github.com/ucla-cdl/prior-weaver/blob/main/src/components/BiVariablePlot.jsx): `src/components/BiVariablePlot.jsx`
- [Multivariate plot](https://github.com/ucla-cdl/prior-weaver/blob/main/src/components/ParallelSankeyPlot.jsx): `src/components/ParallelSankeyPlot.jsx`
- [Parameter plot](https://github.com/ucla-cdl/prior-weaver/blob/main/src/components/ParameterPlot.jsx): `src/components/ParameterPlot.jsx`
- [Prior results](https://github.com/ucla-cdl/prior-weaver/blob/main/src/components/ResultsPanel.jsx): `src/components/ResultsPanel.jsx`

### Shared elicitation state

- [Workspace settings](https://github.com/ucla-cdl/prior-weaver/blob/main/src/contexts/WorkspaceContext.jsx): `src/contexts/WorkspaceContext.jsx`
- [Variables and parameters](https://github.com/ucla-cdl/prior-weaver/blob/main/src/contexts/VariableContext.jsx): `src/contexts/VariableContext.jsx`
- [Representative entities](https://github.com/ucla-cdl/prior-weaver/blob/main/src/contexts/EntityContext.jsx): `src/contexts/EntityContext.jsx`
- [Selection and filtering](https://github.com/ucla-cdl/prior-weaver/blob/main/src/contexts/SelectionContext.jsx): `src/contexts/SelectionContext.jsx`

### Model and service backend

- [PriorWeaver API](https://github.com/ucla-cdl/prior-weaver/blob/main/main.py): `main.py`
- [Bambi model parser](https://github.com/ucla-cdl/prior-weaver/blob/main/bambi_parser.py): `bambi_parser.py`

### Other components

- **Domain analyst**

## Connections

- Domain analyst → Home overview: opens application (evidence: `README.md`)
- App router → Route definitions: uses paths (evidence: `src/App.js`)
- App router → Elicitation workspace: routes to (evidence: `src/App.js`)
- App router → Home overview: routes to (evidence: `src/App.js`)
- App router → Admin view: routes to (evidence: `src/App.js`)
- App router → Documentation view: routes to (evidence: `src/App.js`)
- App router → Workspace settings: provides state (evidence: `src/App.js`)
- App router → Variables and parameters: provides state (evidence: `src/App.js`)
- App router → Representative entities: provides state (evidence: `src/App.js`)
- App router → Selection and filtering: provides state (evidence: `src/App.js`)
- Elicitation workspace → Model setup: renders setup (evidence: `src/containers/Workspace.jsx`)
- Elicitation workspace → Workspace navigation: renders navigation (evidence: `src/containers/Workspace.jsx`)
- Elicitation workspace → Model panel: renders panel (evidence: `src/containers/Workspace.jsx`)
- Elicitation workspace → Univariate plot: renders plot (evidence: `src/containers/Workspace.jsx`)
- Elicitation workspace → Bivariate plot: renders plot (evidence: `src/containers/Workspace.jsx`)
- Elicitation workspace → Multivariate plot: renders plot (evidence: `src/containers/Workspace.jsx`)
- Elicitation workspace → Parameter plot: renders plots (evidence: `src/containers/Workspace.jsx`)
- Elicitation workspace → Prior results: renders results (evidence: `src/containers/Workspace.jsx`)
- Model setup → PriorWeaver API: parses model
- Variables and parameters → PriorWeaver API: requests parsing (evidence: `src/contexts/VariableContext.jsx`)
- Workspace settings → PriorWeaver API: fetches settings (evidence: `src/contexts/WorkspaceContext.jsx`)
- Workspace settings → PriorWeaver API: loads records (evidence: `src/contexts/WorkspaceContext.jsx`)
- Representative entities → PriorWeaver API: saves record (evidence: `src/contexts/EntityContext.jsx`)
- PriorWeaver API → Bambi model parser: parses Bambi code (evidence: `main.py`)
- Variables and parameters → Workspace settings: uses model settings (evidence: `src/contexts/VariableContext.jsx`)
- Representative entities → Workspace settings: reads user mode (evidence: `src/contexts/EntityContext.jsx`)
- Representative entities → Variables and parameters: uses variables (evidence: `src/contexts/EntityContext.jsx`)
- Selection and filtering → Variables and parameters: filters by variables (evidence: `src/contexts/SelectionContext.jsx`)
- Univariate plot → Variables and parameters: reads variables (evidence: `src/components/VariablePlot.jsx`)
- Univariate plot → Representative entities: reads entities (evidence: `src/components/VariablePlot.jsx`)
- Univariate plot → Selection and filtering: uses selection (evidence: `src/components/VariablePlot.jsx`)
- Bivariate plot → Variables and parameters: reads variables (evidence: `src/components/BiVariablePlot.jsx`)
- Bivariate plot → Representative entities: reads entities (evidence: `src/components/BiVariablePlot.jsx`)
- Bivariate plot → Selection and filtering: uses selection (evidence: `src/components/BiVariablePlot.jsx`)
- Multivariate plot → Variables and parameters: reads variables (evidence: `src/components/ParallelSankeyPlot.jsx`)
- Multivariate plot → Representative entities: reads entities (evidence: `src/components/ParallelSankeyPlot.jsx`)
- Multivariate plot → Selection and filtering: updates selection (evidence: `src/components/ParallelSankeyPlot.jsx`)
- Parameter plot → Variables and parameters: reads parameters (evidence: `src/components/ParameterPlot.jsx`)
- Parameter plot → Representative entities: reads entities (evidence: `src/components/ParameterPlot.jsx`)
- Prior results → Variables and parameters: reads parameters (evidence: `src/components/ResultsPanel.jsx`)
- Prior results → Representative entities: reads entities (evidence: `src/components/ResultsPanel.jsx`)
- Prior results → PriorWeaver API: updates distribution (evidence: `src/components/ResultsPanel.jsx`)
- Domain analyst → Elicitation workspace: specifies assumptions (evidence: `README.md`)
- Domain analyst → Prior results: reviews prior checks (evidence: `README.md`)
