BlueGit

timfa posprint

Files

posprint / .cursor / rules / architecture.mdc

architecture.mdc

feat: include paired Classic Bluetooth SPP printers in discovery
timfa project_84475926_bot_3b4fb417c41b9b24a7422b6452f025d2 · pushed by timfa · 8 weeks ago
8b514b7f History
architecture.mdc 1.9 KiB Download Raw
1---
2description: posprint architecture and stack conventions
3globs: src/**/*
4alwaysApply: 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
28Keep business logic out of `app.rs` where possible — UI should call `lib` modules.
29
30## Dependencies
31
32Add 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
36Do **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
45BLE, 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).