# clementsw/interferometer architecture

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

- Interactive diagram: https://gitdiagram.com/clementsw/interferometer
- Repository: https://github.com/clementsw/interferometer

## Overview

This is a compact Python library for representing and designing universal optical interferometers. A typical workflow generates or supplies a unitary matrix, decomposes it into a triangular or square beam-splitter mesh, then calculates the resulting transformation or draws the mesh. The source excerpts show these capabilities implemented in one module; the README documents the square-mesh example and plotting feature. The graph reflects those documented capabilities without assuming additional internal modules.

Main entry points: [`interferometer/__init__.py`](https://github.com/clementsw/interferometer/blob/master/interferometer/__init__.py) (Public API), [`interferometer/main.py`](https://github.com/clementsw/interferometer/blob/master/interferometer/main.py) (Square decomposition)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_user(("Library user"))
node_api["Public API<br/>[__init__.py]"]
node_haar["Haar unitary<br/>[main.py]"]
node_triangle["Triangle decomposition<br/>[main.py]"]
node_square["Square decomposition<br/>[main.py]"]
node_model["Interferometer model<br/>[main.py]"]
node_transform["Transformation calculation<br/>[main.py]"]
node_drawing["Mesh drawing<br/>[main.py]"]
node_numpy["NumPy"]
node_matplotlib["Matplotlib"]

node_user -->|"imports"| node_api
node_api -->|"exports"| node_haar
node_api -->|"exports"| node_triangle
node_api -->|"exports"| node_square
node_api -->|"exports"| node_model
node_user -->|"requests"| node_haar
node_haar -->|"uses"| node_numpy
node_user -->|"supplies matrix"| node_triangle
node_user -->|"supplies matrix"| node_square
node_haar -->|"supplies matrix"| node_square
node_triangle -->|"builds mesh"| node_model
node_square -->|"builds mesh"| node_model
node_triangle -->|"uses"| node_numpy
node_square -->|"uses"| node_numpy
node_user -->|"requests"| node_transform
node_model -->|"calculates"| node_transform
node_transform -->|"uses"| node_numpy
node_user -->|"requests"| node_drawing
node_model -->|"draws mesh"| node_drawing
node_drawing -.->|"renders with"| node_matplotlib

click node_api "https://github.com/clementsw/interferometer/blob/master/interferometer/__init__.py"
click node_haar "https://github.com/clementsw/interferometer/blob/master/interferometer/main.py"
click node_triangle "https://github.com/clementsw/interferometer/blob/master/interferometer/main.py"
click node_square "https://github.com/clementsw/interferometer/blob/master/interferometer/main.py"
click node_model "https://github.com/clementsw/interferometer/blob/master/interferometer/main.py"
click node_transform "https://github.com/clementsw/interferometer/blob/master/interferometer/main.py"
click node_drawing "https://github.com/clementsw/interferometer/blob/master/interferometer/main.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_user toneBlue
class node_api toneMint
class node_haar,node_triangle,node_square,node_transform,node_drawing toneTeal
class node_model,node_numpy,node_matplotlib toneIndigo
```

## Components

### Other components

- **Library user**
- [Public API](https://github.com/clementsw/interferometer/blob/master/interferometer/__init__.py): `interferometer/__init__.py`
- [Haar unitary](https://github.com/clementsw/interferometer/blob/master/interferometer/main.py): `interferometer/main.py`
- [Triangle decomposition](https://github.com/clementsw/interferometer/blob/master/interferometer/main.py): `interferometer/main.py`
- [Square decomposition](https://github.com/clementsw/interferometer/blob/master/interferometer/main.py): `interferometer/main.py`
- [Interferometer model](https://github.com/clementsw/interferometer/blob/master/interferometer/main.py): `interferometer/main.py`
- [Transformation calculation](https://github.com/clementsw/interferometer/blob/master/interferometer/main.py): `interferometer/main.py`
- [Mesh drawing](https://github.com/clementsw/interferometer/blob/master/interferometer/main.py): `interferometer/main.py`
- **NumPy**
- **Matplotlib**

## Connections

- Library user → Public API: imports
- Public API → Haar unitary: exports
- Public API → Triangle decomposition: exports
- Public API → Square decomposition: exports
- Public API → Interferometer model: exports
- Library user → Haar unitary: requests
- Haar unitary → NumPy: uses
- Library user → Triangle decomposition: supplies matrix
- Library user → Square decomposition: supplies matrix
- Haar unitary → Square decomposition: supplies matrix
- Triangle decomposition → Interferometer model: builds mesh
- Square decomposition → Interferometer model: builds mesh
- Triangle decomposition → NumPy: uses
- Square decomposition → NumPy: uses
- Library user → Transformation calculation: requests
- Interferometer model → Transformation calculation: calculates
- Transformation calculation → NumPy: uses
- Library user → Mesh drawing: requests
- Interferometer model → Mesh drawing: draws mesh
- Mesh drawing → Matplotlib: renders with
