# srijan023/seamless_sync architecture

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

- Interactive diagram: https://gitdiagram.com/srijan023/seamless_sync
- Repository: https://github.com/srijan023/seamless_sync

## Overview

##### Main Components
- User Interface (UI): Built using GTK (GTK4) with its implementation split between the src/ui directory (functions such as createButton, createMainWindow, and other UI components) and the related header files in include.
- Core Business Logic: Located in src, which includes the main application logic as well as specific functions for file sending, receiving, starting scans, etc. This layer orchestrates interactions between the UI, network, and encryption modules.
- Network Communication Layer: This handles direct LAN communication using sockets. Notice the presence of UDP, SSDP, and TCP client/server code spread between archive and src as well as helper functions in include (like getClientSocket, getServerSocket). This layer is responsible for both the file transfer and the integrated chat function.
- Security/Encryption Module: Provides AES encryption (files AES.h and AES.c) and RSA-based key initialization and operations. This ensures that encryption/decryption happen seamlessly when files or messages are transmitted.
- Utility/Helper Components: A set of functions that handle tasks like error handling (SSDPErrorHandle.c, UDPErrorHandler.c), IP retrieval (getMyIp.c), and configuration settings (headerConfig.c). These are part of the overall orchestration but help maintain modularity.

##### Relationships & Interactions
- The UI Layer communicates with the Core Business Logic through callback functions (onStartClicked, onSsdpScanCompleted, etc.) which then trigger network actions or file transfer procedures.
- The Core Logic triggers calls to the Network Communication Layer to establish connections (using sockets) and exchange data between devices. It also calls Encryption Modules to secure the transmitting data.
- The Encryption Module is used by both the file sender and receiver for encrypting and decrypting data respectively.
- Utility functions are utilized throughout, for error handling, configuration, and establishing network connections.
- The archive folder contains sample implementations and tests that provide additional clarity on how socket communication and different protocols are implemented, though the main logic is in the src folder.

##### Architectural Patterns & Design Principles
- Modularity: The code is separated into directories by concerns—headers (include), source (src), and experimental/demo code (archive). This allows for easier testing and debugging.
- Layered Architecture: There are clear layers—from the presentation (GTK driven UI in src/ui) to the business logic and network/encryption layers.
- Separation of Concerns: By isolating network operations, UI interactions, and security features, the design encourages loose coupling and better maintainability.
- Use of Standard Libraries & Frameworks: Integration with GTK4 for GUI and reliance on socket libraries in Linux ensures that industry-standard components are used.

##### Technologies, Frameworks, and Libraries
- GTK4: For building the GUI.
- GLib: Provides utilities and data structures required by GTK and overall application logic.
- CMake: Project configuration and build system.
- GCC/Clang: C compilers.
- Standard POSIX Socket Libraries for network communications.
- Custom encryption using AES and RSA.

## Diagram (Mermaid)

