# aaravhmodi/glance architecture

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

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

## Overview

Glance is a local-first gaze-contingent video compression demo plus an offline evaluation harness. In the browser, users select a video source, calibrate or validate gaze, preview foveation, then encode normal and foveated streams, compare them side by side, and inspect live quality and bitrate. The Python harness evaluates blur, ROI, and layered approaches against fair baselines, with synthetic gaze traces and skeptic audits. Edges reflect shown imports/calls or documented product behavior; unsampled details and wiring are omitted where evidence is limited.

Main entry points: [`web/src/app.ts`](https://github.com/aaravhmodi/glance/blob/main/web/src/app.ts) (App workflow), [`offline/experiments/pipeline.py`](https://github.com/aaravhmodi/glance/blob/main/offline/experiments/pipeline.py) (FFmpeg pipeline), [`offline/experiments/experiments.py`](https://github.com/aaravhmodi/glance/blob/main/offline/experiments/experiments.py) (Blur experiments), [`web/src/gaze/tracker.ts`](https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/tracker.ts) (Eye tracker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web_input["Browser inputs and gaze"]
  node_app["App workflow<br/>[app.ts]"]
  node_sources["Video sources<br/>[source.ts]"]
  node_eye_tracker["Eye tracker<br/>[tracker.ts]"]
  node_gaze_features["Gaze features<br/>[features.ts]"]
  node_gaze_filter["Gaze filter<br/>[filter.ts]"]
  node_calibration["Calibration<br/>[calib.ts]"]
  node_regression["Gaze regression<br/>[regression.ts]"]
  node_validation["Gaze validation<br/>[validate.ts]"]
  node_accuracy["Accuracy scoring<br/>[accuracy.ts]"]
  node_gaze_switch["Gaze switching<br/>[switch.ts]"]
  node_mouse_source["Mouse gaze<br/>[mouse.ts]"]
end

subgraph group_web_video["Browser video and measurement"]
  node_foveation["WebGL foveator<br/>[foveate.ts]"]
  node_fovea_geometry["Fovea geometry<br/>[fovea.ts]"]
  node_encoders["Dual encoders<br/>[encoders.ts]"]
  node_rate_control["Rate control<br/>[rate.ts]"]
  node_decoders["Stream decoders<br/>[decoder.ts]"]
  node_quality_meter["Quality meter<br/>[meter.ts]"]
  node_quality_metrics["Quality metrics<br/>[quality.ts]"]
  node_live_stats["Live statistics<br/>[stats.ts]"]
  node_split_view["Split display<br/>[split.ts]"]
end

subgraph group_offline_eval["Offline evaluation"]
  node_offline_runner["Experiment runner<br/>[run.py]"]
  node_experiments["Blur experiments<br/>[experiments.py]"]
  node_offline_pipeline["FFmpeg pipeline<br/>[pipeline.py]"]
  node_trace_generator["Synthetic traces<br/>[traces.py]"]
  node_reporting["Results reporting<br/>[report.py]"]
  node_skeptic_audit["Skeptic audit<br/>[skeptic.py]"]
end

subgraph group_offline_methods["Offline methods"]
  node_fovea_math["Offline foveation math<br/>[fovea.py]"]
  node_roi_method["Block quality ROI<br/>[roi.py]"]
  node_layer_method["Two-layer method<br/>[layers.py]"]
  node_transport_method["Transport model<br/>[transport.py]"]
  node_t8_experiment["T8 experiment<br/>[t8.py]"]
end

node_viewer(("Viewer"))

node_viewer -->|"operates"| node_app
node_app -->|"selects source"| node_sources
node_app -->|"reads gaze"| node_eye_tracker
node_app -->|"runs calibration"| node_calibration
node_app -->|"runs validation"| node_validation
node_app -->|"switches gaze"| node_gaze_switch
node_app -->|"uses fallback"| node_mouse_source
node_eye_tracker -->|"extracts features"| node_gaze_features
node_eye_tracker -->|"filters gaze"| node_gaze_filter
node_calibration -->|"samples features"| node_gaze_features
node_calibration -->|"fits model"| node_regression
node_validation -->|"scores error"| node_accuracy
node_validation -->|"samples gaze"| node_eye_tracker
node_app -->|"previews video"| node_foveation
node_foveation -->|"uses geometry"| node_fovea_geometry
node_app -->|"starts encoding"| node_encoders
node_encoders -->|"configures rate"| node_rate_control
node_encoders -->|"records chunks"| node_live_stats
node_app -->|"creates decoders"| node_decoders
node_app -->|"measures quality"| node_quality_meter
node_quality_meter -->|"decodes samples"| node_decoders
node_quality_meter -->|"computes metrics"| node_quality_metrics
node_app -->|"displays streams"| node_split_view
node_offline_runner -->|"runs experiments"| node_experiments
node_offline_runner -->|"runs T8"| node_t8_experiment
node_offline_runner -->|"generates reports"| node_reporting
node_experiments -->|"builds comparisons"| node_offline_pipeline
node_experiments -->|"generates gaze"| node_trace_generator
node_experiments -->|"uses fovea math"| node_fovea_math
node_offline_pipeline -->|"samples gaze"| node_trace_generator
node_offline_pipeline -->|"builds weights"| node_fovea_math
node_layer_method -->|"builds baseline"| node_offline_pipeline
node_layer_method -->|"generates gaze"| node_trace_generator
node_layer_method -->|"uses fovea math"| node_fovea_math
node_roi_method -->|"uses pipeline"| node_offline_pipeline
node_skeptic_audit -->|"audits results"| node_offline_pipeline
node_t8_experiment -->|"models transport"| node_transport_method
node_t8_experiment -->|"uses pipeline"| node_offline_pipeline

click node_app "https://github.com/aaravhmodi/glance/blob/main/web/src/app.ts"
click node_sources "https://github.com/aaravhmodi/glance/blob/main/web/src/video/source.ts"
click node_eye_tracker "https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/tracker.ts"
click node_gaze_features "https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/features.ts"
click node_gaze_filter "https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/filter.ts"
click node_calibration "https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/calib.ts"
click node_regression "https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/regression.ts"
click node_validation "https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/validate.ts"
click node_accuracy "https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/accuracy.ts"
click node_gaze_switch "https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/switch.ts"
click node_mouse_source "https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/mouse.ts"
click node_foveation "https://github.com/aaravhmodi/glance/blob/main/web/src/video/foveate.ts"
click node_fovea_geometry "https://github.com/aaravhmodi/glance/blob/main/web/src/video/fovea.ts"
click node_encoders "https://github.com/aaravhmodi/glance/blob/main/web/src/video/encoders.ts"
click node_rate_control "https://github.com/aaravhmodi/glance/blob/main/web/src/video/rate.ts"
click node_decoders "https://github.com/aaravhmodi/glance/blob/main/web/src/video/decoder.ts"
click node_quality_meter "https://github.com/aaravhmodi/glance/blob/main/web/src/metrics/meter.ts"
click node_quality_metrics "https://github.com/aaravhmodi/glance/blob/main/web/src/metrics/quality.ts"
click node_live_stats "https://github.com/aaravhmodi/glance/blob/main/web/src/metrics/stats.ts"
click node_split_view "https://github.com/aaravhmodi/glance/blob/main/web/src/ui/split.ts"
click node_offline_runner "https://github.com/aaravhmodi/glance/blob/main/offline/experiments/run.py"
click node_experiments "https://github.com/aaravhmodi/glance/blob/main/offline/experiments/experiments.py"
click node_offline_pipeline "https://github.com/aaravhmodi/glance/blob/main/offline/experiments/pipeline.py"
click node_trace_generator "https://github.com/aaravhmodi/glance/blob/main/offline/experiments/traces.py"
click node_reporting "https://github.com/aaravhmodi/glance/blob/main/offline/experiments/report.py"
click node_skeptic_audit "https://github.com/aaravhmodi/glance/blob/main/offline/experiments/skeptic.py"
click node_fovea_math "https://github.com/aaravhmodi/glance/blob/main/offline/experiments/fovea.py"
click node_roi_method "https://github.com/aaravhmodi/glance/blob/main/offline/experiments/roi.py"
click node_layer_method "https://github.com/aaravhmodi/glance/blob/main/offline/experiments/layers.py"
click node_transport_method "https://github.com/aaravhmodi/glance/blob/main/offline/experiments/transport.py"
click node_t8_experiment "https://github.com/aaravhmodi/glance/blob/main/offline/experiments/t8.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_sources,node_eye_tracker,node_gaze_features,node_gaze_filter,node_calibration,node_regression,node_validation,node_accuracy,node_gaze_switch,node_mouse_source,node_viewer toneBlue
class node_foveation,node_fovea_geometry,node_encoders,node_rate_control,node_decoders,node_quality_meter,node_quality_metrics,node_live_stats,node_split_view toneAmber
class node_offline_runner,node_experiments,node_offline_pipeline,node_trace_generator,node_reporting,node_skeptic_audit toneMint
class node_fovea_math,node_roi_method,node_layer_method,node_transport_method,node_t8_experiment toneRose
```

## Components

### Browser inputs and gaze

- [App workflow](https://github.com/aaravhmodi/glance/blob/main/web/src/app.ts): `web/src/app.ts`
- [Video sources](https://github.com/aaravhmodi/glance/blob/main/web/src/video/source.ts): `web/src/video/source.ts`
- [Eye tracker](https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/tracker.ts): `web/src/gaze/tracker.ts`
- [Gaze features](https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/features.ts): `web/src/gaze/features.ts`
- [Gaze filter](https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/filter.ts): `web/src/gaze/filter.ts`
- [Calibration](https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/calib.ts): `web/src/gaze/calib.ts`
- [Gaze regression](https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/regression.ts): `web/src/gaze/regression.ts`
- [Gaze validation](https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/validate.ts): `web/src/gaze/validate.ts`
- [Accuracy scoring](https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/accuracy.ts): `web/src/gaze/accuracy.ts`
- [Gaze switching](https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/switch.ts): `web/src/gaze/switch.ts`
- [Mouse gaze](https://github.com/aaravhmodi/glance/blob/main/web/src/gaze/mouse.ts): `web/src/gaze/mouse.ts`

### Browser video and measurement

- [WebGL foveator](https://github.com/aaravhmodi/glance/blob/main/web/src/video/foveate.ts): `web/src/video/foveate.ts`
- [Fovea geometry](https://github.com/aaravhmodi/glance/blob/main/web/src/video/fovea.ts): `web/src/video/fovea.ts`
- [Dual encoders](https://github.com/aaravhmodi/glance/blob/main/web/src/video/encoders.ts): `web/src/video/encoders.ts`
- [Rate control](https://github.com/aaravhmodi/glance/blob/main/web/src/video/rate.ts): `web/src/video/rate.ts`
- [Stream decoders](https://github.com/aaravhmodi/glance/blob/main/web/src/video/decoder.ts): `web/src/video/decoder.ts`
- [Quality meter](https://github.com/aaravhmodi/glance/blob/main/web/src/metrics/meter.ts): `web/src/metrics/meter.ts`
- [Quality metrics](https://github.com/aaravhmodi/glance/blob/main/web/src/metrics/quality.ts): `web/src/metrics/quality.ts`
- [Live statistics](https://github.com/aaravhmodi/glance/blob/main/web/src/metrics/stats.ts): `web/src/metrics/stats.ts`
- [Split display](https://github.com/aaravhmodi/glance/blob/main/web/src/ui/split.ts): `web/src/ui/split.ts`

### Offline evaluation

- [Experiment runner](https://github.com/aaravhmodi/glance/blob/main/offline/experiments/run.py): `offline/experiments/run.py`
- [Blur experiments](https://github.com/aaravhmodi/glance/blob/main/offline/experiments/experiments.py): `offline/experiments/experiments.py`
- [FFmpeg pipeline](https://github.com/aaravhmodi/glance/blob/main/offline/experiments/pipeline.py): `offline/experiments/pipeline.py`
- [Synthetic traces](https://github.com/aaravhmodi/glance/blob/main/offline/experiments/traces.py): `offline/experiments/traces.py`
- [Results reporting](https://github.com/aaravhmodi/glance/blob/main/offline/experiments/report.py): `offline/experiments/report.py`
- [Skeptic audit](https://github.com/aaravhmodi/glance/blob/main/offline/experiments/skeptic.py): `offline/experiments/skeptic.py`

### Offline methods

- [Offline foveation math](https://github.com/aaravhmodi/glance/blob/main/offline/experiments/fovea.py): `offline/experiments/fovea.py`
- [Block quality ROI](https://github.com/aaravhmodi/glance/blob/main/offline/experiments/roi.py): `offline/experiments/roi.py`
- [Two-layer method](https://github.com/aaravhmodi/glance/blob/main/offline/experiments/layers.py): `offline/experiments/layers.py`
- [Transport model](https://github.com/aaravhmodi/glance/blob/main/offline/experiments/transport.py): `offline/experiments/transport.py`
- [T8 experiment](https://github.com/aaravhmodi/glance/blob/main/offline/experiments/t8.py): `offline/experiments/t8.py`

### Other components

- **Viewer**

## Connections

- Viewer → App workflow: operates
- App workflow → Video sources: selects source (evidence: `web/src/app.ts`)
- App workflow → Eye tracker: reads gaze (evidence: `web/src/app.ts`)
- App workflow → Calibration: runs calibration (evidence: `web/src/app.ts`)
- App workflow → Gaze validation: runs validation (evidence: `web/src/app.ts`)
- App workflow → Gaze switching: switches gaze (evidence: `web/src/app.ts`)
- App workflow → Mouse gaze: uses fallback (evidence: `web/src/app.ts`)
- Eye tracker → Gaze features: extracts features (evidence: `web/src/gaze/tracker.ts`)
- Eye tracker → Gaze filter: filters gaze (evidence: `web/src/gaze/tracker.ts`)
- Calibration → Gaze features: samples features (evidence: `web/src/gaze/calib.ts`)
- Calibration → Gaze regression: fits model (evidence: `web/src/gaze/calib.ts`)
- Gaze validation → Accuracy scoring: scores error (evidence: `web/src/gaze/validate.ts`)
- Gaze validation → Eye tracker: samples gaze (evidence: `web/src/gaze/validate.ts`)
- App workflow → WebGL foveator: previews video (evidence: `web/src/app.ts`)
- WebGL foveator → Fovea geometry: uses geometry (evidence: `web/src/video/foveate.ts`)
- App workflow → Dual encoders: starts encoding (evidence: `web/src/app.ts`)
- Dual encoders → Rate control: configures rate (evidence: `web/src/video/encoders.ts`)
- Dual encoders → Live statistics: records chunks (evidence: `web/src/video/encoders.ts`)
- App workflow → Stream decoders: creates decoders (evidence: `web/src/app.ts`)
- App workflow → Quality meter: measures quality (evidence: `web/src/app.ts`)
- Quality meter → Stream decoders: decodes samples (evidence: `web/src/metrics/meter.ts`)
- Quality meter → Quality metrics: computes metrics (evidence: `web/src/metrics/meter.ts`)
- App workflow → Split display: displays streams (evidence: `web/src/app.ts`)
- Experiment runner → Blur experiments: runs experiments (evidence: `offline/experiments/run.py`)
- Experiment runner → T8 experiment: runs T8 (evidence: `offline/experiments/run.py`)
- Experiment runner → Results reporting: generates reports (evidence: `offline/experiments/run.py`)
- Blur experiments → FFmpeg pipeline: builds comparisons (evidence: `offline/experiments/experiments.py`)
- Blur experiments → Synthetic traces: generates gaze (evidence: `offline/experiments/experiments.py`)
- Blur experiments → Offline foveation math: uses fovea math (evidence: `offline/experiments/experiments.py`)
- FFmpeg pipeline → Synthetic traces: samples gaze (evidence: `offline/experiments/pipeline.py`)
- FFmpeg pipeline → Offline foveation math: builds weights (evidence: `offline/experiments/pipeline.py`)
- Two-layer method → FFmpeg pipeline: builds baseline (evidence: `offline/experiments/layers.py`)
- Two-layer method → Synthetic traces: generates gaze (evidence: `offline/experiments/layers.py`)
- Two-layer method → Offline foveation math: uses fovea math (evidence: `offline/experiments/layers.py`)
- Block quality ROI → FFmpeg pipeline: uses pipeline (evidence: `offline/experiments/roi.py`)
- Skeptic audit → FFmpeg pipeline: audits results (evidence: `offline/experiments/skeptic.py`)
- T8 experiment → Transport model: models transport (evidence: `offline/experiments/t8.py`)
- T8 experiment → FFmpeg pipeline: uses pipeline (evidence: `offline/experiments/t8.py`)
