# yunis-du/flash-cat architecture

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

- Interactive diagram: https://gitdiagram.com/yunis-du/flash-cat
- Repository: https://github.com/yunis-du/flash-cat

## Overview

##### Project’s Main Components
- Client Applications:
- GUI Application (“app”): Contains a graphical interface, tabs for sending, receiving, and settings. The “gui” directory inside “app/src” defines the aesthetics (styles, themes, progress bars) and functional tabs.
- CLI Application (“cli”): Offers command-line interactions for sending, receiving, and displaying progress. Its modules (send.rs, recv.rs, progress.rs) wrap the core file transfer functionalities.
- Core Functionality (“core”): Provides the main logic for performing sender and receiver operations (e.g., in core/src/sender.rs and core/src/receiver.rs).
- Shared/Common Libraries (“common”): Houses utilities for encryption, logging, networking, file system interactions, and protocol definitions (contained in proto/relay.proto). This is the foundation reused by both the GUI, CLI, and relay.
- Relay Server (“relay”): Implements a relay service that facilitates file transfers over a network (see relay/src directory with grpc.rs, relay.rs, session.rs, etc).

##### Relationships and Interactions
- The Client Applications (both GUI and CLI) interact with the Core functionality to access sending/receiving routines.
- Both core and application layers depend on the Common library for cryptography, networking utilities, logging, and consistent protocol definitions.
- If a user opts to use their own relay server (as described in the README), the Client Applications connect to the Relay Server. The Relay module manages network sessions and ensures data is properly routed between sender and receiver.
- Data flows generally from the client interface to the core backend and then to the relay server (if deployed), with encryption/decryption taking place via routines in the Common module.

##### Architectural Patterns and Design Principles
- Modularity & Separation of Concerns:
- The project uses multiple crates (app, cli, core, common, relay) to isolate different responsibilities.
- The GUI is separated into specialized modules (styles, tabs) which decouple presentation from business logic.
- Reusability:
- Shared functionalities (e.g., encryption algorithms, network utilities) appear in “common” to avoid duplication across clients.
- Cross-platform Design:
- The existence of separate install scripts and different user interfaces (CLI and GUI) hints at a design careful to support various operating systems.

a. Layout of Main Components:
- Blocks for “GUI Client (app)” and “CLI Client (cli)” to represent user interfaces.
- A block for “Core Engine” to capture the sending/receiving logic (from the “core” crate).
- A “Relay Server” block depicting the server-side component that users can deploy.
- Optionally, include an “Installer/Deployment” block to represent the installation scripts and package manager support.

b. Relationships and Data Flow:
- That when in relay mode, data flows from the sender (client) to the relay server and then to the receiver (client), ensuring secure transmission.

c. Technology and Frameworks:
- Mention that the GUI is interacting with several submodules (tabs, widgets, styles) to provide a rich user experience.
- That the common module supports gRPC standards in the “relay” component.

d. Visual Presentation Guidelines:
- Use clear, easy-to-read labels for each block/component.
- Rectangles for applications (GUI, CLI, Relay).
- Ovals or rounded rectangles for shared libraries (Core, Common).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Applications Subgraph
    subgraph "Client Applications"
        A1["GUI Client (app)"]:::app
        A1a["GUI Tabs"]:::app
        A1b["GUI Styles"]:::app
        A2["CLI Client (cli)"]:::cli
        A2a["CLI Send Module"]:::cli
        A2b["CLI Receive Module"]:::cli
        A2c["CLI Progress Module"]:::cli
    end

    %% Core and Shared Services Subgraph
    subgraph "Core and Shared Services"
        B1["Core Engine (core)"]:::core
        B1a["Core Sender"]:::core
        B1b["Core Receiver"]:::core
        C1["Common Library (common)"]:::common
        C1a["Proto Definitions"]:::common
    end

    %% Relay and Deployment Subgraph
    subgraph "Relay and Deployment"
        D1["Relay Server (relay)"]:::relay
        D1a["relay.rs"]:::relay
        D1b["grpc.rs"]:::relay
        D1c["session.rs"]:::relay
        E1["Installer/Deployment (scripts)"]:::installer
    end

    %% Containment relationships within Client Applications
    A1 -->|"contains"| A1a
    A1 -->|"contains"| A1b
    A2 -->|"contains"| A2a
    A2 -->|"contains"| A2b
    A2 -->|"contains"| A2c

    %% Containment relationships within Core Engine
    B1 -->|"implements"| B1a
    B1 -->|"implements"| B1b

    %% Containment relationship within Common Library
    C1 -->|"defines"| C1a

    %% Containment relationships within Relay Server
    D1 -->|"includes"| D1a
    D1 -->|"includes"| D1b
    D1 -->|"includes"| D1c

    %% Inter-component interactions
    A1 -->|"calls"| B1
    A2 -->|"calls"| B1
    B1 -->|"depends_on"| C1
    A1 -->|"relay_mode"| D1
    A2 -->|"relay_mode"| D1
    B1 -->|"relay_transit"| D1

    %% Installer connects to all for deployment
    E1 ---|"deploys"| A1
    E1 ---|"deploys"| A2
    E1 ---|"deploys"| B1
    E1 ---|"deploys"| C1
    E1 ---|"deploys"| D1

    %% Click Events for GUI Client (app) and its submodules
    click A1 "https://github.com/yunis-du/flash-cat/tree/master/app/src/gui"
    click A1a "https://github.com/yunis-du/flash-cat/tree/master/app/src/gui/tabs"
    click A1b "https://github.com/yunis-du/flash-cat/tree/master/app/src/gui/styles"

    %% Click Events for CLI Client (cli) and its modules
    click A2 "https://github.com/yunis-du/flash-cat/tree/master/cli/src"
    click A2a "https://github.com/yunis-du/flash-cat/blob/master/cli/src/send.rs"
    click A2b "https://github.com/yunis-du/flash-cat/blob/master/cli/src/receive.rs"
    click A2c "https://github.com/yunis-du/flash-cat/blob/master/cli/src/progress.rs"

    %% Click Events for Core Engine (core) modules
    click B1 "https://github.com/yunis-du/flash-cat/tree/master/core/src"
    click B1a "https://github.com/yunis-du/flash-cat/blob/master/core/src/sender.rs"
    click B1b "https://github.com/yunis-du/flash-cat/blob/master/core/src/receiver.rs"

    %% Click Events for Common Library (common)
    click C1 "https://github.com/yunis-du/flash-cat/tree/master/common"
    click C1a "https://github.com/yunis-du/flash-cat/blob/master/common/proto/relay.proto"

    %% Click Events for Relay Server (relay) components
    click D1 "https://github.com/yunis-du/flash-cat/tree/master/relay/src"
    click D1a "https://github.com/yunis-du/flash-cat/blob/master/relay/src/relay.rs"
    click D1b "https://github.com/yunis-du/flash-cat/blob/master/relay/src/grpc.rs"
    click D1c "https://github.com/yunis-du/flash-cat/blob/master/relay/src/session.rs"

    %% Styles
    classDef app fill:#a2d0c1,stroke:#333,stroke-width:2px
    classDef cli fill:#f9d56e,stroke:#333,stroke-width:2px
    classDef core fill:#f7a072,stroke:#333,stroke-width:2px
    classDef common fill:#90caf9,stroke:#333,stroke-width:2px
    classDef relay fill:#c5cae9,stroke:#333,stroke-width:2px
    classDef installer fill:#ffe082,stroke:#333,stroke-width:2px
```
