# ezykl/ghostnotes architecture

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

- Interactive diagram: https://gitdiagram.com/ezykl/ghostnotes
- Repository: https://github.com/ezykl/ghostnotes

## Overview

GhostNotes is a Windows floating sticky-note app designed to keep private notes visible to the user but excluded from screen capture. The main workflow starts the app, restores persisted notes into floating editable windows, and saves note changes in the background. Users can create and toggle notes with global hotkeys or the system tray; windows also support rich-text formatting, collapse-to-pill behavior, and appearance settings. The excerpts show the main orchestration and several service calls; other feature details are documented in the README but their implementations were not fully sampled.

Main entry points: [`src/GhostNotes/NoteManager.cs`](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/NoteManager.cs) (Note manager), [`src/GhostNotes/App.xaml.cs`](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/App.xaml.cs) (App startup), [`src/GhostNotes/Interop/CaptureGuard.cs`](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Interop/CaptureGuard.cs) (Capture protection), [`src/GhostNotes/TrayController.cs`](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/TrayController.cs) (System tray)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["App runtime"]
  node_app["App startup<br/>[App.xaml.cs]"]
  node_manager["Note manager<br/>[NoteManager.cs]"]
  node_tray["System tray<br/>[TrayController.cs]"]
  node_icon["Tray icon builder<br/>[IconBuilder.cs]"]
end

subgraph group_notes["Notes and editing"]
  node_model["Note model<br/>[Note.cs]"]
  node_window["Note window<br/>[NoteWindow.xaml.cs]"]
end

subgraph group_platform["Windows integration"]
  node_single_instance["Single instance"]
  node_capture["Capture protection<br/>[CaptureGuard.cs]"]
  node_native["Windows native APIs<br/>[NativeMethods.cs]"]
  node_version["OS version gate<br/>[VersionGate.cs]"]
  node_hotkeys["Global hotkeys<br/>[HotkeyService.cs]"]
  node_selection["Hotkey selection<br/>[HotkeySelection.cs]"]
end

subgraph group_services["Persistence and utilities"]
  node_repository[("Note repository<br/>[NoteRepository.cs]")]
  node_autosave["Autosave scheduler"]
  node_clamp["Position and zoom<br/>[Clamp.cs]"]
end

node_user(("User"))
node_windows(("Windows desktop"))

node_user -->|"launches"| node_app
node_app -->|"checks instance"| node_single_instance
node_app -->|"initializes"| node_capture
node_app -->|"creates"| node_manager
node_app -->|"registers"| node_hotkeys
node_app -->|"creates"| node_tray
node_manager -->|"loads and saves"| node_repository
node_manager -->|"manages"| node_model
node_manager -->|"attaches"| node_window
node_manager -->|"schedules saves"| node_autosave
node_manager -->|"passes guard"| node_capture
node_manager -->|"clamps geometry"| node_clamp
node_repository -->|"serializes"| node_model
node_window -->|"edits and displays"| node_model
node_window -->|"applies protection"| node_capture
node_window -->|"uses window APIs"| node_native
node_hotkeys -->|"selects fallback"| node_selection
node_hotkeys -->|"registers keys"| node_native
node_hotkeys -.->|"requests note actions"| node_manager
node_tray -->|"controls notes"| node_manager
node_tray -->|"shows notices"| node_hotkeys
node_tray -->|"shows status"| node_capture
node_tray -->|"renders fallback icon"| node_icon
node_capture -->|"sets affinity"| node_native
node_capture -->|"checks capability"| node_version
node_version -->|"gates by build"| node_windows
node_native -->|"calls Win32"| node_windows

