# labstreaminglayer/app-pupillabs architecture

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

- Interactive diagram: https://gitdiagram.com/labstreaminglayer/app-pupillabs
- Repository: https://github.com/labstreaminglayer/app-pupillabs

## Overview

App-PupilLabs provides Pupil Capture plugins that bridge Pupil data and Lab Streaming Layer (LSL): the relay converts Pupil events into typed LSL streams, while the recorder discovers LSL streams and saves selected data as timestamped CSV. The graph separates event-specific outlets and channel extraction from plugin orchestration, and shows the recorder’s independent workflow. The README documents the plugin role; relationships between sampled relay modules are supported by their excerpts. Other integrations mentioned by the README are outside the supplied file tree.

Main entry points: [`pupil_capture/pupil_capture_lsl_relay/outlet.py`](https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/outlet.py) (Outlet factory), [`pupil_capture/pupil_capture_lsl_relay/plugin.py`](https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/plugin.py) (Relay plugin), [`pupil_capture/pupil_capture_lsl_relay/channel.py`](https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/channel.py) (Channel extraction), [`pupil_capture/pupil_capture_lsl_recorder.py`](https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_recorder.py) (Recorder plugin)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_relay["LSL Relay"]
  node_relay_plugin["Relay plugin<br/>[plugin.py]"]
  node_outlet_factory["Outlet factory<br/>[outlet.py]"]
  node_channel_extract["Channel extraction<br/>[channel.py]"]
  node_relay_version["Relay version<br/>[version.py]"]
end

subgraph group_streams["Relay Stream Types"]
  node_gaze_outlet["Scene gaze outlet"]
  node_fixation_outlet["Scene fixation outlet"]
  node_pupil_outlet["Eye pupillometry outlet"]
end

subgraph group_recording["LSL Recording"]
  node_recorder_plugin["Recorder plugin"]
  node_stream_discovery["Stream discovery"]
  node_stream_recorder["Stream recorder"]
end

node_pupil_capture(("Pupil Capture"))
node_pupil_events["Pupil event data"]
node_lsl_network["LSL streams"]
node_csv_files["Recorded CSV files"]

node_pupil_capture -->|"hosts plugin"| node_relay_plugin
node_pupil_capture -->|"hosts plugin"| node_recorder_plugin
node_pupil_events -.->|"dispatches events"| node_relay_plugin
node_relay_plugin -->|"sets up outlets"| node_outlet_factory
node_relay_plugin -->|"pushes samples"| node_outlet_factory
node_outlet_factory -->|"extracts channels"| node_channel_extract
node_outlet_factory -->|"adds version metadata"| node_relay_version
node_gaze_outlet -->|"extends outlet"| node_outlet_factory
node_gaze_outlet -->|"configures channels"| node_channel_extract
node_fixation_outlet -->|"extends outlet"| node_outlet_factory
node_fixation_outlet -->|"configures channels"| node_channel_extract
node_pupil_outlet -->|"extends outlet"| node_outlet_factory
node_pupil_outlet -->|"configures channels"| node_channel_extract
node_outlet_factory -->|"publishes samples"| node_lsl_network
node_recorder_plugin -->|"resolves streams"| node_stream_discovery
node_stream_discovery -->|"discovers streams"| node_lsl_network
node_recorder_plugin -->|"sets up recorders"| node_stream_recorder
node_stream_recorder -->|"reads samples"| node_lsl_network
node_stream_recorder -->|"writes CSV"| node_csv_files

