# samuelsbenghe/samic architecture

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

- Interactive diagram: https://gitdiagram.com/samuelsbenghe/samic
- Repository: https://github.com/samuelsbenghe/samic

## Overview

Samic is a Windows tray app that periodically monitors the selected capture device and, when enforcement is enabled, restores its input volume to 100%. Users can choose the default or an active microphone, refresh the device list, toggle enforcement, and exit from the tray UI. The excerpts show the main thread starting the monitor and UI, shared state carrying settings and status, and the UI reflecting microphone status with tray icons. Unsampled UI code limits detail about some controls and event wiring.

Main entry points: [`src/ui.rs`](https://github.com/samuelsbenghe/samic/blob/main/src/ui.rs) (Tray and settings UI), [`src/audio.rs`](https://github.com/samuelsbenghe/samic/blob/main/src/audio.rs) (Device monitor), [`src/state.rs`](https://github.com/samuelsbenghe/samic/blob/main/src/state.rs) (Shared state), [`src/main.rs`](https://github.com/samuelsbenghe/samic/blob/main/src/main.rs) (App startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["App runtime"]
  node_main["App startup<br/>[main.rs]"]
  node_state["Shared state<br/>[state.rs]"]
end

subgraph group_controls["Tray controls"]
  node_ui["Tray and settings UI<br/>[ui.rs]"]
  node_icons["Status icons<br/>[icon.rs]"]
end

subgraph group_audio["Audio monitoring"]
  node_audio["Device monitor<br/>[audio.rs]"]
end

node_user(("User"))
node_endpoints["Windows audio endpoints"]
node_tray["Windows notification area"]

node_user -->|"uses"| node_ui
node_main -->|"creates"| node_state
node_main -->|"starts monitor"| node_audio
node_main -->|"runs UI"| node_ui
node_ui -->|"updates settings"| node_state
node_audio -->|"reads settings"| node_state
node_audio -->|"writes status"| node_state
node_ui -->|"reads status"| node_state
node_ui -->|"lists devices"| node_audio
node_audio -->|"resolves and adjusts"| node_endpoints
node_ui -->|"creates icons"| node_icons
node_ui -->|"updates tray icon"| node_tray

click node_main "https://github.com/samuelsbenghe/samic/blob/main/src/main.rs"
click node_state "https://github.com/samuelsbenghe/samic/blob/main/src/state.rs"
click node_ui "https://github.com/samuelsbenghe/samic/blob/main/src/ui.rs"
click node_icons "https://github.com/samuelsbenghe/samic/blob/main/src/icon.rs"
click node_audio "https://github.com/samuelsbenghe/samic/blob/main/src/audio.rs"

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_main,node_state,node_user toneBlue
class node_ui,node_icons toneAmber
class node_audio toneMint
class node_endpoints,node_tray toneIndigo
```

## Components

### App runtime

- [App startup](https://github.com/samuelsbenghe/samic/blob/main/src/main.rs): `src/main.rs`
- [Shared state](https://github.com/samuelsbenghe/samic/blob/main/src/state.rs): `src/state.rs`

### Tray controls

- [Tray and settings UI](https://github.com/samuelsbenghe/samic/blob/main/src/ui.rs): `src/ui.rs`
- [Status icons](https://github.com/samuelsbenghe/samic/blob/main/src/icon.rs): `src/icon.rs`

### Audio monitoring

- [Device monitor](https://github.com/samuelsbenghe/samic/blob/main/src/audio.rs): `src/audio.rs`

### Other components

- **User**
- **Windows audio endpoints**
- **Windows notification area**

## Connections

- User → Tray and settings UI: uses (evidence: `README.md`)
- App startup → Shared state: creates (evidence: `src/main.rs`)
- App startup → Device monitor: starts monitor (evidence: `src/main.rs`)
- App startup → Tray and settings UI: runs UI (evidence: `src/main.rs`)
- Tray and settings UI → Shared state: updates settings (evidence: `src/ui.rs`)
- Device monitor → Shared state: reads settings (evidence: `src/audio.rs`)
- Device monitor → Shared state: writes status (evidence: `src/audio.rs`)
- Tray and settings UI → Shared state: reads status (evidence: `src/ui.rs`)
- Tray and settings UI → Device monitor: lists devices (evidence: `src/ui.rs`)
- Device monitor → Windows audio endpoints: resolves and adjusts (evidence: `src/audio.rs`)
- Tray and settings UI → Status icons: creates icons (evidence: `src/ui.rs`)
- Tray and settings UI → Windows notification area: updates tray icon (evidence: `src/ui.rs`)
