Service layers first, TUI second
The Rust application follows an orchestrated-state pattern: config and transport live below the service layer, and the TUI renders state instead of owning business logic.
System shape
config: durable configuration, session persistence, output selectionapi: transport abstraction, request construction, error mappingservices: Paperless workflows as domain operationssecurity: a continuously polling reviewer feeding findings back to the apptui: Ratatui layout that renders staterender: Markdown and JSON emitters for non-interactive use
Compatibility placement
Compatibility commands such as document content, tag edit, config set-url, and pdf read/info stay thin adapters over the same config and service foundations rather than forming a second architecture.
Output modes
- TUI: default interactive mode, with document list, inspector, latest task, and security state.
- Markdown: text-first commands return plain extracted text; structured responses render as tables or summaries.
- JSON:
OutputEnvelopewithmode,command,data, andsecurity.