# daniliuskosmaches/bufferdevicemanager architecture

> Architecture diagram of the GitHub repository daniliuskosmaches/bufferdevicemanager, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/daniliuskosmaches/bufferdevicemanager
- Repository: https://github.com/daniliuskosmaches/bufferdevicemanager

## Overview

BufferDeviceManager is a clipboard watcher with platform-specific behavior. On Windows, the CLI subscribes to Win+V history events, reads item IDs, compares snapshots, and prints additions or removals. On Linux, it polls the current clipboard and prints changes; this is separate from the Windows history workflow. A UDP device-discovery listener exists, but the clipboard watcher does not send data to it. Edges reflect the README and shown source; the Android file is only a stub.

Main entry points: [`internal/clipboard/windows.go`](https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/clipboard/windows.go) (History CLI), [`internal/clipboard/events_windows.go`](https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/clipboard/events_windows.go) (Event subscriptions), [`internal/clipboard/history_windows.go`](https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/clipboard/history_windows.go) (History reader), [`internal/clipboard/linux.go`](https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/clipboard/linux.go) (Clipboard poller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_win["Windows history"]
  node_wincli["History CLI<br/>[windows.go]"]
  node_history["History reader<br/>[history_windows.go]"]
  node_events["Event subscriptions<br/>[events_windows.go]"]
  node_dispatcher["Dispatcher queue<br/>[events_windows.go]"]
  node_diff["Snapshot diff<br/>[diff.go]"]
end

subgraph group_linux["Linux clipboard"]
  node_linuxwatch["Clipboard poller<br/>[linux.go]"]
end

subgraph group_network["Device discovery"]
  node_discovery["Device listener<br/>[Network.go]"]
end

node_user(("CLI user"))
node_winrt["Windows Runtime"]
node_wlclipboard["wl-clipboard"]
node_devicepeer(("UDP device peer"))

node_user -->|"runs CLI"| node_wincli
node_wincli -->|"reads history"| node_history
node_wincli -->|"subscribes"| node_events
node_wincli -->|"starts queue"| node_dispatcher
node_wincli -->|"waits for signals"| node_events
node_history -->|"calls history API"| node_winrt
node_events -->|"registers handlers"| node_winrt
node_wincli -->|"compares snapshots"| node_diff
node_user -->|"runs app"| node_linuxwatch
node_linuxwatch -->|"reads clipboard"| node_wlclipboard
node_devicepeer -->|"sends UDP packet"| node_discovery

click node_wincli "https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/clipboard/windows.go"
click node_history "https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/clipboard/history_windows.go"
click node_events "https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/clipboard/events_windows.go"
click node_dispatcher "https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/clipboard/events_windows.go"
click node_diff "https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/historydiff/diff.go"
click node_linuxwatch "https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/clipboard/linux.go"
click node_discovery "https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/transport/Network.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_wincli,node_history,node_events,node_dispatcher,node_diff,node_user toneBlue
class node_linuxwatch toneAmber
class node_discovery toneMint
class node_winrt,node_wlclipboard,node_devicepeer toneIndigo
```

## Components

### Windows history

- [History CLI](https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/clipboard/windows.go): `internal/clipboard/windows.go`
- [History reader](https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/clipboard/history_windows.go): `internal/clipboard/history_windows.go`
- [Event subscriptions](https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/clipboard/events_windows.go): `internal/clipboard/events_windows.go`
- [Dispatcher queue](https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/clipboard/events_windows.go): `internal/clipboard/events_windows.go`
- [Snapshot diff](https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/historydiff/diff.go): `internal/historydiff/diff.go`

### Linux clipboard

- [Clipboard poller](https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/clipboard/linux.go): `internal/clipboard/linux.go`

### Device discovery

- [Device listener](https://github.com/daniliuskosmaches/bufferdevicemanager/blob/master/internal/transport/Network.go): `internal/transport/Network.go`

### Other components

- **CLI user**
- **Windows Runtime**
- **wl-clipboard**
- **UDP device peer**

## Connections

- CLI user → History CLI: runs CLI (evidence: `README.md`)
- History CLI → History reader: reads history (evidence: `internal/clipboard/windows.go`)
- History CLI → Event subscriptions: subscribes (evidence: `internal/clipboard/windows.go`)
- History CLI → Dispatcher queue: starts queue (evidence: `internal/clipboard/windows.go`)
- History CLI → Event subscriptions: waits for signals (evidence: `internal/clipboard/windows.go`)
- History reader → Windows Runtime: calls history API (evidence: `internal/clipboard/history_windows.go`)
- Event subscriptions → Windows Runtime: registers handlers (evidence: `internal/clipboard/events_windows.go`)
- History CLI → Snapshot diff: compares snapshots (evidence: `internal/clipboard/windows.go`)
- CLI user → Clipboard poller: runs app (evidence: `README.md`)
- Clipboard poller → wl-clipboard: reads clipboard (evidence: `README.md`)
- UDP device peer → Device listener: sends UDP packet (evidence: `internal/transport/Network.go`)
