# decipher3114/capter architecture

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

- Interactive diagram: https://gitdiagram.com/decipher3114/capter
- Repository: https://github.com/decipher3114/capter

## Overview

The project is a cross-platform screen capture tool written in Rust, which uses a minimalistic and user-friendly GUI framework (hinted by the credits to the iced community). Its primary purpose is to offer fast and efficient screen capturing with annotation and clipboard support across Windows, Linux, and macOS environments.

##### Main Components
- Module: Housed in src/capture, this module handles the core screen capture functionality – capturing fullscreen, window, or cropped areas, and includes files for canvas manipulation, cropping, drawing annotations (rectangle, circle, etc.), modes, and updating of the capture.
- Configuration and Settings: Managed within src/config and src/settings, these modules handle runtime configurations and user settings (initialization, updating, and view rendering for settings).
- System Integration & Utilities: Other critical pieces include modules like src/ipc for inter-process communications, src/key_listener for global key events, src/notify for notifications, src/subscription for handling subscription events, and src/update for checking or handling updates.
- Build and Cross-Platform Assets: The assets folder contains images, fonts, and platform-specific resources (Linux, macOS, Windows), which ensure the UI and iconography integrate properly on different operating systems.
- Application Entry Point: The src/main.rs which ties everything together and likely initializes and configures the various components.

##### Relationships and Interactions
- User Interaction: The UI layer receives user input which is processed through event listeners (key_listener) and leads to actions in the capture or settings modules.
- Workflow: The capture module interacts with helper functions (src/capture/helper.rs) and update processes (src/capture/update.rs) to process screen data and annotations.
- Settings and Configuration: User-modified settings via the settings module affect both UI theming and capture behaviour. This can be represented by showing directional flows from the settings components to both UI and capture modules.

##### Architectural Patterns & Design Principles
- Modularity: The clear separation into modules like capture, settings, and theme shows a modular design.
- Layered Architecture: Separate presentation (UI/theme/view) from business logic (capture, configuration) and system integrations (IPC, key_listener, update) to encourage maintainability.
- Event-Driven Interaction: Indicate how user actions (mouse clicks, key events) initiate a chain of events leading to screen capture and updates.

## Diagram (Mermaid)

```mermaid
flowchart TD
    U("User"):::integration
    B("Main Application"):::core

    subgraph "UI Layer"
        UI1("View"):::frontend
        UI2("Tray Icon"):::frontend
        UI3("Theme"):::frontend
    end

    subgraph "Capture Module"
        CAP("Core Capture"):::business
    end

    subgraph "Settings & Configuration"
        CFG("Configuration"):::business
        SET("Settings"):::business
    end

    subgraph "System Integration & Utilities"
        SYS1("IPC"):::integration
        SYS2("Key Listener"):::integration
        SYS3("Notifications"):::integration
        SYS4("Subscription"):::integration
        SYS5("Update Handling"):::integration
    end

    AST("Assets"):::resource

    U -->|"UserInput"| UI1

    B -->|"Initializes"| UI1
    B -->|"Initializes"| CAP
    B -->|"Initializes"| CFG
    B -->|"Initializes"| SET
    B -->|"Initializes"| SYS1
    B -->|"Initializes"| SYS2
    B -->|"Initializes"| SYS3
    B -->|"Initializes"| SYS4
    B -->|"Initializes"| SYS5
    B -->|"Loads"| AST

    UI1 -->|"CaptureCommand"| CAP
    UI1 -->|"OpenSettings"| SET

    SET -->|"ConfigUpdate"| UI1
    SET -->|"ConfigUpdate"| CAP

    SYS2 -->|"TriggerCapture"| CAP
    SYS1 -->|"SendMessages"| B
    SYS3 -->|"Notify"| UI1

    AST -->|"ResourceAccess"| UI1

    CAP -->|"CheckForUpdates"| SYS5

    SYS4 -->|"EventSubscription"| B

    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef business fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef integration fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef resource fill:#DDA0DD,stroke:#000,stroke-width:1px;
    classDef core fill:#FF6347,stroke:#000,stroke-width:1px;

    click UI1 "https://github.com/decipher3114/capter/blob/master/src/view.rs"
    click UI2 "https://github.com/decipher3114/capter/blob/master/src/tray_icon.rs"
    click UI3 "https://github.com/decipher3114/capter/tree/master/src/theme"
    click CAP "https://github.com/decipher3114/capter/tree/master/src/capture"
    click CFG "https://github.com/decipher3114/capter/tree/master/src/config"
    click SET "https://github.com/decipher3114/capter/tree/master/src/settings"
    click SYS1 "https://github.com/decipher3114/capter/blob/master/src/ipc.rs"
    click SYS2 "https://github.com/decipher3114/capter/blob/master/src/key_listener.rs"
    click SYS3 "https://github.com/decipher3114/capter/blob/master/src/notify.rs"
    click SYS4 "https://github.com/decipher3114/capter/blob/master/src/subscription.rs"
    click SYS5 "https://github.com/decipher3114/capter/blob/master/src/update.rs"
    click AST "https://github.com/decipher3114/capter/tree/master/assets"
    click B "https://github.com/decipher3114/capter/blob/master/src/main.rs"
```
