# cycle0/markdown-image-processor architecture

> Architecture diagram of the GitHub repository cycle0/markdown-image-processor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cycle0/markdown-image-processor
- Repository: https://github.com/cycle0/markdown-image-processor

## Overview

##### Project type and purpose
- This is a single‐process, desktop application built in C# using WPF on .NET 6.0.
- Its sole purpose is to scan a folder of Markdown files, fetch remote images into a local “assets” directory, update image links, and report progress/logs via a modern UI.

##### File structure
- App.xaml / App.xaml.cs & MainWindow.xaml / MainWindow.xaml.cs
→ WPF application entry point and main window UI definitions.
- MarkdownImageProcessor.csproj
→ .NET 6.0 project file declaring dependencies and build targets.
- MarkdownImageProcessor.cs (likely contains core image‐processing logic)
- README.md, LICENSE, .gitignore, app.manifest
→ Documentation, license, source control ignore rules, and Windows manifest.

##### README for additional insights
- Confirms a WPF UI that displays real-time progress and detailed logs.
- Core features: directory selection, network download of images, path rewriting, local logging.
- Uses only local processing—no external services except HTTP GET for images.

a. Main components:
- UI Layer (WPF):
– MainWindow (View)
– ViewModel / Controller (event handlers, commands)
- Business Logic Layer (Core Processor):
– Markdown Parser & Scanner
– Network Downloader
– Path Updater
– Logger
- File System:
– Input Folder (Markdown files)
– Assets Folder (downloaded images)
– Log File(s)
- .NET Runtime
b. Relationships & interactions:
1. User interacts with WPF UI → triggers “Process” command in ViewModel.
2. ViewModel calls Core Processor API.
3. Processor reads each Markdown file from Input Folder.
4. For each remote image URL → Network Downloader issues HTTP GET → saves to Assets Folder.
5. Path Updater rewrites Markdown to reference local file.
6. Logger writes progress to UI (via data binding) and to disk.
7. Upon completion, UI displays summary.
c. Architectural patterns / design principles:
– MVVM (Model‐View‐ViewModel) for UI separation.
– Single responsibility for parser, network, I/O, and logging modules.
– Event‐driven or callback updates to UI for progress.
– Clear layering: UI ←→ ViewModel ←→ Core Processor ←→ I/O & Network.
d. Key technologies / frameworks:
– .NET 6.0 & C#
– WPF (UI/XAML)
– HttpClient (network)
– System.IO (file system)
– Powershell scripts (build & release automation)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        AppX["App.xaml"]:::ui
        AppCS["App.xaml.cs"]:::ui
        MainX["MainWindow.xaml"]:::ui
        MainCS["MainWindow.xaml.cs"]:::ui
    end

    %% ViewModel / Controller
    VM["ViewModel / Controller"]:::ui

    %% Core Processor
    subgraph "Core Processor"
        Parser["Markdown Scanner"]:::core
        Downloader["Image Downloader"]:::core
        Updater["Path Updater"]:::core
        Logger["Logger"]:::core
        CoreAPI["MarkdownImageProcessor.cs"]:::core
    end

    %% I/O & Network
    subgraph "I/O & Network"
        InputFS["Input Folder (Markdown files)"]:::ext
        AssetsFS["Assets Folder (Downloaded images)"]:::ext
        LogFS["Log Files"]:::ext
        HTTP["HTTP Endpoint"]:::cloud
    end

    %% DevOps & Scripts
    subgraph "DevOps & Automation Scripts"
        S1["ProcessMarkdownImages.ps1"]:::script
        S2["build-secure-simple.ps1"]:::script
        S3["prepare-release.ps1"]:::script
        S4["create-icon.ps1"]:::script
    end

    %% Project Definition & Documentation
    subgraph "Project Definition & Docs"
        CSProj["MarkdownImageProcessor.csproj"]:::doc
        Manifest["app.manifest"]:::doc
        Readme["README.md"]:::doc
        License["LICENSE"]:::doc
        Gitignore[".gitignore"]:::doc
    end

    %% Application Flow
    MainX -->|"User clicks Process"| VM
    VM -->|"Process()"| CoreAPI
    CoreAPI -->|"Parse & Scan"| Parser
    Parser -->|"Read .md"| InputFS
    Parser -->|"Found URLs"| Downloader
    Downloader -->|"HTTP GET"| HTTP
    HTTP -->|"Image Data"| Downloader
    Downloader -->|"Save Image"| AssetsFS
    Downloader -->|"Local Path"| Updater
    Updater -->|"Rewrite Links"| InputFS
    Parser -->|"Log events"| Logger
    Downloader -->|"Log events"| Logger
    Updater -->|"Log events"| Logger
    Logger -->|"Write Log"| LogFS
    Logger -->|"Progress update"| VM
    VM -->|"Update UI"| MainX

    %% Scripts to Project
    S1 --> CSProj
    S2 --> CSProj
    S3 --> CSProj
    S4 --> CSProj

    %% Documentation linked
    Readme --> CSProj
    License --> CSProj
    Gitignore --> CSProj
    Manifest --> CSProj

    %% Click Events
    click AppX "https://github.com/cycle0/markdown-image-processor/blob/main/App.xaml"
    click AppCS "https://github.com/cycle0/markdown-image-processor/blob/main/App.xaml.cs"
    click MainX "https://github.com/cycle0/markdown-image-processor/blob/main/MainWindow.xaml"
    click MainCS "https://github.com/cycle0/markdown-image-processor/blob/main/MainWindow.xaml.cs"
    click CSProj "https://github.com/cycle0/markdown-image-processor/blob/main/MarkdownImageProcessor.csproj"
    click CoreAPI "https://github.com/cycle0/markdown-image-processor/blob/main/MarkdownImageProcessor.cs"
    click S1 "https://github.com/cycle0/markdown-image-processor/blob/main/ProcessMarkdownImages.ps1"
    click S2 "https://github.com/cycle0/markdown-image-processor/blob/main/build-secure-simple.ps1"
    click S3 "https://github.com/cycle0/markdown-image-processor/blob/main/prepare-release.ps1"
    click S4 "https://github.com/cycle0/markdown-image-processor/blob/main/create-icon.ps1"
    click Manifest "https://github.com/cycle0/markdown-image-processor/blob/main/app.manifest"
    click Readme "https://github.com/cycle0/markdown-image-processor/blob/main/README.md"
    click License "https://github.com/cycle0/markdown-image-processor/tree/main/LICENSE"
    click Gitignore "https://github.com/cycle0/markdown-image-processor/blob/main/.gitignore"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef core fill:#90EE90,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5;
    classDef ext fill:#FFFFE0,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2;
    classDef cloud fill:#FFE4B5,stroke:#333,stroke-width:1px;
    classDef script fill:#D3D3D3,stroke:#333,stroke-width:1px;
    classDef doc fill:#FFEFD5,stroke:#333,stroke-width:1px;
```
