| 1 | ---
|
| 2 | description: posprint architecture and stack conventions
|
| 3 | globs: src/**/*
|
| 4 | alwaysApply: true
|
| 5 | ---
|
| 6 |
|
| 7 | # Architecture rules
|
| 8 |
|
| 9 | ## Stack (do not change without updating docs)
|
| 10 |
|
| 11 | - **Rust only** — no TypeScript/JavaScript frontend.
|
| 12 | - **egui / eframe** for UI (`src/app.rs`, `src/main.rs`).
|
| 13 | - **Printing:** USB printer-class (`rusb`), Windows spooler (Windows), USB-serial, and OS-paired Classic Bluetooth SPP (`serialport`) via `src/print/`.
|
| 14 |
|
| 15 | ## Module responsibilities
|
| 16 |
|
| 17 | | Module | Responsibility |
|
| 18 | |--------|----------------|
|
| 19 | | `dsl/` | Parse template text → `Document` AST |
|
| 20 | | `params.rs` | Collect `${Name}` tokens; substitute at print / preview |
|
| 21 | | `escpos.rs` | AST → ESC/POS bytes (in-tree; no `escpos` crate) |
|
| 22 | | `preview.rs` | AST → `PreviewModel` for UI canvas |
|
| 23 | | `io/` | `PosFile` JSON load/save |
|
| 24 | | `print/` | Discovery + transports (USB-direct, spooler, serial, mock) |
|
| 25 | | `print_dialog.rs` | Shared print UI |
|
| 26 | | `app.rs` | Full designer egui UI |
|
| 27 |
|
| 28 | Keep business logic out of `app.rs` where possible — UI should call `lib` modules.
|
| 29 |
|
| 30 | ## Dependencies
|
| 31 |
|
| 32 | Add a crate only when hand-rolling is unreasonable. Current set includes:
|
| 33 |
|
| 34 | - `eframe`, `serde`, `serde_json`, `serialport`, `rusb`, `image`, `rfd`, `barcoders`, `qrcode`, `clap`, `chrono`
|
| 35 |
|
| 36 | Do **not** add `escpos`, `nusb`, `tauri`, or a JS toolchain without a deliberate stack change and doc update.
|
| 37 |
|
| 38 | ## Preview vs print
|
| 39 |
|
| 40 | - **Preview:** layout from shared wrap; bitmaps for image/barcode/QR; sample or dialog params for `${Param}`.
|
| 41 | - **Print:** substitute parameters, encode ESC/POS, write via the chosen transport (serial baud is probed).
|
| 42 |
|
| 43 | ## Planned features (not in codebase yet)
|
| 44 |
|
| 45 | BLE, network TCP 9100, persisted recent files/parameters, syntax highlighting. Document these only under "Planned" sections — do not implement stubs without a task. Classic Bluetooth SPP after OS pairing is implemented (no BLE/GATT).
|