# sathvik-rao/clipcascade architecture

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

- Interactive diagram: https://gitdiagram.com/sathvik-rao/clipcascade
- Repository: https://github.com/sathvik-rao/clipcascade

## Overview

##### Overall Project Type and Purpose
- ClipCascade is a cross-platform, lightweight clipboard synchronizer. It is an open-source full-stack application that consists of multiple client applications (desktop – both GUI and CLI – and mobile) as well as a backend server. Its main goal is to automatically sync clipboard contents securely across devices using both server-mediated and peer-to-peer (P2P) modes.
- The README emphasizes real-time clipboard sync, end-to-end encryption, cross-platform support, and self-hosting capabilities (Docker, standalone JAR).

##### Main Architectural Components
a. Client-side Applications:
- Desktop Application (ClipCascade_Desktop):
– Subdivided into UI components (GUI & CLI) and core business logic.
– Clipboard management: Monitors clipboard events across different operating systems using platform-specific modules (e.g., clipboard_monitor_win.py, clipboard_monitor_mac.py, clipboard_monitor_linux.py).
– Communication: Contains modules for WebSocket communication (ws_interface, stomp_ws) and P2P operations (p2p/p2p_manager.py).
– Supporting utilities: Encryption (utils/cipher_manager.py) and notification (utils/notification_manager.py).
- Mobile Application (ClipCascade_Mobile):
– Contains React Native code with native modules for Android (native Kotlin/Java files) and iOS-specific resources.
– Implements similar synchronization logic and secure communication.

b. Server-side Application (ClipCascade_Server):
- A Java-based backend built with Maven, using Spring Boot-like configuration (see packages in config, controllers, model, service, and repo folders).
- Handles authentication (custom authentication handlers), user management, REST endpoints, and WebSocket endpoints.
- Integrates configuration for P2P signaling and STOMP-based message brokers (external broker, ActiveMQ integration).
- Provides support for self-hosting (Docker, docker-compose configurations) and configurable environment variables.

c. Integration & Communication Layers:
- Real-time Messaging Channels:
– WebSocket endpoints for live clipboard updates (implemented in both the server and client via ws_interface and stomp_ws).
– P2P messaging streams (when CC_P2P_ENABLED is true) that allow direct clipboard sync between devices.
- Security Layer:
– End-to-end encryption modules on the client for encrypting clipboard data before sending it and decrypting on the receiver.
– Server-side verification of authentication, enforcing secure transmission and user isolation.
- External Services:
– Option for external STOMP broker integration.
– Environment-based configuration (reverse proxy, load balancing) that can be illustrated, including Docker containers.

- Client Tier:
- Annotations for clipboard monitoring, encryption, and UI details.
- Communication Layer:
▪ Indicate encryption modules (e.g., “Cipher Manager”) adjacent to these communication links.
- Server Tier:
▪ Backend Server: With sub-modules for authentication, REST endpoints, WebSocket endpoints, and business logic (controllers, services, repositories). Emphasize the configuration elements (security, STOMP integration, and environment variables).

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Client Tier
    subgraph "Client Tier"
        subgraph "Desktop Application"
            CLI["CLI (Desktop)"]:::client
            GUI["GUI (Desktop)"]:::client
            Clipboard["Clipboard Management"]:::client
            WS["WS Interface"]:::client
            P2P["P2P Manager"]:::client
            Cipher["Cipher Manager"]:::client
            Notification["Notification System"]:::client
        end
        subgraph "Mobile Application"
            Mobile["Mobile App"]:::client
        end
    end

    %% Communication Layer
    subgraph "Communication Layer"
        WS_Comm["WebSocket Channel"]:::comm
        P2P_Comm["P2P Channel"]:::comm
    end

    %% Server Tier
    subgraph "Server Tier"
        Server["Backend Server (Java & Maven)"]:::server
        Database(("Database")):::database
        subgraph "Docker Deployment"
            Dockerfile["Dockerfile"]:::server
            DockerCompose["docker-compose"]:::server
        end
    end

    %% Connections in Client Tier
    CLI -->|"triggers"| Clipboard
    GUI -->|"triggers"| Clipboard
    Clipboard -->|"sends data"| Cipher
    Cipher -->|"encrypts data"| WS
    Cipher -->|"encrypts data"| P2P
    WS -->|"communicates"| WS_Comm
    P2P -->|"communicates"| P2P_Comm
    Mobile -->|"communicates"| WS_Comm

    %% Connections to Server Tier
    WS_Comm -->|"syncs via WS"| Server
    P2P_Comm -->|"syncs via P2P"| Server
    Server -->|"reads/writes"| Database
    Dockerfile -->|"deploys to"| Server
    DockerCompose -->|"deploys to"| Server

    %% Click Events for Client Components
    click CLI "https://github.com/sathvik-rao/clipcascade/tree/main/ClipCascade_Desktop/src/cli"
    click GUI "https://github.com/sathvik-rao/clipcascade/tree/main/ClipCascade_Desktop/src/gui"
    click Clipboard "https://github.com/sathvik-rao/clipcascade/tree/main/ClipCascade_Desktop/src/clipboard"
    click WS "https://github.com/sathvik-rao/clipcascade/blob/main/ClipCascade_Desktop/src/interfaces/ws_interface.py"
    click P2P "https://github.com/sathvik-rao/clipcascade/blob/main/ClipCascade_Desktop/src/p2p/p2p_manager.py"
    click Cipher "https://github.com/sathvik-rao/clipcascade/blob/main/ClipCascade_Desktop/src/utils/cipher_manager.py"
    click Notification "https://github.com/sathvik-rao/clipcascade/blob/main/ClipCascade_Desktop/src/utils/notification_manager.py"
    click Mobile "https://github.com/sathvik-rao/clipcascade/tree/main/ClipCascade_Mobile/src"
    
    %% Click Event for Server Components
    click Server "https://github.com/sathvik-rao/clipcascade/tree/main/ClipCascade_Server/ClipCascade_Backend/src/main/java/com/acme/clipcascade"
    click Dockerfile "https://github.com/sathvik-rao/clipcascade/tree/main/ClipCascade_Server/ClipCascade_Backend/Dockerfile"
    click DockerCompose "https://github.com/sathvik-rao/clipcascade/tree/main/ClipCascade_Server/docker-compose"

    %% Styling
    classDef client fill:#AEDFF7,stroke:#036,stroke-width:2px;
    classDef comm fill:#FFF2B2,stroke:#B58900,stroke-width:2px;
    classDef server fill:#F7D6AE,stroke:#D2691E,stroke-width:2px;
    classDef database fill:#C3F7C3,stroke:#2E8B57,stroke-width:2px;
```
