# youchenjiang/clickra architecture

> Architecture diagram of the GitHub repository youchenjiang/clickra, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/youchenjiang/clickra
- Repository: https://github.com/youchenjiang/clickra

## Overview

1. **What this repository is**
   Clickra is a Windows 11-native context-menu utility suite built as a self-contained .NET NativeAOT product. The architecture is centered on shell integration plus local file-processing engines, not on a server or browser model.

2. **Top-level runtime boundary**
   The solution is split into three production projects:
   - **ClickraShell**: Windows Explorer integration
   - **Clickra.CLI**: the user-facing Win32/GDI+ UI entrypoints for dashboard and progress windows
   - **Clickra.Core**: all conversion, translation, compression, storage, and business logic  
   This separation is the main boundary to reflect in an architecture diagram.

3. **Shell integration layer**
   `ClickraShell` exposes the app to Explorer via manual COM plumbing. It contains COM methods, GUIDs, VTable/export helpers, and Win32 interop for registering and invoking context-menu commands. This layer is responsible for making Clickra appear as a modern Windows 11 submenu and is sensitive to shell-specific ABI details.

4. **UI layer: dashboard and progress windows**
   `Clickra.CLI` provides the native UI experience using Win32/GDI+ rather than a web or XAML stack. It has two main window families:
   - **DashboardWindow**: system readiness/status, settings, history, and feature overview
   - **ProgressWindow**: long-running job display, password input, tray integration, and process lifecycle  
   These are split into partial classes by responsibility, such as paint, events, state, hit testing, and lifecycle.

5. **Core processing boundary**
   `Clickra.Core` is the engine layer. It owns all file-processing orchestration and should be shown as the central processing box in the diagram. The UI and shell layers call into it, but it does not depend on Explorer or the windowing layer.

6. **File-processing framework**
   The core has a common processor hierarchy built around `SingleFileProcessorBase`, `MultiFileProcessorBase`, `IFileProcessor`, and `PostProcessor`. This framework handles common concerns like batching, cancellation, progress calculation, and cleanup across different file operations.

7. **Main operational pipelines**
   The core processors implement the product’s visible features:
   - Office documents to PDF: Word, Excel, PowerPoint processors
   - PDF merge
   - Image-to-PDF
   - Image stitching
   - PDF decrypt/removal of passwords
   - PDF compression
   - PDF translation  
   These are distinct processor paths, but they share the same orchestration and progress model.

8. **PDF translation subsystem**
   PDF translation is the most complex pipeline in the repo. It is staged into analysis, classification, masking, translation, and rewrite/render steps. Subsystems cover paragraphs, tables, diagrams, gray prompts, annotations, fonts, and layout analysis. A diagram should show this as a multi-stage pipeline rather than a single monolithic translator.

9. **Translation providers**
   The translation layer supports pluggable engines through `ITranslationEngine` and concrete implementations such as Google Free, MyMemory, identity, and fallback translators. This is a key external-boundary area because translation behavior depends on the selected engine and network availability, even though the rest of the app is local-first.

10. **Storage and history**
   `ClickraStorage` persists local app state such as active records and history. The README emphasizes a native list-view history experience, so storage should be shown as a local persistence subsystem backing the dashboard’s history and active-job tracking, not as cloud sync.

11. **Localization and font handling**
   The core includes localization helpers, Chinese text conversion, and font resolution. The UI layer also has localized font selection helpers. These pieces matter because the app supports multiple languages and handles PDF text rendering/rewriting across scripts.

12. **Native and external dependencies**
   The solution relies heavily on Windows-specific APIs and native desktop patterns: COM, Win32, GDI+, shell extension registration, and NativeAOT deployment. The product also includes LibreOffice-related installation/dispatch logic as a local fallback engine for Office-to-PDF conversion when Microsoft Office is unavailable.

