# elcanion/cornojoblesscertificatemanager architecture

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

- Interactive diagram: https://gitdiagram.com/elcanion/cornojoblesscertificatemanager
- Repository: https://github.com/elcanion/cornojoblesscertificatemanager

## Overview

1. **Overall shape**
   - This is a **.NET 8, Windows-only certificate management tool**.
   - The main shipped experience is a **WPF desktop app** (`CornojoblessCertificateManager.UI`), backed by a reusable **core library** (`CornojoblessCertificateManager.Core`).
   - There is also a **console project** (`CornojoblessCertificateManager.Console`), but the README only documents the WPF app, so the console host’s role is not clearly described in the snapshot.

2. **Primary architectural boundary**
   - The code is split into a **presentation layer** and a **certificate-processing layer**.
   - The UI project handles windows, dialogs, view models, and user interaction.
   - The Core project contains the business logic for querying, filtering, backing up, and deleting certificates.

3. **Domain model and configuration**
   - `CertificateInfo` represents certificate data surfaced to the UI and service layer.
   - `CertificateSettings` maps runtime configuration, including issuer-related filtering rules loaded from `appsettings.json`.
   - This makes issuer filtering configurable without recompiling the app.

4. **Certificate query/filter flow**
   - `CertificateQuery` is the central query object used to describe what certificates should be listed or acted on.
   - The README indicates filtering by **issuer**, **expired certificates**, and **exportable certificates**.
   - The architecture suggests the UI builds a query, passes it to the service, and receives a filtered certificate list for display or selection.

5. **Action requests**
   - The Core layer uses explicit request objects for mutating operations:
     - `CertificateBackupRequest`
     - `CertificateDeleteRequest`
   - This separates “what the user wants to do” from the service implementation and keeps backup/delete workflows distinct.

6. **Service layer**
   - `ICertificateService` defines the main contract for certificate operations.
   - `CertificateService` likely orchestrates:
     - reading from Windows certificate stores,
     - applying filters,
     - exporting backup files,
     - deleting certificates.
   - This is the main application logic boundary between UI and the Windows certificate APIs.

7. **Certificate utilities**
   - `CertificateUtils` holds shared helper logic around certificate handling.
   - In this kind of design, utilities typically support common checks and transformations used by the service and query logic, keeping the service class focused on orchestration.

8. **UI composition**
   - `MainWindow.xaml` and `MainWindowViewModel` form the main MVVM entry point.
   - `RelayCommand` provides command binding for user actions such as refresh, backup, delete, and filtering.
   - The UI also includes confirmation dialogs:
     - `DialogConfirmBackup`
     - `DialogConfirmDelete`
   - These dialogs create an explicit safety boundary before destructive operations.

9. **WPF-specific interaction details**
   - `DataGridSelectedItemsBehavior` indicates the UI uses a `DataGrid` and needs multi-selection or selected-item synchronization with the view model.
   - This is important for architecture because deletion/backup actions are likely applied to a batch of selected certificates rather than a single item.

10. **External system integration**
    - The app interacts with **Windows certificate stores** in:
      - `CurrentUser`
      - `LocalMachine`
    - Backups are stored under `Documents/CertificateBackups`.
    - The README notes that `LocalMachine` access may require **elevated privileges**, and the UI project includes `app.manifest` for the requested execution level.

11. **Safety and destructive-operation design**
    - Backup is a first-class workflow before deletion, but only for **exportable certificates**.
    - Deletion is intentionally gated by confirmation dialogs.
    - The README emphasizes the risk of deleting the wrong certificate; architecturally, that is reflected in the explicit request objects, filtering, and confirmation steps.

12. **Testing structure**
    - The test project is organized around **story-based scenarios** rather than isolated unit tests only.
    - `Factories/CertificateFactory.cs` provides test data builders.
    - `Stories/Certificates/CertificateBackup.cs` suggests behavior-focused coverage around backup workflows.
    - `ICertificateStore` in the test project indicates the certificate store is abstracted for testability, so certificate I/O can be simulated without touching real Windows stores.

