BlueGit

timfa posprint

Files

posprint / .cursor / rules / architecture.mdc

architecture.mdc

architecture.mdc 1.8 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- **USB-serial printing only** — `src/print/mod.rs` via `serialport`. No Bluetooth or USB printer-class code until explicitly requested.
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 time |
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/` | Port enumeration, `SerialTransport`, `MockTransport` |
25| `app.rs` | All egui UI: editor, preview, help, print dialog |
26
27Keep business logic out of `app.rs` where possible — UI should call `lib` modules.
28
29## Dependencies
30
31Add a crate only when hand-rolling is unreasonable. Current allowed set:
32
33- `eframe`, `serde`, `serde_json`, `serialport`, `image`, `rfd`
34
35Do **not** add `escpos`, `nusb`, `tauri`, or a JS toolchain without a deliberate stack change and doc update.
36
37## Preview vs print
38
39- **Preview:** approximate layout; placeholders for barcode/QR/image; unresolved `${Param}` shown literally.
40- **Print:** substitute parameters first, then encode ESC/POS, then write to serial port at **9600 baud**.
41
42## Planned features (not in codebase yet)
43
44USB printer class, Bluetooth, baud autodetect, persisted recent files/parameters, syntax highlighting. Document these only under "Planned" sections — do not implement stubs without a task.