13. **Packaging and release flow**
   Packaging is MSIX-based, with store assets and app manifest resources under `packaging/`. Release automation lives in GitHub Actions and helper scripts for building MSIX, version bumps, and Microsoft Store publishing. This is a separate distribution boundary from the runtime architecture.

14. **Validation and regression ecosystem**
   The repository includes a broad test and diagnostics toolchain:
   - .NET tests under `tests/Clickra.Core.Tests`
   - Python-based PDF regression and health checks under `tests/PdfRegression`
   - Diagnostic tools under `tools/pdf-diagnostics`  
   These are used to validate translation quality, layout behavior, mask coverage, compression, and shell-related edge cases.

15. **How the data flows end-to-end**
   A typical flow is: Explorer invokes a shell command → `ClickraShell` hands off to the UI entrypoint → `Clickra.CLI` shows dashboard or progress UI → `Clickra.Core` runs the selected processor → results are written locally, progress/history are updated, and the UI reflects completion. For translation and compression tasks, the pipeline may branch through analyzers, engine adapters, and post-processors before output is finalized.

Main entry points: [`src/Clickra.Core/Processors/PdfTranslation/PdfTranslationPipeline.cs`](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Processors/PdfTranslation/PdfTranslationPipeline.cs) (PDF translate), [`src/Clickra.CLI`](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.CLI) (Clickra.CLI), [`src/Clickra.Core`](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core) (Clickra.Core), [`src/Clickra.Core/Processors/FileProcessing/SingleFileProcessorBase.cs`](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Processors/FileProcessing/SingleFileProcessorBase.cs) (Processor base)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_clickra_shell["ClickraShell<br/>shell extension"]
  node_shell_com["COM plumbing<br/>interop<br/>[ComMethods.cs]"]
  node_shell_utils["Shell utils<br/>win32 interop<br/>[ShellUtils.cs]"]
  node_clickra_cli["Clickra.CLI<br/>native ui<br/>[Clickra.CLI]"]
  node_cli_entry["CLI entry<br/>bootstrap<br/>[ClickraCli.cs]"]
  node_dashboard_window["Dashboard<br/>window<br/>[DashboardWindow.cs]"]
  node_progress_window["Progress<br/>window<br/>[ProgressWindow.cs]"]
  node_clickra_core["Clickra.Core<br/>engine<br/>[Clickra.Core]"]
  node_processor_base["Processor base<br/>processing framework"]
  node_office_pdf["Office to PDF<br/>conversion pipeline"]
  node_pdf_ops["PDF ops<br/>document pipeline"]
  node_storage_history[("Storage & history<br/>local persistence<br/>[ClickraStorage.cs]")]
  node_localization_fonts["Localization & fonts<br/>render support"]
end

subgraph group_translation["PDF translation"]
  node_pdf_translate["PDF translate<br/>pipeline"]
  node_analysis_stage["Analysis stages<br/>analysis pipeline"]
  node_render_stage["Render stages<br/>rewrite pipeline"]
  node_translation_engines["Translation engines<br/>provider boundary"]
end

subgraph group_distribution["Distribution"]
  node_packaging_msix["MSIX packaging<br/>distribution<br/>[AppxManifest.xml]"]
  node_release_automation["Release automation<br/>ci/cd<br/>[build_msix.ps1]"]
end

subgraph group_validation["Validation"]
  node_core_tests["Core tests<br/>test suite<br/>[Program.cs]"]
  node_pdf_regression["PDF regression<br/>python tests"]
  node_pdf_diagnostics["Diagnostics<br/>analysis tools<br/>[pdf_health.py]"]
end

