Skip to content

Latest commit

 

History

History
61 lines (48 loc) · 2.31 KB

File metadata and controls

61 lines (48 loc) · 2.31 KB

Architecture

Magic Mirror is a two-layer application.

Web layer - MagicMirror/

The web layer is a Cepha / NetWasmMvc.SDK application: ASP.NET MVC runs inside a WebAssembly worker. Controllers and Razor views remain the source of business logic and rendering; the browser main thread is only a display surface.

Responsibilities:

  • Settings UI and Cepha Material UI pages.
  • Sarmad AI gateway contract.
  • Cloudflare Pages deployment target for a supported Workers AI model such as @cf/openai/gpt-oss-20b.

Native layer - MagicMirror.Native/

The native layer is a .NET MAUI Windows-first host that renders the Cepha MVC layer in-process and provides native OS capabilities.

Responsibilities:

  • Transparent always-on-top overlay window.
  • Screen capture behind the overlay, with self-capture exclusion.
  • UI Automation text extraction.
  • Tesseract and Windows.Media.Ocr OCR.
  • Font/style inference.
  • Translation orchestration with Sarmad-first provenance and explicit MT fallback gating.
  • Document-like translated rendering with Arabic RTL/LTR handling.
  • Native transparent editor and detachable reader surfaces for stable selection, copy, wrapping, and dictionary context menus.

Runtime pipeline

Overlay region
  -> screen capture / UI Automation text
  -> OCR fallback
  -> row and paragraph merge
  -> font role/style inference
  -> Sarmad AI translation
  -> explicit whole-capture MT fallback only when the user confirms it
  -> document layout normalization
  -> native transparent editor / detached reader
  -> rendered hit regions and OCR-block provenance for dictionary selection

Selection and dictionary design

Dictionary selection uses actual canvas-space hit regions generated by MirrorDrawable while drawing the translated document. This avoids mismatches between raw OCR boxes and the final rendered text after scroll, wrapping, target-direction alignment, and reader-page layout. Source OCR boxes are also registered as fallback hit regions, so clicking visible original text remains usable when translation text has been normalized into the target-language column. Reader/editor selections are mapped back to their owning TranslatedBlock, and the dictionary proof tab separates technical OCR/Merkle provenance from the linguistic answer to avoid mixing audit details with the glossary result.