# beyondrgb/imaging-art-beyond-rgb architecture

> Architecture diagram of the GitHub repository beyondrgb/imaging-art-beyond-rgb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/beyondrgb/imaging-art-beyond-rgb
- Repository: https://github.com/beyondrgb/imaging-art-beyond-rgb

## Overview

##### Project Type and Purpose
- **Project Type:** Full-stack application.

##### File Structure
- **Top-Level Directories:**
- `backend`: Contains all backend-related code, primarily in C++, responsible for image processing, calibration, and handling spectral data.
- `frontend`: Houses the frontend application built with Svelte, managing the user interface and user interactions.
- `docs`: Documentation resources.
- **Backend Subdirectories:**
- `src`: Core source code divided into modules like `ImageUtil`, `backend_process`, `image_processing`, `server`, and `utils`.
- `res`: Resources such as reference data in CSV format.
- `test`: Testing resources and HTML test pages.
- **Frontend Subdirectories:**
- `src/renderer/components`: Reusable UI components built with Svelte.
- `cypress`: End-to-end testing configurations.
- **Configuration and Build Scripts:**
- Various shell and batch scripts for building and configuring both backend and frontend on different operating systems.

##### README for Additional Insights
- **Architecture Overview:** The README outlines the separation between backend and frontend, the dependencies required, and the build processes for different environments (Windows, Mac, Ubuntu).
- **Technologies Used:**
- **Backend:** C++ (C++20), CMake, Vcpkg for dependency management.
- **Frontend:** Svelte, Node.js, Cypress for testing.
- **Documentation Links:** Provides links to detailed architecture, API communications, backend design, TIFF output handling, and system internals ("Under The Hood").

##### a. Main Components
- **Frontend Application:**
- Built with Svelte, handling the user interface, image importation, user selections, and displaying processed images and reports.
- **Backend Processing Engine:**
- **Communication Layer:**
- API or inter-process communication facilitating interactions between the frontend and backend.
- **Resource Management:**
- Reference data and calibration files stored in the `res` directory.
- **Build and Deployment Scripts:**
- Scripts for setting up, building, and releasing the application across different operating systems.

##### b. Relationships and Interactions
- **Frontend ↔ Backend:**
- The frontend sends image data and user selections to the backend for processing.
- The backend processes the data and returns the processed images and calibration reports to the frontend.
- **Backend Components:**
- `server` manages requests from the frontend and orchestrates processing workflows.
- **Resource Access:**
- Backend accesses reference data from the `res` directory to perform calibrations and processing.

##### c. Architectural Patterns or Design Principles
- **Modular Architecture:**
- Clearly separated modules in both frontend and backend enhance maintainability and scalability.
- **Separation of Concerns:**
- Distinct separation between user interface (frontend) and data processing (backend).
- **Cross-Platform Build System:**
- Use of CMake and platform-specific scripts ensures the application can be built and released on Windows, Mac, and Ubuntu.

##### d. Relevant Technologies, Frameworks, or Libraries
- **Frontend:**
- **Svelte:** For building reactive user interfaces.
- **Node.js:** Managing frontend dependencies and build processes.
- **Cypress:** For end-to-end testing.
- **Backend:**
- **C++20:** Core processing language.
- **CMake:** Build configuration.
- **Vcpkg:** Dependency management.
- **Documentation and Testing Tools:** Git for version control, various scripts for environment setup.

##### Frontend Layer
- **User Interface (Svelte Components):** Image Importer, Image Viewer, Process Controls, Report Viewer.
- **Build Tools:** Node.js, Cypress.
##### Communication Layer
- **API Gateway or IPC Mechanism:** Handles requests and responses between frontend and backend.
##### Backend Layer
- **Server Module:** Manages incoming requests.
- **Image Processing Modules:** ImageUtil, ImageReader, ImageWriter, ColorProfiles.
- **Resource Management:** Access to reference data and calibration files.
- **Utilities:** Command Argument Manager, JSON Handling, Time Tracker.
##### Build and Deployment
- **Scripts:** CMake, Vcpkg, Platform-specific build scripts.
- **Dependencies:** Managed via `dependencies.txt` and `package.json`/`package-lock.json`.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Class Definitions
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px
    classDef communication fill:#FFA500,stroke:#000,stroke-width:1px
    classDef build fill:#D3D3D3,stroke:#000,stroke-width:1px

    %% Frontend Layer
    subgraph "Frontend Layer"
        FA["Frontend Application"]:::frontend
        II["Image Importer"]:::frontend
        IV["Image Viewer"]:::frontend
        PC["Process Controls"]:::frontend
        RV["Report Viewer"]:::frontend
        NT["Node.js"]:::frontend
        CT["Cypress"]:::frontend
    end

    %% Communication Layer
    comm["IPC Mechanism"]:::communication

    %% Backend Layer
    subgraph "Backend Layer"
        BE["Backend Processing Engine"]:::backend
        SM["Server Module"]:::backend
        IU["ImageUtil"]:::backend
        IP["Image Processing"]:::backend
        UT["Utils"]:::backend
        RM["Resource Management"]:::backend
    end

    %% Build and Deployment
    subgraph "Build and Deployment"
        BBS1["config_depends.bat"]:::build
        BBS2["linux_config_environment.sh"]:::build
        BBS3["osx_config_environment.sh"]:::build
        FBS1["release_frontend.sh"]:::build
        FBS2["win10_release_frontend.bat"]:::build
    end

    %% Connections
    FA --> II
    FA --> IV
    FA --> PC
    FA --> RV
    FA --> NT
    FA --> CT
    FA --> comm
    comm --> BE
    BE --> SM
    BE --> IU
    BE --> IP
    BE --> UT
    BE --> RM
    BE --> BBS1
    BE --> BBS2
    BE --> BBS3
    FA --> FBS1
    FA --> FBS2

    %% Click Events
    click FA "https://github.com/beyondrgb/imaging-art-beyond-rgb/tree/master/frontend/src/renderer"
    click BE "https://github.com/beyondrgb/imaging-art-beyond-rgb/tree/master/backend/src"
    click SM "https://github.com/beyondrgb/imaging-art-beyond-rgb/tree/master/backend/src/server"
    click comm "https://github.com/beyondrgb/imaging-art-beyond-rgb/blob/master/frontend/src/main/preload.js"
    click RM "https://github.com/beyondrgb/imaging-art-beyond-rgb/tree/master/backend/res"
    click BBS1 "https://github.com/beyondrgb/imaging-art-beyond-rgb/blob/master/backend/config_depends.bat"
    click BBS2 "https://github.com/beyondrgb/imaging-art-beyond-rgb/blob/master/backend/linux_config_environment.sh"
    click BBS3 "https://github.com/beyondrgb/imaging-art-beyond-rgb/blob/master/backend/osx_config_environment.sh"
    click FBS1 "https://github.com/beyondrgb/imaging-art-beyond-rgb/blob/master/frontend/release_frontend.sh"
    click FBS2 "https://github.com/beyondrgb/imaging-art-beyond-rgb/blob/master/frontend/win10_release_frontend.bat"
    %% Styles
    class FA,II,IV,PC,RV,NT,CT frontend
    class BE,SM,IU,IP,UT,RM backend
    class comm communication
    class BBS1,BBS2,BBS3,FBS1,FBS2 build
```
