# mrmlik12/steganography-cpp architecture

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

- Interactive diagram: https://gitdiagram.com/mrmlik12/steganography-cpp
- Repository: https://github.com/mrmlik12/steganography-cpp

## Overview

##### Main Components
- CLI Module: This is responsible for parsing command-line arguments and providing helper functions (see include/cli and src/cli). It routes the user commands such as “check”, “encrypt”, “decrypt” to the appropriate processing modules.
- File Management Module: Located in include/file and src/file, it’s in charge of file-related functions (e.g., reading file metadata and verifying file validity).
- Image Processing Module: This core part of the application (found in include/image and src/image) manages image-specific tasks, including:
- Pixel manipulation (include/image/pixel and corresponding src/image/pixel.cpp)
- Handling different image formats (BMP and PPM) with specialized sub-modules (include/image/formats and src/image/formats). Each format (bmp, ppm) implements its own logic for embedding or extracting the hidden text.
- Main Control: The main entry point (src/main.cpp) orchestrates the overall workflow by integrating inputs from the CLI and delegating tasks to the file and image modules.

##### Establish Relationships and Interactions
- The CLI module serves as the front door: it accepts user input, validates commands, and directs the flow.
- The CLI interacts with the File Management module to retrieve details about the image (e.g., file information, check capacity for message embedding).
- Once file validation is done, the CLI invokes the Image Processing module—choosing the correct format-specific routines (BMP or PPM) based on the image file type.
- The Image Processing module then operates on the image’s pixel data. It collaborates with helper components (found in both include/cli/helpers.h, include/file/helpers.h, and include/image/helpers.h) to perform the LSB-based steganography operations.

##### Architectural Patterns and Design Principles
- Layered/Modular Architecture: The clear separation among CLI handling, file operations, and image processing modules simplifies understanding and potential future extensions.
- Separation of Concerns: Each directory and module focuses on a single responsibility – argument parsing, file I/O, image data manipulation, or format-specific operations.
- Reusability: Helper files and shared constants (like include/consts.h) indicate that drilling down specific tasks into re-usable functions is a priority.

##### Incorporate Relevant Technologies
- C++20 – emphasizing modern C++ features.
- CMake – used to build and manage the compilation process.

##### Step-by-Step Creation
a. Start by sketching a high-level view where the “User” sends commands into the “CLI Module”.
c. “Main Control” as the container that initializes and ties together these modules.
d. Error handling or validation flows where the file’s properties are checked to ensure that the text can be embedded.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        UI["User Input"]:::ui
        CLI["CLI Module: Arg Parser & Helpers"]:::cli
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        FM["File Management Module: File I/O & Metadata"]:::fm
        IP["Image Processing Module"]:::ip
    end

    %% Data Processing Layer
    subgraph "Data Processing Layer"
        BMP["BMP Format Handler"]:::dp
        PPM["PPM Format Handler"]:::dp
        PIXEL["Pixel Operations"]:::dp
        BASE["Base Format Handler"]:::dp
        IHELP["Additional Image Helpers"]:::dp
    end

    %% Main Control
    MC["Main Control (Main.cpp)"]:::mc

    %% Connections
    UI -->|"sendsCommand"| CLI
    CLI -->|"validatesFile"| FM
    CLI -->|"delegatesTask"| IP
    FM -->|"providesData"| IP
    IP -->|"processesVia"| BMP
    IP -->|"processesVia"| PPM
    IP -->|"manipulates"| PIXEL
    IP -->|"uses"| BASE
    IP -->|"assistsWith"| IHELP
    MC -->|"orchestrates"| CLI
    MC -->|"orchestrates"| FM
    MC -->|"orchestrates"| IP

    %% Click Events for CLI Module
    click CLI "https://github.com/mrmlik12/steganography-cpp/blob/main/include/cli/args.h"
    click CLI "https://github.com/mrmlik12/steganography-cpp/blob/main/include/cli/helpers.h"
    click CLI "https://github.com/mrmlik12/steganography-cpp/blob/main/src/cli/args.cpp"
    click CLI "https://github.com/mrmlik12/steganography-cpp/blob/main/src/cli/helpers.cpp"
    
    %% Click Events for File Management Module
    click FM "https://github.com/mrmlik12/steganography-cpp/blob/main/include/file/helpers.h"
    click FM "https://github.com/mrmlik12/steganography-cpp/blob/main/src/file/helpers.cpp"
    
    %% Click Events for Image Processing - Pixel Operations
    click PIXEL "https://github.com/mrmlik12/steganography-cpp/blob/main/include/image/pixel.h"
    click PIXEL "https://github.com/mrmlik12/steganography-cpp/blob/main/src/image/pixel.cpp"
    
    %% Click Events for Image Processing - BMP Format Handler
    click BMP "https://github.com/mrmlik12/steganography-cpp/blob/main/include/image/formats/bmp.h"
    click BMP "https://github.com/mrmlik12/steganography-cpp/blob/main/src/image/formats/bmp.cpp"
    
    %% Click Events for Image Processing - PPM Format Handler
    click PPM "https://github.com/mrmlik12/steganography-cpp/blob/main/include/image/formats/ppm.h"
    click PPM "https://github.com/mrmlik12/steganography-cpp/blob/main/src/image/formats/ppm.cpp"
    
    %% Click Events for Image Processing - Base Format Handler
    click BASE "https://github.com/mrmlik12/steganography-cpp/blob/main/include/image/formats/base.h"
    click BASE "https://github.com/mrmlik12/steganography-cpp/blob/main/src/image/formats/base.cpp"
    
    %% Click Events for Additional Image Helpers
    click IHELP "https://github.com/mrmlik12/steganography-cpp/blob/main/include/image/helpers.h"
    click IHELP "https://github.com/mrmlik12/steganography-cpp/blob/main/src/image/helpers.cpp"
    
    %% Click Event for Main Control
    click MC "https://github.com/mrmlik12/steganography-cpp/blob/main/src/main.cpp"

    %% Styles
    classDef cli fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef fm fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef ip fill:#FFDAB9,stroke:#000,stroke-width:2px;
    classDef dp fill:#FFDAB9,stroke:#000,stroke-width:2px;
    classDef ui fill:#B0E0E6,stroke:#000,stroke-width:2px;
    classDef mc fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