13. **Likely end-to-end data flow**
    - User opens the WPF app → selects filters/settings → `MainWindowViewModel` builds a `CertificateQuery` → `CertificateService` reads certificates from Windows stores → filtered certificates are shown in the grid → user selects items → confirm dialogs appear → service backs up exportable certificates to `Documents/CertificateBackups` and/or deletes them from `CurrentUser` or `LocalMachine`.

14. **Diagramming note**
    - A clear architecture diagram for this repo should show three main boxes:
      - **WPF UI/MVVM**
      - **Core service/domain layer**
      - **Windows certificate store + backup file system**
    - The tests should be shown as a separate verification layer around the Core contract, not as part of the runtime path.

Main entry points: [`CornojoblessCertificateManager.UI/ViewModel/MainWindowViewModel.cs`](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.UI/ViewModel/MainWindowViewModel.cs) (Main VM), [`CornojoblessCertificateManager.Core/Services/CertificateService.cs`](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Services/CertificateService.cs) (Certificate service), [`CornojoblessCertificateManager.Core/Services/ICertificateService.cs`](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Services/ICertificateService.cs) (Service contract), [`CornojoblessCertificateManager.Tests/Stories/Certificates/CertificateBackup.cs`](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Tests/Stories/Certificates/CertificateBackup.cs) (Backup story)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["WPF UI"]
  node_ui_mainwindow["Main window<br/>WPF view<br/>[MainWindow.xaml]"]
  node_ui_vm["Main VM<br/>view model"]
  node_ui_command["Relay command<br/>MVVM command<br/>[RelayCommand.cs]"]
  node_ui_backup_dialog["Backup confirm<br/>dialog"]
  node_ui_delete_dialog["Delete confirm<br/>dialog"]
  node_ui_selection["Grid selection<br/>behavior"]
  node_ui_config["App settings<br/>WPF config<br/>[appsettings.json]"]
end

subgraph group_core["Core"]
  node_core_service["Certificate service"]
  node_core_contract["Service contract<br/>interface"]
  node_core_query["Certificate query<br/>query model"]
  node_core_info["Certificate info<br/>domain model<br/>[CertificateInfo.cs]"]
  node_core_settings["Certificate settings<br/>config model"]
  node_core_backup_req["Backup request<br/>action request"]
  node_core_delete_req["Delete request<br/>action request"]
  node_core_utils["Certificate utils<br/>helpers"]
end

subgraph group_tests["Tests"]
  node_test_factory["Test factory<br/>test fixture"]
  node_test_store["Store stub<br/>test double"]
  node_test_story["Backup story<br/>story test"]
end

subgraph group_external["External systems"]
  node_win_store[("Windows stores<br/>system boundary")]
  node_backup_fs[("Backup folder<br/>filesystem")]
end

node_console_host["Console host<br/>console app<br/>[Program.cs]"]

node_ui_mainwindow -->|"binds to"| node_ui_vm
node_ui_vm -->|"uses"| node_ui_command
node_ui_vm -->|"tracks selection"| node_ui_selection
node_ui_vm -->|"calls"| node_core_contract
node_ui_vm -->|"builds"| node_core_query
node_ui_vm -->|"creates"| node_core_backup_req
node_ui_vm -->|"creates"| node_core_delete_req
node_ui_vm -->|"confirms"| node_ui_backup_dialog
node_ui_vm -->|"confirms"| node_ui_delete_dialog
node_ui_vm -->|"reads"| node_ui_config
node_core_service -->|"reads from"| node_win_store
node_core_service -->|"writes to"| node_backup_fs
node_core_service -->|"applies"| node_core_query
node_core_service -->|"executes"| node_core_backup_req
node_core_service -->|"executes"| node_core_delete_req
node_core_service -->|"returns"| node_core_info
node_core_service -->|"uses"| node_core_settings
node_core_service -->|"delegates to"| node_core_utils
node_core_contract -->|"implemented by"| node_core_service
node_ui_config -->|"maps to"| node_core_settings
node_test_factory -->|"supports"| node_test_story
node_test_store -->|"mocks boundary"| node_core_contract
node_test_story -->|"verifies"| node_core_contract
node_test_story -->|"uses"| node_test_factory
node_core_service -.->|"can be isolated by"| node_test_store

