Architecture

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

  1. config: durable configuration, session persistence, output selection
  2. api: transport abstraction, request construction, error mapping
  3. services: Paperless workflows as domain operations
  4. security: a continuously polling reviewer feeding findings back to the app
  5. tui: Ratatui layout that renders state
  6. render: 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: OutputEnvelope with mode, command, data, and security.