node_clickra_shell -->|"implements"| node_shell_com
node_clickra_shell -->|"uses"| node_shell_utils
node_clickra_shell -->|"launches"| node_clickra_cli
node_clickra_cli -->|"starts at"| node_cli_entry
node_clickra_cli -->|"shows"| node_dashboard_window
node_clickra_cli -->|"shows"| node_progress_window
node_clickra_cli -->|"calls"| node_clickra_core
node_dashboard_window -->|"reads/writes"| node_storage_history
node_progress_window -->|"updates"| node_storage_history
node_clickra_core -->|"orchestrates"| node_processor_base
node_processor_base -->|"drives"| node_office_pdf
node_processor_base -->|"drives"| node_pdf_ops
node_processor_base -->|"drives"| node_pdf_translate
node_pdf_translate -->|"analyzes"| node_analysis_stage
node_pdf_translate -->|"selects"| node_translation_engines
node_pdf_translate -->|"rewrites"| node_render_stage
node_pdf_translate -->|"depends on"| node_localization_fonts
node_clickra_core -->|"persists"| node_storage_history
node_clickra_core -->|"uses"| node_localization_fonts
node_packaging_msix -->|"published by"| node_release_automation
node_core_tests -->|"validates"| node_clickra_core
node_pdf_regression -->|"validates"| node_pdf_translate
node_pdf_diagnostics -->|"inspects"| node_pdf_translate