click node_app "https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/App.xaml.cs"
click node_single_instance "https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Services/SingleInstanceGuard.cs"
click node_manager "https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/NoteManager.cs"
click node_model "https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Models/Note.cs"
click node_window "https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/NoteWindow.xaml.cs"
click node_repository "https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Services/NoteRepository.cs"
click node_autosave "https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Services/AutosaveScheduler.cs"
click node_clamp "https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Services/Clamp.cs"
click node_capture "https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Interop/CaptureGuard.cs"
click node_native "https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Interop/NativeMethods.cs"
click node_version "https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Interop/VersionGate.cs"
click node_hotkeys "https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Services/HotkeyService.cs"
click node_selection "https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Services/HotkeySelection.cs"
click node_tray "https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/TrayController.cs"
click node_icon "https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Services/IconBuilder.cs"

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_app,node_manager,node_tray,node_icon,node_user toneBlue
class node_model,node_window toneAmber
class node_single_instance,node_capture,node_native,node_version,node_hotkeys,node_selection toneMint
class node_repository,node_autosave,node_clamp toneRose
class node_windows toneIndigo
```

## Components

### App runtime

- [App startup](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/App.xaml.cs): `src/GhostNotes/App.xaml.cs`
- [Note manager](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/NoteManager.cs): `src/GhostNotes/NoteManager.cs`
- [System tray](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/TrayController.cs): `src/GhostNotes/TrayController.cs`
- [Tray icon builder](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Services/IconBuilder.cs): `src/GhostNotes/Services/IconBuilder.cs`

### Notes and editing

- [Note model](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Models/Note.cs): `src/GhostNotes/Models/Note.cs`
- [Note window](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/NoteWindow.xaml.cs): `src/GhostNotes/NoteWindow.xaml.cs`

### Windows integration

- [Single instance](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Services/SingleInstanceGuard.cs): `src/GhostNotes/Services/SingleInstanceGuard.cs`
- [Capture protection](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Interop/CaptureGuard.cs): `src/GhostNotes/Interop/CaptureGuard.cs`
- [Windows native APIs](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Interop/NativeMethods.cs): `src/GhostNotes/Interop/NativeMethods.cs`
- [OS version gate](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Interop/VersionGate.cs): `src/GhostNotes/Interop/VersionGate.cs`
- [Global hotkeys](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Services/HotkeyService.cs): `src/GhostNotes/Services/HotkeyService.cs`
- [Hotkey selection](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Services/HotkeySelection.cs): `src/GhostNotes/Services/HotkeySelection.cs`

### Persistence and utilities

- [Note repository](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Services/NoteRepository.cs): `src/GhostNotes/Services/NoteRepository.cs`
- [Autosave scheduler](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Services/AutosaveScheduler.cs): `src/GhostNotes/Services/AutosaveScheduler.cs`
- [Position and zoom](https://github.com/ezykl/ghostnotes/blob/main/src/GhostNotes/Services/Clamp.cs): `src/GhostNotes/Services/Clamp.cs`

### Other components

- **User**
- **Windows desktop**

## Connections

- User → App startup: launches (evidence: `README.md`)
- App startup → Single instance: checks instance (evidence: `src/GhostNotes/App.xaml.cs`)
- App startup → Capture protection: initializes (evidence: `src/GhostNotes/App.xaml.cs`)
- App startup → Note manager: creates (evidence: `src/GhostNotes/App.xaml.cs`)
- App startup → Global hotkeys: registers (evidence: `src/GhostNotes/App.xaml.cs`)
- App startup → System tray: creates (evidence: `src/GhostNotes/App.xaml.cs`)
- Note manager → Note repository: loads and saves (evidence: `src/GhostNotes/NoteManager.cs`)
- Note manager → Note model: manages (evidence: `src/GhostNotes/NoteManager.cs`)
- Note manager → Note window: attaches (evidence: `src/GhostNotes/NoteManager.cs`)
- Note manager → Autosave scheduler: schedules saves (evidence: `src/GhostNotes/NoteManager.cs`)
- Note manager → Capture protection: passes guard (evidence: `src/GhostNotes/NoteManager.cs`)
- Note manager → Position and zoom: clamps geometry (evidence: `src/GhostNotes/NoteManager.cs`)
- Note repository → Note model: serializes (evidence: `src/GhostNotes/Services/NoteRepository.cs`)
- Note window → Note model: edits and displays (evidence: `src/GhostNotes/NoteWindow.xaml.cs`)
- Note window → Capture protection: applies protection (evidence: `src/GhostNotes/NoteWindow.xaml.cs`)
- Note window → Windows native APIs: uses window APIs (evidence: `src/GhostNotes/NoteWindow.xaml.cs`)
- Global hotkeys → Hotkey selection: selects fallback (evidence: `src/GhostNotes/Services/HotkeyService.cs`)
- Global hotkeys → Windows native APIs: registers keys (evidence: `src/GhostNotes/Services/HotkeyService.cs`)
- Global hotkeys → Note manager: requests note actions
- System tray → Note manager: controls notes (evidence: `src/GhostNotes/TrayController.cs`)
- System tray → Global hotkeys: shows notices (evidence: `src/GhostNotes/TrayController.cs`)
- System tray → Capture protection: shows status (evidence: `src/GhostNotes/TrayController.cs`)
- System tray → Tray icon builder: renders fallback icon (evidence: `src/GhostNotes/TrayController.cs`)
- Capture protection → Windows native APIs: sets affinity (evidence: `src/GhostNotes/Interop/CaptureGuard.cs`)
- Capture protection → OS version gate: checks capability (evidence: `src/GhostNotes/Interop/CaptureGuard.cs`)
- OS version gate → Windows desktop: gates by build (evidence: `src/GhostNotes/Interop/VersionGate.cs`)
- Windows native APIs → Windows desktop: calls Win32 (evidence: `src/GhostNotes/Interop/NativeMethods.cs`)
