# egrqwertyuio/label-station architecture

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

- Interactive diagram: https://gitdiagram.com/egrqwertyuio/label-station
- Repository: https://github.com/egrqwertyuio/label-station

## Overview

Label Station is an offline Flask appliance for composing and printing TSPL2 labels. A user opens the web interface, fills a built-in or uploaded custom template, or uploads a spreadsheet for column mapping and row review; approved jobs are compiled and sent to a USB printer, with preview and status handling. The designer creates template files on the user's computer, while the station keeps uploaded templates in memory. The source index supports the main module dependencies; unsampled routes and browser interactions are represented only where the README or excerpts document them.

Main entry points: [`app.py`](https://github.com/egrqwertyuio/label-station/blob/main/app.py) (Flask web app), [`tspl.py`](https://github.com/egrqwertyuio/label-station/blob/main/tspl.py) (TSPL2 job compiler), [`custom_templates.py`](https://github.com/egrqwertyuio/label-station/blob/main/custom_templates.py) (Custom template validation), [`printer.py`](https://github.com/egrqwertyuio/label-station/blob/main/printer.py) (Printer transport and status)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["Flask web app<br/>[app.py]"]
  node_webui["Web pages and scripts"]
  node_designer["Browser label designer<br/>[designer.js]"]
end

subgraph group_input["Templates and input"]
  node_builtin["Built-in templates<br/>[templates_def.py]"]
  node_custom["Custom template validation"]
  node_sheets["Spreadsheet reading and mapping<br/>[sheets.py]"]
end

subgraph group_jobs["Job processing"]
  node_batch["Batch review and runner<br/>[batch.py]"]
  node_config["Print configuration<br/>[config.py]"]
  node_engine["TSPL2 job compiler<br/>[tspl.py]"]
  node_text["TrueType text rasterizer<br/>[textraster.py]"]
  node_images["Image bitmap conversion<br/>[logo_tool.py]"]
  node_qr["QR bitmap encoder<br/>[qr_tool.py]"]
end

subgraph group_output["Rendering and printing"]
  node_preview["Job preview renderer<br/>[preview.py]"]
  node_printer["Printer transport and status<br/>[printer.py]"]
  node_device[("TSPL2 thermal printer")]
end

node_user(("Phone or laptop user"))

node_user -->|"uses"| node_webapp
node_webapp -->|"renders pages"| node_webui
node_webapp -->|"selects template"| node_builtin
node_user -->|"designs labels"| node_designer
node_designer -->|"uploads template"| node_custom
node_webapp -->|"validates upload"| node_custom
node_webapp -->|"reads upload"| node_sheets
node_sheets -->|"maps fields"| node_builtin
node_webapp -->|"builds and runs review"| node_batch
node_batch -->|"builds jobs"| node_engine
node_batch -->|"sends and waits"| node_printer
node_webapp -->|"builds jobs"| node_engine
node_webapp -->|"dispatches print"| node_printer
node_webapp -->|"loads settings"| node_config
node_batch -->|"loads settings"| node_config
node_engine -->|"validates geometry"| node_config
node_engine -->|"compiles template"| node_builtin
node_custom -->|"creates template objects"| node_builtin
node_engine -->|"rasterizes text"| node_text
node_engine -->|"converts pictures"| node_images
node_engine -->|"encodes QR"| node_qr
node_custom -->|"validates QR content"| node_qr
node_custom -->|"uses text rasterizer"| node_text
node_webapp -->|"renders preview"| node_preview
node_printer -->|"renders mock output"| node_preview
node_printer -->|"transports job bytes"| node_engine
node_printer -->|"writes TSPL2"| node_device

click node_webapp "https://github.com/egrqwertyuio/label-station/blob/main/app.py"
click node_webui "https://github.com/egrqwertyuio/label-station/tree/main/templates"
click node_designer "https://github.com/egrqwertyuio/label-station/blob/main/static/designer.js"
click node_builtin "https://github.com/egrqwertyuio/label-station/blob/main/templates_def.py"
click node_custom "https://github.com/egrqwertyuio/label-station/blob/main/custom_templates.py"
click node_sheets "https://github.com/egrqwertyuio/label-station/blob/main/sheets.py"
click node_batch "https://github.com/egrqwertyuio/label-station/blob/main/batch.py"
click node_config "https://github.com/egrqwertyuio/label-station/blob/main/config.py"
click node_engine "https://github.com/egrqwertyuio/label-station/blob/main/tspl.py"
click node_text "https://github.com/egrqwertyuio/label-station/blob/main/textraster.py"
click node_images "https://github.com/egrqwertyuio/label-station/blob/main/logo_tool.py"
click node_qr "https://github.com/egrqwertyuio/label-station/blob/main/qr_tool.py"
click node_preview "https://github.com/egrqwertyuio/label-station/blob/main/preview.py"
click node_printer "https://github.com/egrqwertyuio/label-station/blob/main/printer.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_webapp,node_webui,node_designer,node_user toneBlue
class node_builtin,node_custom,node_sheets toneAmber
class node_batch,node_config,node_engine,node_text,node_images,node_qr toneMint
class node_preview,node_printer,node_device toneRose
```

## Components

### Web experience

- [Flask web app](https://github.com/egrqwertyuio/label-station/blob/main/app.py): `app.py`
- [Web pages and scripts](https://github.com/egrqwertyuio/label-station/tree/main/templates): `templates`
- [Browser label designer](https://github.com/egrqwertyuio/label-station/blob/main/static/designer.js): `static/designer.js`

### Templates and input

- [Built-in templates](https://github.com/egrqwertyuio/label-station/blob/main/templates_def.py): `templates_def.py`
- [Custom template validation](https://github.com/egrqwertyuio/label-station/blob/main/custom_templates.py): `custom_templates.py`
- [Spreadsheet reading and mapping](https://github.com/egrqwertyuio/label-station/blob/main/sheets.py): `sheets.py`

### Job processing

- [Batch review and runner](https://github.com/egrqwertyuio/label-station/blob/main/batch.py): `batch.py`
- [Print configuration](https://github.com/egrqwertyuio/label-station/blob/main/config.py): `config.py`
- [TSPL2 job compiler](https://github.com/egrqwertyuio/label-station/blob/main/tspl.py): `tspl.py`
- [TrueType text rasterizer](https://github.com/egrqwertyuio/label-station/blob/main/textraster.py): `textraster.py`
- [Image bitmap conversion](https://github.com/egrqwertyuio/label-station/blob/main/logo_tool.py): `logo_tool.py`
- [QR bitmap encoder](https://github.com/egrqwertyuio/label-station/blob/main/qr_tool.py): `qr_tool.py`

### Rendering and printing

- [Job preview renderer](https://github.com/egrqwertyuio/label-station/blob/main/preview.py): `preview.py`
- [Printer transport and status](https://github.com/egrqwertyuio/label-station/blob/main/printer.py): `printer.py`
- **TSPL2 thermal printer**

### Other components

- **Phone or laptop user**

## Connections

- Phone or laptop user → Flask web app: uses
- Flask web app → Web pages and scripts: renders pages (evidence: `app.py`)
- Flask web app → Built-in templates: selects template (evidence: `app.py`)
- Phone or laptop user → Browser label designer: designs labels
- Browser label designer → Custom template validation: uploads template
- Flask web app → Custom template validation: validates upload (evidence: `app.py`)
- Flask web app → Spreadsheet reading and mapping: reads upload (evidence: `app.py`)
- Spreadsheet reading and mapping → Built-in templates: maps fields (evidence: `sheets.py`)
- Flask web app → Batch review and runner: builds and runs review (evidence: `app.py`)
- Batch review and runner → TSPL2 job compiler: builds jobs (evidence: `batch.py`)
- Batch review and runner → Printer transport and status: sends and waits (evidence: `batch.py`)
- Flask web app → TSPL2 job compiler: builds jobs (evidence: `app.py`)
- Flask web app → Printer transport and status: dispatches print (evidence: `app.py`)
- Flask web app → Print configuration: loads settings (evidence: `app.py`)
- Batch review and runner → Print configuration: loads settings (evidence: `batch.py`)
- TSPL2 job compiler → Print configuration: validates geometry (evidence: `tspl.py`)
- TSPL2 job compiler → Built-in templates: compiles template (evidence: `tspl.py`)
- Custom template validation → Built-in templates: creates template objects (evidence: `custom_templates.py`)
- TSPL2 job compiler → TrueType text rasterizer: rasterizes text (evidence: `tspl.py`)
- TSPL2 job compiler → Image bitmap conversion: converts pictures (evidence: `tspl.py`)
- TSPL2 job compiler → QR bitmap encoder: encodes QR (evidence: `tspl.py`)
- Custom template validation → QR bitmap encoder: validates QR content (evidence: `custom_templates.py`)
- Custom template validation → TrueType text rasterizer: uses text rasterizer (evidence: `custom_templates.py`)
- Flask web app → Job preview renderer: renders preview (evidence: `app.py`)
- Printer transport and status → Job preview renderer: renders mock output (evidence: `printer.py`)
- Printer transport and status → TSPL2 job compiler: transports job bytes (evidence: `printer.py`)
- Printer transport and status → TSPL2 thermal printer: writes TSPL2 (evidence: `printer.py`)