```mermaid
flowchart TD

    subgraph "User Interface (GTK4)"
        ui1("createMainWindow.c"):::ui
        ui2("createButton.c"):::ui
        ui3("onStartClicked.c"):::ui
        ui4("createMainWindow.h"):::ui
        ui5("createButton.h"):::ui
        ui6("onStartClicked.h"):::ui
    end

    subgraph "Core Business Logic"
        core1("main.c"):::core
        core2("sendFile.c"):::core
        core3("receiveFile.c"):::core
        core4("headerConfig.c"):::core
    end

    subgraph "Network Communication Layer"
        net1("TCPClient.c"):::network
        net2("TCPServer.c"):::network
        net3("joinSSDP.c"):::network
        net4("fileTransfer_client.c"):::network
        net5("fileTransfer_server.c"):::network
        net6("getClientSocket.c"):::network
        net7("getServerSocket.c"):::network
        net8("getClientSocket.h"):::network
        net9("getServerSocket.h"):::network
        net10("UDPListen.h"):::network
        net11("UDPSend.h"):::network
        net12("joinSSDP.h"):::network
    end

    subgraph "Security/Encryption Module"
        sec1("AES.h"):::security
        sec2("RSA.h"):::security
        sec3("RSAKeyInitializer.h"):::security
        sec4("AES.c"):::security
        sec5("RSA.c"):::security
        sec6("RSAKeyInitializer.c"):::security
    end

    subgraph "Utility/Helper Components"
        util1("getMyIp.h"):::utility
        util2("SSDPErrorHandle.h"):::utility
        util3("UDPErrorHandle.h"):::utility
        util4("activate.h"):::utility
        util5("check_network_status.h"):::utility
        util6("getMyIp.c"):::utility
        util7("SSDPErrorHandle.c"):::utility
        util8("UDPErrorHandler.c"):::utility
    end

    %% Connections between layers
    ui3 -->|"triggers"| core1
    core2 -->|"sendFile"| net1
    core3 -->|"receiveFile"| net2
    core2 -->|"EncryptData"| sec4
    core4 -->|"Error/Config"| util6

    %% Click Events for User Interface (GTK4)
    click ui1 "https://github.com/srijan023/seamless_sync/blob/main/src/ui/createMainWindow.c"
    click ui2 "https://github.com/srijan023/seamless_sync/blob/main/src/ui/createButton.c"
    click ui3 "https://github.com/srijan023/seamless_sync/blob/main/src/ui/onStartClicked.c"
    click ui4 "https://github.com/srijan023/seamless_sync/blob/main/include/createMainWindow.h"
    click ui5 "https://github.com/srijan023/seamless_sync/blob/main/include/createButton.h"
    click ui6 "https://github.com/srijan023/seamless_sync/blob/main/include/onStartClicked.h"

    %% Click Events for Core Business Logic
    click core1 "https://github.com/srijan023/seamless_sync/blob/main/src/main.c"
    click core2 "https://github.com/srijan023/seamless_sync/blob/main/src/sendFile.c"
    click core3 "https://github.com/srijan023/seamless_sync/blob/main/src/receiveFile.c"
    click core4 "https://github.com/srijan023/seamless_sync/blob/main/src/headerConfig.c"

    %% Click Events for Network Communication Layer
    click net1 "https://github.com/srijan023/seamless_sync/blob/main/archive/TCPClient.c"
    click net2 "https://github.com/srijan023/seamless_sync/blob/main/archive/TCPServer.c"
    click net3 "https://github.com/srijan023/seamless_sync/blob/main/archive/joinSSDP.c"
    click net4 "https://github.com/srijan023/seamless_sync/blob/main/archive/fileTransfer_client.c"
    click net5 "https://github.com/srijan023/seamless_sync/blob/main/archive/fileTransfer_server.c"
    click net6 "https://github.com/srijan023/seamless_sync/blob/main/src/getClientSocket.c"
    click net7 "https://github.com/srijan023/seamless_sync/blob/main/src/getServerSocket.c"
    click net8 "https://github.com/srijan023/seamless_sync/blob/main/include/getClientSocket.h"
    click net9 "https://github.com/srijan023/seamless_sync/blob/main/include/getServerSocket.h"
    click net10 "https://github.com/srijan023/seamless_sync/blob/main/include/UDPListen.h"
    click net11 "https://github.com/srijan023/seamless_sync/blob/main/include/UDPSend.h"
    click net12 "https://github.com/srijan023/seamless_sync/blob/main/include/joinSSDP.h"

    %% Click Events for Security/Encryption Module
    click sec1 "https://github.com/srijan023/seamless_sync/blob/main/include/AES.h"
    click sec2 "https://github.com/srijan023/seamless_sync/blob/main/include/RSA.h"
    click sec3 "https://github.com/srijan023/seamless_sync/blob/main/include/RSAKeyInitializer.h"
    click sec4 "https://github.com/srijan023/seamless_sync/blob/main/src/AES.c"
    click sec5 "https://github.com/srijan023/seamless_sync/blob/main/src/RSA.c"
    click sec6 "https://github.com/srijan023/seamless_sync/blob/main/src/RSAKeyInitializer.c"

    %% Click Events for Utility/Helper Components
    click util1 "https://github.com/srijan023/seamless_sync/blob/main/include/getMyIp.h"
    click util2 "https://github.com/srijan023/seamless_sync/blob/main/include/SSDPErrorHandle.h"
    click util3 "https://github.com/srijan023/seamless_sync/blob/main/include/UDPErrorHandle.h"
    click util4 "https://github.com/srijan023/seamless_sync/blob/main/include/activate.h"
    click util5 "https://github.com/srijan023/seamless_sync/blob/main/include/check_network_status.h"
    click util6 "https://github.com/srijan023/seamless_sync/blob/main/src/getMyIp.c"
    click util7 "https://github.com/srijan023/seamless_sync/blob/main/src/SSDPErrorHandle.c"
    click util8 "https://github.com/srijan023/seamless_sync/blob/main/src/UDPErrorHandler.c"

    %% Styles
    classDef ui fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef core fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef network fill:#FFCCBC,stroke:#D84315,stroke-width:2px;
    classDef security fill:#E1BEE7,stroke:#6A1B9A,stroke-width:2px;
    classDef utility fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;
```
