# deadserpent/image-steganography architecture

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

- Interactive diagram: https://gitdiagram.com/deadserpent/image-steganography
- Repository: https://github.com/deadserpent/image-steganography

## Overview

##### Main Components
- GUI Layer: This represents the user interface built using Tkinter. Include the main window (initialized in the main() method), separate UI frames for encoding (frame1_encode and frame2_encode), decoding (frame1_decode and frame2_decode), and navigation components (home and page3 functions).
- Steganography Engine: This component encapsulates all the core logic for steganography including:
- Data Conversion – (genData): Converts plain text into binary data.
- Pixel Modification – (modPix): Alters image pixel values to embed binary data.
- Encoding Method – (encode_enc): The process that actually embeds the binary data into the image.
- Decoding – (decode): Extracts the binary data from an image and converts it back into text.
- Image I/O and Utilities: Though not broken into separate modules, note that the program makes heavy use of PIL (Pillow) for image processing and Tkinter’s file dialogs for selecting images, along with built-in modules (io, os) for file and data handling.

##### Relationships and Data Flow
- When the program starts, the main GUI is displayed.
- Via the GUI (buttons or menu options), the user selects either the encode or decode functionality.
- For encoding:
- The user selects an image and enters text.
- The application converts the text using genData.
- modPix and encode_enc perform pixel-level modifications to hide the data, and then the modified image is output.
- For decoding:
- The user selects an image.
- The decode function processes the image and extracts the embedded text.

##### Architectural Patterns and Important Elements
- Although the project is contained within a single file, it effectively separates concerns between UI management and the steganography logic.
- Interactive frames and transitional flows (navigational methods like home() and page3()).

##### Relevant Technologies
- Tkinter (GUI creation)
- PIL/Pillow (Image processing)
- Native Python modules: os, io, messagebox for alerts, etc.

##### Specific Elements
- User Interface (UI) Component:
- Main Window (Initialization with root = Tk())
- Encode Frame (with frame1_encode and frame2_encode)
- Decode Frame (with frame1_decode and frame2_decode)
- Navigation Controls (home, page3)
- Steganography Engine:
- Data Processing: genData (converts text to binary)
- Pixel Modification: modPix (embeds binary data into image pixels)
- Encoding Routine: encode_enc (final embedding process)
- Decoding Routine: decode (extraction process)
- Interaction with External Libraries:
- Mention usage of PIL (for image handling and manipulation)
- Mention Tkinter file dialogs (for image selection)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Input
    UserInput["User Input"]:::gui

    %% UI Layer Subgraph
    subgraph "User Interface Layer"
        UIMain["Main Window (Tkinter)"]:::gui
        UINav["Navigation (home & page3)"]:::gui
        EncodeUI["Encode Frames (frame1_encode & frame2_encode)"]:::gui
        DecodeUI["Decode Frames (frame1_decode & frame2_decode)"]:::gui
    end

    %% Steganography Engine Subgraph
    subgraph "Steganography Engine"
        GenData["Data Conversion (genData)"]:::engine
        ModPix["Pixel Modification (modPix)"]:::engine
        EncodeEnc["Encoding Routine (encode_enc)"]:::engine
        Decode["Decoding Routine (decode)"]:::engine
        EndEncode["Modified Image Output"]:::engine
        EndDecode["Extracted Hidden Text"]:::engine
    end

    %% External Libraries Subgraph
    subgraph "External Libraries"
        Tkinter["Tkinter (GUI)"]:::external
        PIL["PIL/Pillow (Image Processing)"]:::external
        Native["os, io, messagebox (Utilities)"]:::external
    end

    %% Connections: User interaction flows
    UserInput --> UIMain
    UIMain --> UINav
    UIMain --> EncodeUI
    UIMain --> DecodeUI

    %% Encoding flow
    EncodeUI -->|"selects image & enters text"| GenData
    GenData -->|"converts text→binary"| ModPix
    ModPix -->|"embeds binary into pixels"| EncodeEnc
    EncodeEnc -->|"outputs encoded image"| EndEncode

    %% Decoding flow
    DecodeUI -->|"selects image"| Decode
    Decode -->|"extracts hidden text"| EndDecode

    %% External Libraries Integration
    Tkinter --- UIMain
    PIL --- GenData
    PIL --- Decode
    Native --- UIMain

    %% Click Events (paths for components)
    click UIMain "https://github.com/deadserpent/image-steganography/blob/main/ImageSteganography.py"
    click UINav "https://github.com/deadserpent/image-steganography/blob/main/ImageSteganography.py"
    click EncodeUI "https://github.com/deadserpent/image-steganography/blob/main/ImageSteganography.py"
    click DecodeUI "https://github.com/deadserpent/image-steganography/blob/main/ImageSteganography.py"
    click GenData "https://github.com/deadserpent/image-steganography/blob/main/ImageSteganography.py"
    click ModPix "https://github.com/deadserpent/image-steganography/blob/main/ImageSteganography.py"
    click EncodeEnc "https://github.com/deadserpent/image-steganography/blob/main/ImageSteganography.py"
    click Decode "https://github.com/deadserpent/image-steganography/blob/main/ImageSteganography.py"
    click Tkinter "https://github.com/deadserpent/image-steganography/blob/main/ImageSteganography.py"
    click PIL "https://github.com/deadserpent/image-steganography/blob/main/ImageSteganography.py"
    click Native "https://github.com/deadserpent/image-steganography/blob/main/ImageSteganography.py"

    %% Styles
    classDef gui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef engine fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef external fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    class UserInput gui
```