click node_relay_plugin "https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/plugin.py"
click node_outlet_factory "https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/outlet.py"
click node_channel_extract "https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/channel.py"
click node_relay_version "https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/version.py"
click node_gaze_outlet "https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/gaze_scene_camera.py"
click node_fixation_outlet "https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/fixations_scene_camera.py"
click node_pupil_outlet "https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/pupillometry_eye_camera.py"
click node_recorder_plugin "https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_recorder.py"
click node_stream_discovery "https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_recorder.py"
click node_stream_recorder "https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_recorder.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_relay_plugin,node_outlet_factory,node_channel_extract,node_relay_version toneBlue
class node_gaze_outlet,node_fixation_outlet,node_pupil_outlet toneAmber
class node_recorder_plugin,node_stream_discovery,node_stream_recorder toneMint
class node_pupil_capture,node_pupil_events,node_lsl_network,node_csv_files toneIndigo
```

## Components

### LSL Relay

- [Relay plugin](https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/plugin.py): `pupil_capture/pupil_capture_lsl_relay/plugin.py`
- [Outlet factory](https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/outlet.py): `pupil_capture/pupil_capture_lsl_relay/outlet.py`
- [Channel extraction](https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/channel.py): `pupil_capture/pupil_capture_lsl_relay/channel.py`
- [Relay version](https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/version.py): `pupil_capture/pupil_capture_lsl_relay/version.py`

### Relay Stream Types

- [Scene gaze outlet](https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/gaze_scene_camera.py): `pupil_capture/pupil_capture_lsl_relay/gaze_scene_camera.py`
- [Scene fixation outlet](https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/fixations_scene_camera.py): `pupil_capture/pupil_capture_lsl_relay/fixations_scene_camera.py`
- [Eye pupillometry outlet](https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_relay/pupillometry_eye_camera.py): `pupil_capture/pupil_capture_lsl_relay/pupillometry_eye_camera.py`

### LSL Recording

- [Recorder plugin](https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_recorder.py): `pupil_capture/pupil_capture_lsl_recorder.py`
- [Stream discovery](https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_recorder.py): `pupil_capture/pupil_capture_lsl_recorder.py`
- [Stream recorder](https://github.com/labstreaminglayer/app-pupillabs/blob/master/pupil_capture/pupil_capture_lsl_recorder.py): `pupil_capture/pupil_capture_lsl_recorder.py`

### Other components

- **Pupil Capture**
- **Pupil event data**
- **LSL streams**
- **Recorded CSV files**

## Connections

- Pupil Capture → Relay plugin: hosts plugin (evidence: `README.md`)
- Pupil Capture → Recorder plugin: hosts plugin (evidence: `README.md`)
- Pupil event data → Relay plugin: dispatches events
- Relay plugin → Outlet factory: sets up outlets (evidence: `pupil_capture/pupil_capture_lsl_relay/plugin.py`)
- Relay plugin → Outlet factory: pushes samples (evidence: `pupil_capture/pupil_capture_lsl_relay/plugin.py`)
- Outlet factory → Channel extraction: extracts channels (evidence: `pupil_capture/pupil_capture_lsl_relay/outlet.py`)
- Outlet factory → Relay version: adds version metadata (evidence: `pupil_capture/pupil_capture_lsl_relay/outlet.py`)
- Scene gaze outlet → Outlet factory: extends outlet (evidence: `pupil_capture/pupil_capture_lsl_relay/gaze_scene_camera.py`)
- Scene gaze outlet → Channel extraction: configures channels (evidence: `pupil_capture/pupil_capture_lsl_relay/gaze_scene_camera.py`)
- Scene fixation outlet → Outlet factory: extends outlet (evidence: `pupil_capture/pupil_capture_lsl_relay/fixations_scene_camera.py`)
- Scene fixation outlet → Channel extraction: configures channels (evidence: `pupil_capture/pupil_capture_lsl_relay/fixations_scene_camera.py`)
- Eye pupillometry outlet → Outlet factory: extends outlet (evidence: `pupil_capture/pupil_capture_lsl_relay/pupillometry_eye_camera.py`)
- Eye pupillometry outlet → Channel extraction: configures channels (evidence: `pupil_capture/pupil_capture_lsl_relay/pupillometry_eye_camera.py`)
- Outlet factory → LSL streams: publishes samples (evidence: `pupil_capture/pupil_capture_lsl_relay/outlet.py`)
- Recorder plugin → Stream discovery: resolves streams (evidence: `pupil_capture/pupil_capture_lsl_recorder.py`)
- Stream discovery → LSL streams: discovers streams (evidence: `pupil_capture/pupil_capture_lsl_recorder.py`)
- Recorder plugin → Stream recorder: sets up recorders (evidence: `pupil_capture/pupil_capture_lsl_recorder.py`)
- Stream recorder → LSL streams: reads samples (evidence: `pupil_capture/pupil_capture_lsl_recorder.py`)
- Stream recorder → Recorded CSV files: writes CSV (evidence: `pupil_capture/pupil_capture_lsl_recorder.py`)