click node_ui_mainwindow "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.UI/MainWindow.xaml"
click node_ui_vm "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.UI/ViewModel/MainWindowViewModel.cs"
click node_ui_command "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.UI/ViewModel/RelayCommand.cs"
click node_ui_backup_dialog "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.UI/DialogConfirmBackup.xaml"
click node_ui_delete_dialog "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.UI/DialogConfirmDelete.xaml"
click node_ui_selection "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.UI/Behavior/DataGridSelectedItemsBehavior.cs"
click node_ui_config "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.UI/appsettings.json"
click node_core_service "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Services/CertificateService.cs"
click node_core_contract "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Services/ICertificateService.cs"
click node_core_query "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Queries/CertificateQuery.cs"
click node_core_info "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Model/CertificateInfo.cs"
click node_core_settings "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Model/CertificateSettings.cs"
click node_core_backup_req "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Requests/CertificateBackupRequest.cs"
click node_core_delete_req "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Requests/CertificateDeleteRequest.cs"
click node_core_utils "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Utils/CertificateUtils.cs"
click node_console_host "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Console/Program.cs"
click node_test_factory "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Tests/Factories/CertificateFactory.cs"
click node_test_store "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Tests/ICertificateStore.cs"
click node_test_story "https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Tests/Stories/Certificates/CertificateBackup.cs"

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_ui_mainwindow,node_ui_vm,node_ui_command,node_ui_backup_dialog,node_ui_delete_dialog,node_ui_selection,node_ui_config toneBlue
class node_core_service,node_core_contract,node_core_query,node_core_info,node_core_settings,node_core_backup_req,node_core_delete_req,node_core_utils toneAmber
class node_test_factory,node_test_store,node_test_story toneMint
class node_win_store,node_backup_fs toneRose
class node_console_host toneNeutral
```

## Components

### WPF UI

Desktop presentation and user interaction layer.

- [Main window](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.UI/MainWindow.xaml): WPF view · Primary application window and certificate list surface. · `CornojoblessCertificateManager.UI/MainWindow.xaml`
- [Main VM](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.UI/ViewModel/MainWindowViewModel.cs): view model · Builds queries, drives actions, and exposes certificate state to the view. · `CornojoblessCertificateManager.UI/ViewModel/MainWindowViewModel.cs`
- [Relay command](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.UI/ViewModel/RelayCommand.cs): MVVM command · Command binding helper for refresh, backup, delete, and filter actions. · `CornojoblessCertificateManager.UI/ViewModel/RelayCommand.cs`
- [Backup confirm](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.UI/DialogConfirmBackup.xaml): dialog · Confirmation step before exporting certificates. · `CornojoblessCertificateManager.UI/DialogConfirmBackup.xaml`
- [Delete confirm](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.UI/DialogConfirmDelete.xaml): dialog · Confirmation step before deleting certificates. · `CornojoblessCertificateManager.UI/DialogConfirmDelete.xaml`
- [Grid selection](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.UI/Behavior/DataGridSelectedItemsBehavior.cs): behavior · Synchronizes selected certificate rows with the view model. · `CornojoblessCertificateManager.UI/Behavior/DataGridSelectedItemsBehavior.cs`
- [App settings](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.UI/appsettings.json): WPF config · Runtime configuration for issuer filtering and other UI-driven settings. · `CornojoblessCertificateManager.UI/appsettings.json`

### Core

Reusable certificate domain and service layer.

- [Certificate service](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Services/CertificateService.cs): service · Orchestrates listing, filtering, backup, and delete workflows. · `CornojoblessCertificateManager.Core/Services/CertificateService.cs`
- [Service contract](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Services/ICertificateService.cs): interface · Defines the application boundary for certificate operations. · `CornojoblessCertificateManager.Core/Services/ICertificateService.cs`
- [Certificate query](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Queries/CertificateQuery.cs): query model · Describes which certificates to list or act on. · `CornojoblessCertificateManager.Core/Queries/CertificateQuery.cs`
- [Certificate info](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Model/CertificateInfo.cs): domain model · Certificate data surfaced to the UI and service layer. · `CornojoblessCertificateManager.Core/Model/CertificateInfo.cs`
- [Certificate settings](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Model/CertificateSettings.cs): config model · Maps runtime settings such as issuer filtering rules. · `CornojoblessCertificateManager.Core/Model/CertificateSettings.cs`
- [Backup request](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Requests/CertificateBackupRequest.cs): action request · Explicit request object for certificate export workflows. · `CornojoblessCertificateManager.Core/Requests/CertificateBackupRequest.cs`
- [Delete request](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Requests/CertificateDeleteRequest.cs): action request · Explicit request object for certificate deletion workflows. · `CornojoblessCertificateManager.Core/Requests/CertificateDeleteRequest.cs`
- [Certificate utils](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Core/Utils/CertificateUtils.cs): helpers · Shared certificate helper logic used by the service and query flow. · `CornojoblessCertificateManager.Core/Utils/CertificateUtils.cs`

### Tests

Story-based verification around the core contract.

- [Test factory](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Tests/Factories/CertificateFactory.cs): test fixture · Builds certificate test data for stories and scenarios. · `CornojoblessCertificateManager.Tests/Factories/CertificateFactory.cs`
- [Store stub](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Tests/ICertificateStore.cs): test double · Abstracts certificate I/O so tests avoid touching real stores. · `CornojoblessCertificateManager.Tests/ICertificateStore.cs`
- [Backup story](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Tests/Stories/Certificates/CertificateBackup.cs): story test · Behavior-focused coverage for certificate backup workflows. · `CornojoblessCertificateManager.Tests/Stories/Certificates/CertificateBackup.cs`

### External systems

Windows certificate stores and backup file system.

- **Windows stores**: system boundary · CurrentUser and LocalMachine certificate stores.
- **Backup folder**: filesystem · Documents/CertificateBackups destination for exported certificates.

### Other components

- [Console host](https://github.com/elcanion/cornojoblesscertificatemanager/blob/main/CornojoblessCertificateManager.Console/Program.cs): console app · Alternative executable host; role is not clearly documented in the snapshot. · `CornojoblessCertificateManager.Console/Program.cs`

## Connections

- Main window → Main VM: binds to · The window is driven by the main view model.
- Main VM → Relay command: uses · View model exposes actions through commands.
- Main VM → Grid selection: tracks selection · Selected certificate rows are synchronized into the VM.
- Main VM → Service contract: calls · Presentation layer depends on the core service boundary.
- Main VM → Certificate query: builds · User filters are translated into certificate queries.
- Main VM → Backup request: creates · Selected items are packaged for export workflows.
- Main VM → Delete request: creates · Selected items are packaged for deletion workflows.
- Main VM → Backup confirm: confirms · Backup is gated by user confirmation.
- Main VM → Delete confirm: confirms · Deletion is gated by user confirmation.
- Main VM → App settings: reads · UI settings shape filtering and runtime behavior.
- Certificate service → Windows stores: reads from · Service queries certificates from Windows stores.
- Certificate service → Backup folder: writes to · Exported backups are stored on disk.
- Certificate service → Certificate query: applies · Query object drives listing and filtering.
- Certificate service → Backup request: executes · Backup request drives export behavior.
- Certificate service → Delete request: executes · Delete request drives removal behavior.
- Certificate service → Certificate info: returns · Filtered certificate data is surfaced through the domain model.
- Certificate service → Certificate settings: uses · Issuer and related rules are loaded into service logic.
- Certificate service → Certificate utils: delegates to · Shared certificate checks and transformations are centralized here.
- Service contract → Certificate service: implemented by · Concrete orchestration lives in the service implementation.
- App settings → Certificate settings: maps to · UI runtime configuration feeds certificate settings.
- Test factory → Backup story: supports · Shared builders underpin story-based scenarios.
- Store stub → Service contract: mocks boundary · Tests abstract certificate I/O behind a store interface.
- Backup story → Service contract: verifies · Stories exercise the certificate service contract.
- Backup story → Test factory: uses · Scenario tests rely on generated certificate data.
- Certificate service → Store stub: can be isolated by · The service is designed to be testable against an abstract store.
