# luongwnv/convert-raw-to-jpeg architecture

> Architecture diagram of the GitHub repository luongwnv/convert-raw-to-jpeg, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/luongwnv/convert-raw-to-jpeg
- Repository: https://github.com/luongwnv/convert-raw-to-jpeg

## Overview

##### Main Components
- Application UI (Renderer Process): Represented by index.html, renderer.js, and styles.css. This is where users interact with the app (drag & drop, file selection, and conversion commands).
- Main Process: Represented by main.js. This is the Electron main process that creates browser windows, handles application lifecycle events, and orchestrates inter-process communication (IPC) between UI and back-end operations.
- External Conversion Tools: The app relies on system-installed tools – dcraw, ImageMagick, and ExifTool – to perform the image conversion, metadata preservation, and cleanup processes.
- File System: Although not a coded module, file system interactions (reading the source .ARW file, writing the converted .jpeg, and optionally deleting intermediate .TIFF files) are crucial parts of the workflow.
- Package & Configuration: Files such as package.json and package-lock.json specify dependencies and serve as build/startup configuration, indicating a Node.js environment.

##### Relationships and Interactions
- The UI sends user actions (e.g., a drag & drop event or file selection) via IPC messages to the Main Process.
- The Main Process receives these events and calls on the external conversion tools by spawning child processes or executing system commands to handle the conversion.
- After conversion, the Main Process updates the UI with the output status or image preview.
- The file system is accessed to both read the input .ARW and write the output .JPEG file in the same folder as the original.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The front-end (renderer) is exclusively focused on the user interface and interactions, while the main process handles back-end operations like file conversion and managing the external tool executions.
- External Integration: Clearly mark integration points with system-level commands/tools (dcraw, ImageMagick, ExifTool) used for image processing.

##### Relevant Technologies, Frameworks, or Libraries
- Electron framework as the underlying platform.
- Node.js runtime that runs the main process.
- External utilities (dcraw, ImageMagick, ExifTool), which are crucial for the conversion process.
- UI technologies (HTML, CSS, JavaScript in renderer.js).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-level User Trigger
    U["User Actions"]:::ui

    %% Renderer Process Subgraph
    subgraph "Renderer Process (UI)"
        R1["index.html"]:::ui
        R2["renderer.js"]:::ui
        R3["styles.css"]:::ui
    end

    %% Main Process Subgraph
    subgraph "Main Process"
        M["main.js"]:::backend
    end

    %% External Conversion Tools Subgraph
    subgraph "External Conversion Tools"
        E1["dcraw"]:::external
        E2["ImageMagick"]:::external
        E3["ExifTool"]:::external
    end

    %% File System Node
    FS["File System"]:::fs

    %% Package & Configuration Subgraph
    subgraph "Package & Configuration"
        P1["package.json"]:::config
        P2["package-lock.json"]:::config
    end

    %% Relationships
    U -->|"initiates"| R1
    U -->|"initiates"| R2
    U -->|"initiates"| R3

    %% IPC Communication from Renderer to Main Process
    R1 -->|"IPC_message"| M
    R2 -->|"UI_logic"| M
    R3 -->|"UI_styles"| M

    %% Main Process invokes External Tools
    M -->|"executes"| E1
    M -->|"executes"| E2
    M -->|"executes"| E3

    %% File System interactions
    M -->|"read/write"| FS
    R1 -->|"display_output"| FS

    %% Feedback from Main Process back to Renderer (via IPC)
    M -->|"feedback"| R1

    %% Click Events for Component Mapping
    click R1 "https://github.com/luongwnv/convert-raw-to-jpeg/blob/master/index.html"
    click R2 "https://github.com/luongwnv/convert-raw-to-jpeg/blob/master/renderer.js"
    click R3 "https://github.com/luongwnv/convert-raw-to-jpeg/blob/master/styles.css"
    click M "https://github.com/luongwnv/convert-raw-to-jpeg/blob/master/main.js"
    click P1 "https://github.com/luongwnv/convert-raw-to-jpeg/blob/master/package.json"
    click P2 "https://github.com/luongwnv/convert-raw-to-jpeg/blob/master/package-lock.json"

    %% Styles
    classDef ui fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
    classDef backend fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
    classDef external fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef fs fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef config fill:#F5B7B1,stroke:#E74C3C,stroke-width:2px;
```
