# unixpenguin/opticsbox architecture

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

- Interactive diagram: https://gitdiagram.com/unixpenguin/opticsbox
- Repository: https://github.com/unixpenguin/opticsbox
- Video tour (about a minute): https://gitdiagram.com/unixpenguin/opticsbox/video

## Overview

OpticsBox is a browser-based photonic-circuit simulator, with a parallel Python library for the same transfer-matrix physics. The main workflow is to assemble and configure a circuit, calculate its matrices and output behavior, then inspect or export results. The README documents the browser features, but the HTML source was not sampled, so relationships for that implementation are based on those documented capabilities; the Python excerpt shows its component and circuit APIs.

Main entry points: [`index.html`](https://github.com/unixpenguin/opticsbox/blob/main/index.html) (Circuit solver), [`opticsbox.py`](https://github.com/unixpenguin/opticsbox/blob/main/opticsbox.py) (Python Circuit)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser simulator"]
  node_editor["Circuit editor<br/>[index.html]"]
  node_parameters["Parameters and inputs<br/>[index.html]"]
end

subgraph group_physics["Simulation physics"]
  node_components["Component library<br/>[index.html]"]
  node_matrix["Transfer matrices<br/>[index.html]"]
  node_solver["Circuit solver<br/>[index.html]"]
end

subgraph group_results["Analysis and export"]
  node_spectrum["Spectrum sweep<br/>[index.html]"]
  node_outputs["Port results<br/>[index.html]"]
  node_probe["Field probe<br/>[index.html]"]
  node_matrix_view["Matrices tab<br/>[index.html]"]
  node_reference["Reference tab<br/>[index.html]"]
  node_csv["CSV export<br/>[index.html]"]
  node_python_export["Python export<br/>[index.html]"]
  node_sharing["Circuit sharing<br/>[index.html]"]
end

subgraph group_python["Python library"]
  node_py_components["Python components<br/>[opticsbox.py]"]
  node_py_circuit["Python Circuit<br/>[opticsbox.py]"]
  node_py_sweep["Python sweep<br/>[opticsbox.py]"]
end

node_user(("Circuit designer"))

node_user -->|"builds circuit"| node_editor
node_user -->|"sets inputs"| node_parameters
node_editor -->|"places components"| node_components
node_parameters -->|"configures model"| node_solver
node_components -->|"defines matrices"| node_matrix
node_matrix -->|"forms circuit matrix"| node_solver
node_solver -->|"calculates ports"| node_outputs
node_solver -->|"sweeps wavelengths"| node_spectrum
node_solver -->|"reports fields"| node_probe
node_solver -->|"provides matrices"| node_matrix_view
node_user -->|"searches components"| node_reference
node_spectrum -->|"exports data"| node_csv
node_user -->|"requests export"| node_python_export
node_user -->|"shares circuit"| node_sharing
node_py_components -->|"adds to circuit"| node_py_circuit
node_py_circuit -->|"sweeps wavelengths"| node_py_sweep

click node_editor "https://github.com/unixpenguin/opticsbox/blob/main/index.html"
click node_parameters "https://github.com/unixpenguin/opticsbox/blob/main/index.html"
click node_components "https://github.com/unixpenguin/opticsbox/blob/main/index.html"
click node_matrix "https://github.com/unixpenguin/opticsbox/blob/main/index.html"
click node_solver "https://github.com/unixpenguin/opticsbox/blob/main/index.html"
click node_spectrum "https://github.com/unixpenguin/opticsbox/blob/main/index.html"
click node_outputs "https://github.com/unixpenguin/opticsbox/blob/main/index.html"
click node_probe "https://github.com/unixpenguin/opticsbox/blob/main/index.html"
click node_matrix_view "https://github.com/unixpenguin/opticsbox/blob/main/index.html"
click node_reference "https://github.com/unixpenguin/opticsbox/blob/main/index.html"
click node_csv "https://github.com/unixpenguin/opticsbox/blob/main/index.html"
click node_python_export "https://github.com/unixpenguin/opticsbox/blob/main/index.html"
click node_sharing "https://github.com/unixpenguin/opticsbox/blob/main/index.html"
click node_py_components "https://github.com/unixpenguin/opticsbox/blob/main/opticsbox.py"
click node_py_circuit "https://github.com/unixpenguin/opticsbox/blob/main/opticsbox.py"
click node_py_sweep "https://github.com/unixpenguin/opticsbox/blob/main/opticsbox.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_editor,node_parameters toneBlue
class node_components,node_matrix,node_solver toneAmber
class node_spectrum,node_outputs,node_probe,node_matrix_view,node_reference,node_csv,node_python_export,node_sharing toneMint
class node_py_components,node_py_circuit,node_py_sweep toneRose
class node_user toneIndigo
```

## Components

### Browser simulator

- [Circuit editor](https://github.com/unixpenguin/opticsbox/blob/main/index.html): `index.html`
- [Parameters and inputs](https://github.com/unixpenguin/opticsbox/blob/main/index.html): `index.html`

### Simulation physics

- [Component library](https://github.com/unixpenguin/opticsbox/blob/main/index.html): `index.html`
- [Transfer matrices](https://github.com/unixpenguin/opticsbox/blob/main/index.html): `index.html`
- [Circuit solver](https://github.com/unixpenguin/opticsbox/blob/main/index.html): `index.html`

### Analysis and export

- [Spectrum sweep](https://github.com/unixpenguin/opticsbox/blob/main/index.html): `index.html`
- [Port results](https://github.com/unixpenguin/opticsbox/blob/main/index.html): `index.html`
- [Field probe](https://github.com/unixpenguin/opticsbox/blob/main/index.html): `index.html`
- [Matrices tab](https://github.com/unixpenguin/opticsbox/blob/main/index.html): `index.html`
- [Reference tab](https://github.com/unixpenguin/opticsbox/blob/main/index.html): `index.html`
- [CSV export](https://github.com/unixpenguin/opticsbox/blob/main/index.html): `index.html`
- [Python export](https://github.com/unixpenguin/opticsbox/blob/main/index.html): `index.html`
- [Circuit sharing](https://github.com/unixpenguin/opticsbox/blob/main/index.html): `index.html`

### Python library

- [Python components](https://github.com/unixpenguin/opticsbox/blob/main/opticsbox.py): `opticsbox.py`
- [Python Circuit](https://github.com/unixpenguin/opticsbox/blob/main/opticsbox.py): `opticsbox.py`
- [Python sweep](https://github.com/unixpenguin/opticsbox/blob/main/opticsbox.py): `opticsbox.py`

### Other components

- **Circuit designer**

## Connections

- Circuit designer → Circuit editor: builds circuit (evidence: `README.md`)
- Circuit designer → Parameters and inputs: sets inputs (evidence: `README.md`)
- Circuit editor → Component library: places components (evidence: `README.md`)
- Parameters and inputs → Circuit solver: configures model (evidence: `README.md`)
- Component library → Transfer matrices: defines matrices (evidence: `README.md`)
- Transfer matrices → Circuit solver: forms circuit matrix (evidence: `README.md`)
- Circuit solver → Port results: calculates ports (evidence: `README.md`)
- Circuit solver → Spectrum sweep: sweeps wavelengths (evidence: `README.md`)
- Circuit solver → Field probe: reports fields (evidence: `README.md`)
- Circuit solver → Matrices tab: provides matrices (evidence: `README.md`)
- Circuit designer → Reference tab: searches components (evidence: `README.md`)
- Spectrum sweep → CSV export: exports data (evidence: `README.md`)
- Circuit designer → Python export: requests export (evidence: `README.md`)
- Circuit designer → Circuit sharing: shares circuit (evidence: `README.md`)
- Python components → Python Circuit: adds to circuit (evidence: `opticsbox.py`)
- Python Circuit → Python sweep: sweeps wavelengths (evidence: `opticsbox.py`)
