# yngboson/streamomr architecture

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

- Interactive diagram: https://gitdiagram.com/yngboson/streamomr
- Repository: https://github.com/yngboson/streamomr

## Overview

StreamOMR scans self-describing answer sheets from a live camera or image, recognizes identity and answers, stabilizes results across frames, then records, grades, and presents them for review. It has a server application and a browser-only edition. The graph preserves form generation, scan management, and review capabilities documented in the README and handoff log. Some frontend and standalone wiring is unsampled, so those connections are omitted or marked unverified.

Main entry points: [`omr/recognize.py`](https://github.com/yngboson/streamomr/blob/main/omr/recognize.py) (Sheet recognition), [`app/main.py`](https://github.com/yngboson/streamomr/blob/main/app/main.py) (HTTP and camera API), [`omr/service.py`](https://github.com/yngboson/streamomr/blob/main/omr/service.py) (Exam and scan operations), [`omr/stream.py`](https://github.com/yngboson/streamomr/blob/main/omr/stream.py) (Frame stabilization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_forms["Forms and layout"]
  node_layout["Sheet layout<br/>[layout.py]"]
  node_pdf["Printable PDF<br/>[render_pdf.py]"]
end

subgraph group_recognition["OMR recognition"]
  node_markers["Marker and header codec<br/>[markers.py]"]
  node_detect["Marker detection<br/>[detect.py]"]
  node_tracks["Page flattening<br/>[tracks.py]"]
  node_illum["Lighting correction<br/>[illum.py]"]
  node_ink["Ink calibration<br/>[ink.py]"]
  node_recognize["Sheet recognition<br/>[recognize.py]"]
  node_stream["Frame stabilization<br/>[stream.py]"]
  node_fusion["Frame fusion<br/>[fusion.py]"]
  node_identity["Sheet identity<br/>[identity.py]"]
end

subgraph group_server["Server workflow"]
  node_api["HTTP and camera API<br/>[main.py]"]
  node_service["Exam and scan operations<br/>[service.py]"]
  node_database[("Scan and exam database<br/>[db.py]")]
end

subgraph group_review["Review interfaces"]
  node_review["Review image helpers<br/>[review.py]"]
  node_web["Server review UI<br/>[scan.js]"]
  node_detail["Scan detail UI<br/>[detail.js]"]
end

subgraph group_standalone["Browser standalone"]
  node_standalone_ui["Standalone interface<br/>[app.js]"]
  node_glue["Python browser bridge<br/>[glue.py]"]
  node_worker["Pyodide worker<br/>[worker.js]"]
end

node_teacher(("Exam operator"))
node_camera(("Camera / image"))

node_teacher -->|"submits scans"| node_api
node_camera -->|"streams frames"| node_api
node_teacher -->|"scans sheets"| node_standalone_ui
node_layout -->|"defines geometry"| node_pdf
node_api -->|"delegates operations"| node_service
node_api -->|"uses recognition"| node_recognize
node_api -->|"uses stream state"| node_stream
node_service -->|"reads and writes"| node_database
node_service -->|"generates forms"| node_pdf
node_service -->|"loads layouts"| node_layout
node_service -->|"applies identity policy"| node_identity
node_recognize -->|"detects markers"| node_detect
node_recognize -->|"decodes sheet header"| node_markers
node_recognize -->|"resolves layout"| node_layout
node_recognize -->|"flattens sheet"| node_tracks
node_recognize -->|"corrects lighting"| node_illum
node_recognize -->|"calibrates ink"| node_ink
node_stream -->|"fuses frames"| node_fusion
node_stream -->|"keys sheets"| node_identity
node_api -->|"serves previews"| node_review
node_teacher -->|"reviews results"| node_web
node_teacher -->|"inspects scans"| node_detail
node_standalone_ui -.->|"requests recognition"| node_glue
node_worker -.->|"runs Python bridge"| node_glue

click node_layout "https://github.com/yngboson/streamomr/blob/main/omr/layout.py"
click node_pdf "https://github.com/yngboson/streamomr/blob/main/omr/render_pdf.py"
click node_markers "https://github.com/yngboson/streamomr/blob/main/omr/markers.py"
click node_detect "https://github.com/yngboson/streamomr/blob/main/omr/detect.py"
click node_tracks "https://github.com/yngboson/streamomr/blob/main/omr/tracks.py"
click node_illum "https://github.com/yngboson/streamomr/blob/main/omr/illum.py"
click node_ink "https://github.com/yngboson/streamomr/blob/main/omr/ink.py"
click node_recognize "https://github.com/yngboson/streamomr/blob/main/omr/recognize.py"
click node_stream "https://github.com/yngboson/streamomr/blob/main/omr/stream.py"
click node_fusion "https://github.com/yngboson/streamomr/blob/main/omr/fusion.py"
click node_identity "https://github.com/yngboson/streamomr/blob/main/omr/identity.py"
click node_api "https://github.com/yngboson/streamomr/blob/main/app/main.py"
click node_service "https://github.com/yngboson/streamomr/blob/main/omr/service.py"
click node_database "https://github.com/yngboson/streamomr/blob/main/omr/db.py"
click node_review "https://github.com/yngboson/streamomr/blob/main/omr/review.py"
click node_web "https://github.com/yngboson/streamomr/blob/main/app/static/scan.js"
click node_detail "https://github.com/yngboson/streamomr/blob/main/app/static/detail.js"
click node_standalone_ui "https://github.com/yngboson/streamomr/blob/main/standalone/app.js"
click node_glue "https://github.com/yngboson/streamomr/blob/main/standalone/glue.py"
click node_worker "https://github.com/yngboson/streamomr/blob/main/standalone/worker.js"

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_layout,node_pdf toneBlue
class node_markers,node_detect,node_tracks,node_illum,node_ink,node_recognize,node_stream,node_fusion,node_identity toneAmber
class node_api,node_service,node_database toneMint
class node_review,node_web,node_detail toneRose
class node_standalone_ui,node_glue,node_worker,node_teacher,node_camera toneIndigo
```

## Components

### Forms and layout

- [Sheet layout](https://github.com/yngboson/streamomr/blob/main/omr/layout.py): `omr/layout.py`
- [Printable PDF](https://github.com/yngboson/streamomr/blob/main/omr/render_pdf.py): `omr/render_pdf.py`

### OMR recognition

- [Marker and header codec](https://github.com/yngboson/streamomr/blob/main/omr/markers.py): `omr/markers.py`
- [Marker detection](https://github.com/yngboson/streamomr/blob/main/omr/detect.py): `omr/detect.py`
- [Page flattening](https://github.com/yngboson/streamomr/blob/main/omr/tracks.py): `omr/tracks.py`
- [Lighting correction](https://github.com/yngboson/streamomr/blob/main/omr/illum.py): `omr/illum.py`
- [Ink calibration](https://github.com/yngboson/streamomr/blob/main/omr/ink.py): `omr/ink.py`
- [Sheet recognition](https://github.com/yngboson/streamomr/blob/main/omr/recognize.py): `omr/recognize.py`
- [Frame stabilization](https://github.com/yngboson/streamomr/blob/main/omr/stream.py): `omr/stream.py`
- [Frame fusion](https://github.com/yngboson/streamomr/blob/main/omr/fusion.py): `omr/fusion.py`
- [Sheet identity](https://github.com/yngboson/streamomr/blob/main/omr/identity.py): `omr/identity.py`

### Server workflow

- [HTTP and camera API](https://github.com/yngboson/streamomr/blob/main/app/main.py): `app/main.py`
- [Exam and scan operations](https://github.com/yngboson/streamomr/blob/main/omr/service.py): `omr/service.py`
- [Scan and exam database](https://github.com/yngboson/streamomr/blob/main/omr/db.py): `omr/db.py`

### Review interfaces

- [Review image helpers](https://github.com/yngboson/streamomr/blob/main/omr/review.py): `omr/review.py`
- [Server review UI](https://github.com/yngboson/streamomr/blob/main/app/static/scan.js): `app/static/scan.js`
- [Scan detail UI](https://github.com/yngboson/streamomr/blob/main/app/static/detail.js): `app/static/detail.js`

### Browser standalone

- [Standalone interface](https://github.com/yngboson/streamomr/blob/main/standalone/app.js): `standalone/app.js`
- [Python browser bridge](https://github.com/yngboson/streamomr/blob/main/standalone/glue.py): `standalone/glue.py`
- [Pyodide worker](https://github.com/yngboson/streamomr/blob/main/standalone/worker.js): `standalone/worker.js`

### Other components

- **Exam operator**
- **Camera / image**

## Connections

- Exam operator → HTTP and camera API: submits scans (evidence: `README.md`)
- Camera / image → HTTP and camera API: streams frames (evidence: `app/main.py`)
- Exam operator → Standalone interface: scans sheets (evidence: `README.md`)
- Sheet layout → Printable PDF: defines geometry (evidence: `omr/render_pdf.py`)
- HTTP and camera API → Exam and scan operations: delegates operations (evidence: `app/main.py`)
- HTTP and camera API → Sheet recognition: uses recognition (evidence: `app/main.py`)
- HTTP and camera API → Frame stabilization: uses stream state (evidence: `app/main.py`)
- Exam and scan operations → Scan and exam database: reads and writes (evidence: `omr/service.py`)
- Exam and scan operations → Printable PDF: generates forms (evidence: `omr/service.py`)
- Exam and scan operations → Sheet layout: loads layouts (evidence: `omr/service.py`)
- Exam and scan operations → Sheet identity: applies identity policy (evidence: `omr/service.py`)
- Sheet recognition → Marker detection: detects markers (evidence: `omr/recognize.py`)
- Sheet recognition → Marker and header codec: decodes sheet header (evidence: `omr/recognize.py`)
- Sheet recognition → Sheet layout: resolves layout (evidence: `omr/recognize.py`)
- Sheet recognition → Page flattening: flattens sheet (evidence: `omr/recognize.py`)
- Sheet recognition → Lighting correction: corrects lighting (evidence: `omr/recognize.py`)
- Sheet recognition → Ink calibration: calibrates ink (evidence: `omr/recognize.py`)
- Frame stabilization → Frame fusion: fuses frames (evidence: `omr/stream.py`)
- Frame stabilization → Sheet identity: keys sheets (evidence: `omr/stream.py`)
- HTTP and camera API → Review image helpers: serves previews (evidence: `app/main.py`)
- Exam operator → Server review UI: reviews results (evidence: `README.md`)
- Exam operator → Scan detail UI: inspects scans (evidence: `README.md`)
- Standalone interface → Python browser bridge: requests recognition
- Pyodide worker → Python browser bridge: runs Python bridge