click node_clickra_shell "https://github.com/youchenjiang/clickra/tree/main/src/ClickraShell"
click node_shell_com "https://github.com/youchenjiang/clickra/blob/main/src/ClickraShell/ComMethods.cs"
click node_shell_utils "https://github.com/youchenjiang/clickra/blob/main/src/ClickraShell/ShellUtils.cs"
click node_clickra_cli "https://github.com/youchenjiang/clickra/blob/main/src/Clickra.CLI"
click node_cli_entry "https://github.com/youchenjiang/clickra/blob/main/src/Clickra.CLI/Cli/ClickraCli.cs"
click node_dashboard_window "https://github.com/youchenjiang/clickra/blob/main/src/Clickra.CLI/Dashboard/DashboardWindow.cs"
click node_progress_window "https://github.com/youchenjiang/clickra/blob/main/src/Clickra.CLI/Progress/ProgressWindow.cs"
click node_clickra_core "https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core"
click node_processor_base "https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Processors/FileProcessing/SingleFileProcessorBase.cs"
click node_office_pdf "https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Processors/ExcelToPdfProcessor.cs"
click node_pdf_ops "https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Processors/FileProcessing/PdfMergeProcessor.cs"
click node_pdf_translate "https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Processors/PdfTranslation/PdfTranslationPipeline.cs"
click node_analysis_stage "https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Processors/PdfTranslation/Paragraphs/PdfParagraphAnalysis.cs"
click node_render_stage "https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Processors/PdfTranslation/Rendering/PdfRewrite/PdfTranslatedPdfRebuilder.cs"
click node_translation_engines "https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Translation/TranslationEngineFactory.cs"
click node_storage_history "https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Storage/ClickraStorage.cs"
click node_localization_fonts "https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Localization/ChineseTextConverter.cs"
click node_packaging_msix "https://github.com/youchenjiang/clickra/blob/main/packaging/msix/AppxManifest.xml"
click node_release_automation "https://github.com/youchenjiang/clickra/blob/main/scripts/build_msix.ps1"
click node_core_tests "https://github.com/youchenjiang/clickra/blob/main/tests/Clickra.Core.Tests/Program.cs"
click node_pdf_regression "https://github.com/youchenjiang/clickra/blob/main/tests/PdfRegression/run_translation_tests.py"
click node_pdf_diagnostics "https://github.com/youchenjiang/clickra/blob/main/tools/pdf-diagnostics/pdf_health.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_clickra_shell,node_shell_com,node_shell_utils,node_clickra_cli,node_cli_entry,node_dashboard_window,node_progress_window,node_clickra_core,node_processor_base,node_office_pdf,node_pdf_ops,node_storage_history,node_localization_fonts toneBlue
class node_pdf_translate,node_analysis_stage,node_render_stage,node_translation_engines toneAmber
class node_packaging_msix,node_release_automation toneMint
class node_core_tests,node_pdf_regression,node_pdf_diagnostics toneRose
```

## Components

### Runtime

Production runtime boundary: shell integration, native UI, and core processing.

- [ClickraShell](https://github.com/youchenjiang/clickra/tree/main/src/ClickraShell): shell extension · Explorer-facing COM shell integration and command registration layer. · `src/ClickraShell`
- [COM plumbing](https://github.com/youchenjiang/clickra/blob/main/src/ClickraShell/ComMethods.cs): interop · Manual COM methods, GUIDs, exports, and shell ABI helpers. · `src/ClickraShell/ComMethods.cs`
- [Shell utils](https://github.com/youchenjiang/clickra/blob/main/src/ClickraShell/ShellUtils.cs): win32 interop · Kernel32 and shell helper glue used by the extension. · `src/ClickraShell/ShellUtils.cs`
- [Clickra.CLI](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.CLI): native ui · Native Win32/GDI+ entrypoint for dashboard and progress windows. · `src/Clickra.CLI`
- [CLI entry](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.CLI/Cli/ClickraCli.cs): bootstrap · Argument parsing and deployment entrypoint for the native app. · `src/Clickra.CLI/Cli/ClickraCli.cs`
- [Dashboard](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.CLI/Dashboard/DashboardWindow.cs): window · Readiness, settings, history, and feature overview window. · `src/Clickra.CLI/Dashboard/DashboardWindow.cs`
- [Progress](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.CLI/Progress/ProgressWindow.cs): window · Long-running job window with password input, tray integration, and lifecycle control. · `src/Clickra.CLI/Progress/ProgressWindow.cs`
- [Clickra.Core](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core): engine · Core processing engine for conversion, compression, translation, storage, and localization. · `src/Clickra.Core`
- [Processor base](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Processors/FileProcessing/SingleFileProcessorBase.cs): processing framework · Shared file-processing hierarchy with batching, cancellation, progress, and cleanup. · `src/Clickra.Core/Processors/FileProcessing/SingleFileProcessorBase.cs`
- [Office to PDF](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Processors/ExcelToPdfProcessor.cs): conversion pipeline · Word, Excel, and PowerPoint conversion processors. · `src/Clickra.Core/Processors/ExcelToPdfProcessor.cs`
- [PDF ops](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Processors/FileProcessing/PdfMergeProcessor.cs): document pipeline · Merge, decrypt, compress, and image-to-PDF processing paths. · `src/Clickra.Core/Processors/FileProcessing/PdfMergeProcessor.cs`
- [Storage & history](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Storage/ClickraStorage.cs): local persistence · Local active-record and history persistence backing dashboard state and job tracking. · `src/Clickra.Core/Storage/ClickraStorage.cs`
- [Localization & fonts](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Localization/ChineseTextConverter.cs): render support · Chinese text conversion, localization helpers, and font resolution for UI and PDF text handling. · `src/Clickra.Core/Localization/ChineseTextConverter.cs`

### PDF translation

Multi-stage translation pipeline for PDF analysis, masking, translation, and rewrite.

- [PDF translate](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Processors/PdfTranslation/PdfTranslationPipeline.cs): pipeline · End-to-end PDF translation pipeline orchestrating analysis, masking, translation, and rewrite. · `src/Clickra.Core/Processors/PdfTranslation/PdfTranslationPipeline.cs`
- [Analysis stages](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Processors/PdfTranslation/Paragraphs/PdfParagraphAnalysis.cs): analysis pipeline · Paragraph, table, diagram, annotation, gray-prompt, and layout classification stages. · `src/Clickra.Core/Processors/PdfTranslation/Paragraphs/PdfParagraphAnalysis.cs`
- [Render stages](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Processors/PdfTranslation/Rendering/PdfRewrite/PdfTranslatedPdfRebuilder.cs): rewrite pipeline · Mask planning, translated paragraph rendering, and PDF rebuild/rewrite stages. · `src/Clickra.Core/Processors/PdfTranslation/Rendering/PdfRewrite/PdfTranslatedPdfRebuilder.cs`
- [Translation engines](https://github.com/youchenjiang/clickra/blob/main/src/Clickra.Core/Translation/TranslationEngineFactory.cs): provider boundary · Pluggable translation engines including Google Free, MyMemory, identity, and fallback. · `src/Clickra.Core/Translation/TranslationEngineFactory.cs`

### Distribution

Packaging, manifests, and release automation.

- [MSIX packaging](https://github.com/youchenjiang/clickra/blob/main/packaging/msix/AppxManifest.xml): distribution · MSIX manifest, app assets, and store resource packaging. · `packaging/msix/AppxManifest.xml`
- [Release automation](https://github.com/youchenjiang/clickra/blob/main/scripts/build_msix.ps1): ci/cd · Build, versioning, and Microsoft Store publishing automation. · `scripts/build_msix.ps1`

### Validation

Tests and diagnostics used to verify core behavior and regressions.

- [Core tests](https://github.com/youchenjiang/clickra/blob/main/tests/Clickra.Core.Tests/Program.cs): test suite · .NET regression suites for layout, compression, translation, and LibreOffice flows. · `tests/Clickra.Core.Tests/Program.cs`
- [PDF regression](https://github.com/youchenjiang/clickra/blob/main/tests/PdfRegression/run_translation_tests.py): python tests · PDF health, masking, quality, and translation end-to-end regression checks. · `tests/PdfRegression/run_translation_tests.py`
- [Diagnostics](https://github.com/youchenjiang/clickra/blob/main/tools/pdf-diagnostics/pdf_health.py): analysis tools · PDF inspection and visual-diff tooling used to validate translation output and layout behavior. · `tools/pdf-diagnostics/pdf_health.py`

## Connections

- ClickraShell → COM plumbing: implements · Shell extension is built on manual COM plumbing.
- ClickraShell → Shell utils: uses · Shell integration depends on Win32 and shell helper utilities.
- ClickraShell → Clickra.CLI: launches · Explorer commands hand off to the native UI entrypoint.
- Clickra.CLI → CLI entry: starts at · CLI project begins with argument/deployment bootstrap.
- Clickra.CLI → Dashboard: shows · Dashboard window presents readiness, history, and settings.
- Clickra.CLI → Progress: shows · Progress window tracks long-running jobs and tray lifecycle.
- Clickra.CLI → Clickra.Core: calls · UI entrypoints invoke core processors.
- Dashboard → Storage & history: reads/writes · Dashboard history and status are backed by local storage.
- Progress → Storage & history: updates · Progress UI reflects active records and job state persistence.
- Clickra.Core → Processor base: orchestrates · Core processing builds on the shared processor framework.
- Processor base → Office to PDF: drives · Shared batching and lifecycle logic drive Office-to-PDF converters.
- Processor base → PDF ops: drives · Shared batching and lifecycle logic drive PDF operation processors.
- Processor base → PDF translate: drives · Shared batching and lifecycle logic drive translation jobs.
- PDF translate → Analysis stages: analyzes · Translation pipeline first extracts structure and classifies content.
- PDF translate → Translation engines: selects · Pipeline delegates text generation to pluggable engines.
- PDF translate → Render stages: rewrites · Pipeline finishes by masking, rendering, and rebuilding output PDFs.
- PDF translate → Localization & fonts: depends on · Translation and rendering rely on text normalization and font handling.
- Clickra.Core → Storage & history: persists · Core updates active records and history locally.
- Clickra.Core → Localization & fonts: uses · Core shares localization and font resolution helpers.
- MSIX packaging → Release automation: published by · MSIX artifacts are built and published by release scripts.
- Core tests → Clickra.Core: validates · Unit and regression suites cover core processors and engine behavior.
- PDF regression → PDF translate: validates · Python regression suite exercises translation quality and output health.
- Diagnostics → PDF translate: inspects · Diagnostics tools analyze translation artifacts, layout, and masks.
