# cicag/kalibret architecture

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

- Interactive diagram: https://gitdiagram.com/cicag/kalibret
- Repository: https://github.com/cicag/kalibret

## Overview

Kalibret is a fullscreen GTK touchscreen calibration and testing GUI. An operator configures the input device, runs five-point calibration or starts free-draw testing, reviews the result, and can generate udev rules for manual installation or use Revert to remove the generated rules. The GUI also records free-draw strokes and calibration artifacts under data/. The main implementation is concentrated in kalibret.py; the supplied excerpts show configuration loading and some persistence, while feature relationships noted only in the README are cited there.

Main entry points: [`kalibret.py`](https://github.com/cicag/kalibret/blob/main/kalibret.py) (Five-point calibration), [`kalibret.conf`](https://github.com/cicag/kalibret/blob/main/kalibret.conf) (Device configuration), [`udev/99-kalibret-touchscreen.rules`](https://github.com/cicag/kalibret/blob/main/udev/99-kalibret-touchscreen.rules) (Generated udev rule), [`data/last-draw.json`](https://github.com/cicag/kalibret/blob/main/data/last-draw.json) (Draw log)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Device setup"]
  node_device_config["Device configuration<br/>[kalibret.conf]"]
  node_config_loader["Config loading<br/>[kalibret.py]"]
  node_gui_entry["GUI entry<br/>[kalibret.py]"]
end

subgraph group_interaction["Touch workflows"]
  node_touch_events["Touch interaction<br/>[kalibret.py]"]
  node_free_draw["Free draw testing<br/>[kalibret.py]"]
  node_calibration["Five-point calibration<br/>[kalibret.py]"]
  node_result_view["Calibration result<br/>[kalibret.py]"]
end

subgraph group_artifacts["Saved results"]
  node_draw_log["Draw log<br/>[last-draw.json]"]
  node_calibration_data["Calibration backups"]
  node_rule_generator["Udev rule generator<br/>[kalibret.py]"]
  node_rule_file["Generated udev rule"]
end

node_operator(("Operator"))
node_touchscreen["Touchscreen"]
node_display["Display session"]
node_udev["System udev rules"]

node_operator -->|"sets device"| node_device_config
node_config_loader -->|"reads settings"| node_device_config
node_operator -->|"launches GUI"| node_gui_entry
node_gui_entry -->|"shows GUI"| node_display
node_touchscreen -.->|"provides touches"| node_touch_events
node_touch_events -->|"records strokes"| node_free_draw
node_free_draw -->|"writes log"| node_draw_log
node_operator -->|"starts draw mode"| node_free_draw
node_touch_events -->|"collects taps"| node_calibration
node_operator -->|"taps targets"| node_calibration
node_calibration -->|"shows result"| node_result_view
node_calibration -->|"saves samples"| node_calibration_data
node_result_view -->|"requests apply"| node_rule_generator
node_rule_generator -->|"writes rules"| node_rule_file
node_operator -->|"copies manually"| node_rule_file
node_operator -->|"reverts rules"| node_rule_generator
node_operator -->|"reloads rules"| node_udev

click node_device_config "https://github.com/cicag/kalibret/blob/main/kalibret.conf"
click node_config_loader "https://github.com/cicag/kalibret/blob/main/kalibret.py"
click node_gui_entry "https://github.com/cicag/kalibret/blob/main/kalibret.py"
click node_touch_events "https://github.com/cicag/kalibret/blob/main/kalibret.py"
click node_free_draw "https://github.com/cicag/kalibret/blob/main/kalibret.py"
click node_draw_log "https://github.com/cicag/kalibret/blob/main/data/last-draw.json"
click node_calibration "https://github.com/cicag/kalibret/blob/main/kalibret.py"
click node_result_view "https://github.com/cicag/kalibret/blob/main/kalibret.py"
click node_calibration_data "https://github.com/cicag/kalibret/tree/main/data"
click node_rule_generator "https://github.com/cicag/kalibret/blob/main/kalibret.py"
click node_rule_file "https://github.com/cicag/kalibret/blob/main/udev/99-kalibret-touchscreen.rules"

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_device_config,node_config_loader,node_gui_entry,node_touchscreen toneBlue
class node_touch_events,node_free_draw,node_calibration,node_result_view toneAmber
class node_draw_log,node_calibration_data,node_rule_generator,node_rule_file toneMint
class node_operator,node_display,node_udev toneIndigo
```

## Components

### Device setup

- [Device configuration](https://github.com/cicag/kalibret/blob/main/kalibret.conf): `kalibret.conf`
- [Config loading](https://github.com/cicag/kalibret/blob/main/kalibret.py): `kalibret.py`
- [GUI entry](https://github.com/cicag/kalibret/blob/main/kalibret.py): `kalibret.py`

### Touch workflows

- [Touch interaction](https://github.com/cicag/kalibret/blob/main/kalibret.py): `kalibret.py`
- [Free draw testing](https://github.com/cicag/kalibret/blob/main/kalibret.py): `kalibret.py`
- [Five-point calibration](https://github.com/cicag/kalibret/blob/main/kalibret.py): `kalibret.py`
- [Calibration result](https://github.com/cicag/kalibret/blob/main/kalibret.py): `kalibret.py`

### Saved results

- [Draw log](https://github.com/cicag/kalibret/blob/main/data/last-draw.json): `data/last-draw.json`
- [Calibration backups](https://github.com/cicag/kalibret/tree/main/data): `data`
- [Udev rule generator](https://github.com/cicag/kalibret/blob/main/kalibret.py): `kalibret.py`
- [Generated udev rule](https://github.com/cicag/kalibret/blob/main/udev/99-kalibret-touchscreen.rules): `udev/99-kalibret-touchscreen.rules`

### Other components

- **Operator**
- **Touchscreen**
- **Display session**
- **System udev rules**

## Connections

- Operator → Device configuration: sets device (evidence: `README.md`)
- Config loading → Device configuration: reads settings (evidence: `kalibret.py`)
- Operator → GUI entry: launches GUI (evidence: `README.md`)
- GUI entry → Display session: shows GUI (evidence: `README.md`)
- Touchscreen → Touch interaction: provides touches
- Touch interaction → Free draw testing: records strokes (evidence: `kalibret.py`)
- Free draw testing → Draw log: writes log (evidence: `kalibret.py`)
- Operator → Free draw testing: starts draw mode (evidence: `README.md`)
- Touch interaction → Five-point calibration: collects taps (evidence: `README.md`)
- Operator → Five-point calibration: taps targets (evidence: `README.md`)
- Five-point calibration → Calibration result: shows result (evidence: `README.md`)
- Five-point calibration → Calibration backups: saves samples (evidence: `kalibret.py`)
- Calibration result → Udev rule generator: requests apply (evidence: `README.md`)
- Udev rule generator → Generated udev rule: writes rules (evidence: `kalibret.py`)
- Operator → Generated udev rule: copies manually (evidence: `README.md`)
- Operator → Udev rule generator: reverts rules (evidence: `README.md`)
- Operator → System udev rules: reloads rules (evidence: `README.md`)
