# tanishktewetia/credential_blur_ocr_lab architecture

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

- Interactive diagram: https://gitdiagram.com/tanishktewetia/credential_blur_ocr_lab
- Repository: https://github.com/tanishktewetia/credential_blur_ocr_lab

## Overview

OcrLab is a local Windows WPF experiment for testing credential redaction in captured screen frames. The user starts capture in the UI; CaptureService captures a primary-monitor frame, runs Windows OCR, asks CredentialMatcher to identify sensitive lines, redacts their bounds, then resizes, encodes, and saves the processed JPEG. The UI can stop capture and displays status without showing matched text. The README documents the processing stages; the sampled CaptureService excerpt is partial, so some internal stage links rely on that documentation.

Main entry points: [`OcrLab/CaptureService.cs`](https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/CaptureService.cs) (Capture loop), [`OcrLab/MainWindow.xaml.cs`](https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/MainWindow.xaml.cs) (UI event handling), [`OcrLab/MainWindow.xaml`](https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/MainWindow.xaml) (Start/Stop UI), [`OcrLab/CredentialMatcher.cs`](https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/CredentialMatcher.cs) (Credential matching)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_window["Start/Stop UI<br/>[MainWindow.xaml]"]
  node_ui_logic["UI event handling<br/>[MainWindow.xaml.cs]"]
end

subgraph group_capture["Frame capture"]
  node_capture_service["Capture loop<br/>[CaptureService.cs]"]
  node_monitor["Primary monitor"]
  node_wgc["Windows capture"]
  node_d3d["Direct3D device<br/>[CaptureService.cs]"]
  node_monitor_interop["Monitor interop<br/>[CaptureService.cs]"]
end

subgraph group_processing["Frame processing"]
  node_ocr["Windows OCR"]
  node_matcher["Credential matching"]
  node_redaction["Blackout regions<br/>[CaptureService.cs]"]
end

subgraph group_output["Redacted output"]
  node_resize_encode["Resize and encode<br/>[CaptureService.cs]"]
  node_output_dir[("JPEG output")]
end

node_user(("Operator"))

node_user -->|"starts or stops"| node_window
node_window -->|"raises events"| node_ui_logic
node_ui_logic -->|"starts or stops"| node_capture_service
node_capture_service -->|"creates monitor item"| node_monitor_interop
node_capture_service -->|"creates device"| node_d3d
node_capture_service -->|"starts capture"| node_wgc
node_monitor_interop -->|"selects primary"| node_monitor
node_wgc -->|"captures frame"| node_monitor
node_capture_service -->|"recognizes frame"| node_ocr
node_capture_service -->|"passes OCR result"| node_matcher
node_capture_service -->|"draws black rectangles"| node_redaction
node_matcher -->|"returns bounds"| node_redaction
node_capture_service -->|"resizes and encodes"| node_resize_encode
node_resize_encode -->|"writes JPEG"| node_output_dir
node_capture_service -->|"reports status"| node_ui_logic

click node_window "https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/MainWindow.xaml"
click node_ui_logic "https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/MainWindow.xaml.cs"
click node_capture_service "https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/CaptureService.cs"
click node_d3d "https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/CaptureService.cs"
click node_monitor_interop "https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/CaptureService.cs"
click node_matcher "https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/CredentialMatcher.cs"
click node_redaction "https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/CaptureService.cs"
click node_resize_encode "https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/CaptureService.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_window,node_ui_logic toneBlue
class node_capture_service,node_monitor,node_wgc,node_d3d,node_monitor_interop toneAmber
class node_ocr,node_matcher,node_redaction toneMint
class node_resize_encode,node_output_dir toneRose
class node_user toneIndigo
```

## Components

### User interface

- [Start/Stop UI](https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/MainWindow.xaml): `OcrLab/MainWindow.xaml`
- [UI event handling](https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/MainWindow.xaml.cs): `OcrLab/MainWindow.xaml.cs`

### Frame capture

- [Capture loop](https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/CaptureService.cs): `OcrLab/CaptureService.cs`
- **Primary monitor**
- **Windows capture**
- [Direct3D device](https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/CaptureService.cs): `OcrLab/CaptureService.cs`
- [Monitor interop](https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/CaptureService.cs): `OcrLab/CaptureService.cs`

### Frame processing

- **Windows OCR**
- [Credential matching](https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/CredentialMatcher.cs): `OcrLab/CredentialMatcher.cs`
- [Blackout regions](https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/CaptureService.cs): `OcrLab/CaptureService.cs`

### Redacted output

- [Resize and encode](https://github.com/tanishktewetia/credential_blur_ocr_lab/blob/main/OcrLab/CaptureService.cs): `OcrLab/CaptureService.cs`
- **JPEG output**

### Other components

- **Operator**

## Connections

- Operator → Start/Stop UI: starts or stops (evidence: `README.md`)
- Start/Stop UI → UI event handling: raises events (evidence: `README.md`)
- UI event handling → Capture loop: starts or stops (evidence: `OcrLab/MainWindow.xaml.cs`)
- Capture loop → Monitor interop: creates monitor item (evidence: `OcrLab/CaptureService.cs`)
- Capture loop → Direct3D device: creates device (evidence: `OcrLab/CaptureService.cs`)
- Capture loop → Windows capture: starts capture (evidence: `OcrLab/CaptureService.cs`)
- Monitor interop → Primary monitor: selects primary (evidence: `OcrLab/CaptureService.cs`)
- Windows capture → Primary monitor: captures frame (evidence: `README.md`)
- Capture loop → Windows OCR: recognizes frame (evidence: `README.md`)
- Capture loop → Credential matching: passes OCR result (evidence: `OcrLab/CaptureService.cs`)
- Capture loop → Blackout regions: draws black rectangles (evidence: `README.md`)
- Credential matching → Blackout regions: returns bounds (evidence: `README.md`)
- Capture loop → Resize and encode: resizes and encodes (evidence: `README.md`)
- Resize and encode → JPEG output: writes JPEG (evidence: `README.md`)
- Capture loop → UI event handling: reports status (evidence: `OcrLab/MainWindow.xaml.cs`)
