# ductai05/s2y2_computernetworking architecture

> Architecture diagram of the GitHub repository ductai05/s2y2_computernetworking, 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/ductai05/s2y2_computernetworking
- Repository: https://github.com/ductai05/s2y2_computernetworking

## Overview

##### Project’s Main Components
- Client Module – Found in the “client” directory, this module (client/client.cpp) is built upon SDL2 (as can be seen from the extensive “DL2”, “DL2_IMAGE”, and “DL2_TTF” subdirectories) and is likely used for the remote control interface. It acts as the point of interaction for the operator.
- Server Module – Located in the “server” directory, this contains server/server.cpp, dispatcher.cpp, and additional components (e.g., take_screenshot.cpp). The Server is responsible for controlling and managing tasks in the LAN cluster.
- Mail Module – The “mail” folder holds source files (send.cpp, listen.cpp) and batch scripts for email interactions. This module uses cURL with Winsock to handle SMTP (for sending commands) and IMAP (for receiving control emails) with Gmail.
- External Services – Gmail is used as an intermediary communication channel. Emails sent from the client (or via the server’s mail handler) are received from and sent to Gmail servers, effectively bridging the network gap.

##### Relationships and Interactions
- Optionally, denote the LAN network boundaries, indicating that the Client and Server are on a local network while the Mail Module interfaces with an external network (Gmail).

##### Architectural Patterns and Design Principles
- Communication via Asynchronous Messaging – The use of sockets for immediate communication and email for asynchronous command/control suggests employing both real-time and delayed messaging methods.
- Use of External Libraries – Identify that the Client uses the SDL2 library for graphics/UI and that the Mail Module and possibly parts of the Server use cURL and Winsock for network communications. Optionally annotate these details near each component.

##### Additional Detail to Capture
- Mention any configuration or build scripts that might indicate deployment practices (e.g., the “complie.bat” in the client, “run_server.bat”, and “run_taskDispatcher.bat” in the server).
- That the “add-on” directory contains additional resources such as OpenSSL executables and a complete LaTeX report—this underscores that the project comes with detailed documentation which might include versioning or secure connection aspects (if OpenSSL is used for encryption).

- The Client, Server, and Mail modules as primary components.
- Their interconnections: Client ↔ Server (socket communication), and Server ↔ Mail Module ↔ Gmail (email protocols, cURL/Winsock based).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Local Network Components
    subgraph "Local Network"
        ClientApp["Client Application (SDL2)"]:::client
        subgraph "Server Module"
            ServerApp["Server Application"]:::server
            Dispatcher["Dispatcher"]:::server
            Screenshot["Screenshot Handler"]:::server
            ServerApp -->|"internal"| Dispatcher
            ServerApp -->|"internal"| Screenshot
        end
    end

    %% Mail and External Communication Components
    subgraph "Mail Communication"
        subgraph "Mail Module"
            MailSender["Email Sender"]:::mail
            MailListener["Email Listener"]:::mail
        end
        Gmail["Gmail Server"]:::external
    end

    %% Inter-module Communications
    ClientApp -->|"Socket(Winsock)"| ServerApp
    ServerApp -->|"SMTP/IMAP"| MailSender
    MailListener -->|"SMTP/IMAP"| ServerApp
    MailSender -->|"SMTP"| Gmail
    Gmail -->|"IMAP"| MailListener

    %% Click Events for Component Mappings
    click ClientApp "https://github.com/ductai05/s2y2_computernetworking/blob/main/client/client.cpp"
    click ServerApp "https://github.com/ductai05/s2y2_computernetworking/blob/main/server/server.cpp"
    click Dispatcher "https://github.com/ductai05/s2y2_computernetworking/blob/main/server/dispatcher.cpp"
    click Screenshot "https://github.com/ductai05/s2y2_computernetworking/blob/main/server/take_screenshot.cpp"
    click MailSender "https://github.com/ductai05/s2y2_computernetworking/blob/main/mail/send.cpp"
    click MailListener "https://github.com/ductai05/s2y2_computernetworking/blob/main/mail/listen.cpp"

    %% Styles for visual differentiation
    classDef client fill:#AEDFF7,stroke:#333,stroke-width:2px;
    classDef server fill:#F7D6AE,stroke:#333,stroke-width:2px;
    classDef mail fill:#B2F7B2,stroke:#333,stroke-width:2px;
    classDef external fill:#FFE4B5,stroke:#333,stroke-width:2px;
```
