# linhuanran/ocr architecture

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

- Interactive diagram: https://gitdiagram.com/linhuanran/ocr
- Repository: https://github.com/linhuanran/ocr

## Overview

天若 OCR is a Windows desktop OCR application. The main workflow is to initiate recognition from the desktop, process an image through an OCR service, and work with the returned text; the application also provides text editing, translation, history, and configuration capabilities. The sampled code confirms startup/configuration, Baidu OCR requests, and image-byte conversion. Some UI wiring and the implementation of documented or apparent secondary features are unsampled, so uncertain links are omitted.

Main entry points: [`FmMain.cs`](https://github.com/linhuanran/ocr/blob/master/FmMain.cs) (Main window), [`Program.cs`](https://github.com/linhuanran/ocr/blob/master/Program.cs) (Application startup), [`Helper/IniHelper.cs`](https://github.com/linhuanran/ocr/blob/master/Helper/IniHelper.cs) (INI configuration), [`FmSetting.cs`](https://github.com/linhuanran/ocr/blob/master/FmSetting.cs) (Settings window)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and OCR"]
  node_main["Main window<br/>[FmMain.cs]"]
  node_paste["Screen paste<br/>[FmScreenPaste.cs]"]
  node_ocrhelper["OCR image helper<br/>[OcrHelper.cs]"]
end

subgraph group_text["Text workflow"]
  node_editor["Rich text editor"]
  node_translate["Translation helper<br/>[TranslateHelper.cs]"]
  node_history["Text records<br/>[Fmnote.cs]"]
  node_replace["Text replacement<br/>[ReplaceForm.cs]"]
end

subgraph group_app["Desktop application"]
  node_settings["Settings window<br/>[FmSetting.cs]"]
  node_startup["Application startup<br/>[Program.cs]"]
  node_config[("INI configuration<br/>[IniHelper.cs]")]
end

subgraph group_services["Integrations"]
  node_baidu{{"Baidu OCR"}}
  node_http["HTTP helper<br/>[CommonHelper.cs]"]
  node_updater{{"Update service"}}
end

node_user(("User"))

node_user -->|"uses"| node_main
node_main -->|"opens capture"| node_paste
node_main -->|"converts image"| node_ocrhelper
node_main -->|"submits OCR"| node_baidu
node_baidu -->|"returns text"| node_main
node_main -->|"presents text"| node_editor
node_main -.->|"translates text"| node_translate
node_main -.->|"opens records"| node_history
node_main -.->|"opens replacement"| node_replace
node_startup -->|"launches"| node_main
node_startup -->|"reads and writes"| node_config
node_settings -->|"reads and writes"| node_config
node_main -->|"reads and writes"| node_config
node_main -->|"posts request"| node_http
node_startup -.->|"checks updates"| node_updater

click node_main "https://github.com/linhuanran/ocr/blob/master/FmMain.cs"
click node_paste "https://github.com/linhuanran/ocr/blob/master/FmScreenPaste.cs"
click node_ocrhelper "https://github.com/linhuanran/ocr/blob/master/Helper/OcrHelper.cs"
click node_editor "https://github.com/linhuanran/ocr/blob/master/AdvRichTextBox.Designer.cs"
click node_translate "https://github.com/linhuanran/ocr/blob/master/Helper/TranslateHelper.cs"
click node_history "https://github.com/linhuanran/ocr/blob/master/Fmnote.cs"
click node_replace "https://github.com/linhuanran/ocr/blob/master/ReplaceForm.cs"
click node_settings "https://github.com/linhuanran/ocr/blob/master/FmSetting.cs"
click node_startup "https://github.com/linhuanran/ocr/blob/master/Program.cs"
click node_config "https://github.com/linhuanran/ocr/blob/master/Helper/IniHelper.cs"
click node_http "https://github.com/linhuanran/ocr/blob/master/Helper/CommonHelper.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_main,node_paste,node_ocrhelper,node_user toneBlue
class node_editor,node_translate,node_history,node_replace toneAmber
class node_settings,node_startup,node_config toneMint
class node_baidu,node_http,node_updater toneRose
```

## Components

### Capture and OCR

- [Main window](https://github.com/linhuanran/ocr/blob/master/FmMain.cs): `FmMain.cs`
- [Screen paste](https://github.com/linhuanran/ocr/blob/master/FmScreenPaste.cs): `FmScreenPaste.cs`
- [OCR image helper](https://github.com/linhuanran/ocr/blob/master/Helper/OcrHelper.cs): `Helper/OcrHelper.cs`

### Text workflow

- [Rich text editor](https://github.com/linhuanran/ocr/blob/master/AdvRichTextBox.Designer.cs): `AdvRichTextBox.Designer.cs`
- [Translation helper](https://github.com/linhuanran/ocr/blob/master/Helper/TranslateHelper.cs): `Helper/TranslateHelper.cs`
- [Text records](https://github.com/linhuanran/ocr/blob/master/Fmnote.cs): `Fmnote.cs`
- [Text replacement](https://github.com/linhuanran/ocr/blob/master/ReplaceForm.cs): `ReplaceForm.cs`

### Desktop application

- [Settings window](https://github.com/linhuanran/ocr/blob/master/FmSetting.cs): `FmSetting.cs`
- [Application startup](https://github.com/linhuanran/ocr/blob/master/Program.cs): `Program.cs`
- [INI configuration](https://github.com/linhuanran/ocr/blob/master/Helper/IniHelper.cs): `Helper/IniHelper.cs`

### Integrations

- **Baidu OCR**
- [HTTP helper](https://github.com/linhuanran/ocr/blob/master/Helper/CommonHelper.cs): `Helper/CommonHelper.cs`
- **Update service**

### Other components

- **User**

## Connections

- User → Main window: uses
- Main window → Screen paste: opens capture
- Main window → OCR image helper: converts image
- Main window → Baidu OCR: submits OCR
- Baidu OCR → Main window: returns text
- Main window → Rich text editor: presents text
- Main window → Translation helper: translates text
- Main window → Text records: opens records
- Main window → Text replacement: opens replacement
- Application startup → Main window: launches
- Application startup → INI configuration: reads and writes
- Settings window → INI configuration: reads and writes
- Main window → INI configuration: reads and writes
- Main window → HTTP helper: posts request
- Application startup → Update service: checks updates
