# omriharel/deej architecture

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

- Interactive diagram: https://gitdiagram.com/omriharel/deej
- Repository: https://github.com/omriharel/deej

## Overview

deej is a Go desktop client paired with Arduino slider hardware. Slider readings arrive over serial, are normalized into move events, and are applied according to reloadable configuration to matching audio sessions. The session map discovers and refreshes sessions, then adjusts their volume; platform-specific code supplies audio-session discovery and controls. The tray offers configuration editing, manual session refresh, and quit, while notifications report configuration or connection problems. README-documented capabilities include master, microphone, system sounds, named devices, focused apps, and unmapped apps. Some wiring is documented only at product level because excerpts are partial.

Main entry points: [`pkg/deej/session_map.go`](https://github.com/omriharel/deej/blob/master/pkg/deej/session_map.go) (Session mapping), [`pkg/deej/deej.go`](https://github.com/omriharel/deej/blob/master/pkg/deej/deej.go) (Client lifecycle), [`pkg/deej/config.go`](https://github.com/omriharel/deej/blob/master/pkg/deej/config.go) (Configuration), [`pkg/deej/tray.go`](https://github.com/omriharel/deej/blob/master/pkg/deej/tray.go) (System tray)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime orchestration"]
  node_entry["Client entry<br/>[main.go]"]
  node_client["Client lifecycle<br/>[deej.go]"]
end

subgraph group_input["Slider input and config"]
  node_config["Configuration<br/>[config.go]"]
  node_mapping["Slider mapping<br/>[slider_map.go]"]
  node_serial["Serial reader<br/>[serial.go]"]
end

subgraph group_audio["Audio session control"]
  node_sessionmap["Session mapping<br/>[session_map.go]"]
  node_finder["Session discovery<br/>[session_finder.go]"]
  node_finderwin["Windows discovery"]
  node_finderlinux["Linux discovery"]
  node_sessionwin["Windows controls<br/>[session_windows.go]"]
  node_sessionlinux["Linux controls<br/>[session_linux.go]"]
end

subgraph group_desktop["Desktop experience"]
  node_tray["System tray<br/>[tray.go]"]
  node_notify["Notifications<br/>[notify.go]"]
end

subgraph group_hardware["Hardware input"]
  node_arduino["Arduino firmware"]
end

node_user(("User"))
node_audioapi["Operating system audio"]
node_editor["Config editor"]

node_user -->|"moves sliders"| node_arduino
node_arduino -->|"streams readings"| node_serial
node_entry -->|"creates and initializes"| node_client
node_client -->|"loads and watches"| node_config
node_client -->|"initializes and releases"| node_sessionmap
node_client -->|"starts and stops"| node_serial
node_client -->|"starts tray"| node_tray
node_config -->|"builds mapping"| node_mapping
node_serial -->|"delivers slider changes"| node_sessionmap
node_config -->|"provides target rules"| node_sessionmap
node_sessionmap -->|"requests sessions"| node_finder
node_finder -.->|"platform implementation"| node_finderwin
node_finder -.->|"platform implementation"| node_finderlinux
node_finderwin -->|"creates audio sessions"| node_sessionwin
node_sessionmap -->|"sets session volume"| node_sessionwin
node_sessionmap -.->|"sets session volume"| node_sessionlinux
node_sessionwin -->|"controls audio"| node_audioapi
node_sessionlinux -.->|"controls audio"| node_audioapi
node_tray -->|"refreshes sessions"| node_sessionmap
node_user -->|"uses menu"| node_tray
node_tray -->|"opens config in"| node_editor
node_config -->|"reports reload status"| node_notify
node_client -->|"reports connection errors"| node_notify

click node_entry "https://github.com/omriharel/deej/blob/master/pkg/deej/cmd/main.go"
click node_client "https://github.com/omriharel/deej/blob/master/pkg/deej/deej.go"
click node_config "https://github.com/omriharel/deej/blob/master/pkg/deej/config.go"
click node_mapping "https://github.com/omriharel/deej/blob/master/pkg/deej/slider_map.go"
click node_serial "https://github.com/omriharel/deej/blob/master/pkg/deej/serial.go"
click node_arduino "https://github.com/omriharel/deej/blob/master/arduino/deej-5-sliders-vanilla/deej-5-sliders-vanilla.ino"
click node_sessionmap "https://github.com/omriharel/deej/blob/master/pkg/deej/session_map.go"
click node_finder "https://github.com/omriharel/deej/blob/master/pkg/deej/session_finder.go"
click node_finderwin "https://github.com/omriharel/deej/blob/master/pkg/deej/session_finder_windows.go"
click node_finderlinux "https://github.com/omriharel/deej/blob/master/pkg/deej/session_finder_linux.go"
click node_sessionwin "https://github.com/omriharel/deej/blob/master/pkg/deej/session_windows.go"
click node_sessionlinux "https://github.com/omriharel/deej/blob/master/pkg/deej/session_linux.go"
click node_tray "https://github.com/omriharel/deej/blob/master/pkg/deej/tray.go"
click node_notify "https://github.com/omriharel/deej/blob/master/pkg/deej/notify.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_entry,node_client,node_user toneBlue
class node_config,node_mapping,node_serial toneAmber
class node_sessionmap,node_finder,node_finderwin,node_finderlinux,node_sessionwin,node_sessionlinux toneMint
class node_tray,node_notify toneRose
class node_arduino,node_audioapi,node_editor toneIndigo
```

## Components

### Runtime orchestration

- [Client entry](https://github.com/omriharel/deej/blob/master/pkg/deej/cmd/main.go): `pkg/deej/cmd/main.go`
- [Client lifecycle](https://github.com/omriharel/deej/blob/master/pkg/deej/deej.go): `pkg/deej/deej.go`

### Slider input and config

- [Configuration](https://github.com/omriharel/deej/blob/master/pkg/deej/config.go): `pkg/deej/config.go`
- [Slider mapping](https://github.com/omriharel/deej/blob/master/pkg/deej/slider_map.go): `pkg/deej/slider_map.go`
- [Serial reader](https://github.com/omriharel/deej/blob/master/pkg/deej/serial.go): `pkg/deej/serial.go`

### Audio session control

- [Session mapping](https://github.com/omriharel/deej/blob/master/pkg/deej/session_map.go): `pkg/deej/session_map.go`
- [Session discovery](https://github.com/omriharel/deej/blob/master/pkg/deej/session_finder.go): `pkg/deej/session_finder.go`
- [Windows discovery](https://github.com/omriharel/deej/blob/master/pkg/deej/session_finder_windows.go): `pkg/deej/session_finder_windows.go`
- [Linux discovery](https://github.com/omriharel/deej/blob/master/pkg/deej/session_finder_linux.go): `pkg/deej/session_finder_linux.go`
- [Windows controls](https://github.com/omriharel/deej/blob/master/pkg/deej/session_windows.go): `pkg/deej/session_windows.go`
- [Linux controls](https://github.com/omriharel/deej/blob/master/pkg/deej/session_linux.go): `pkg/deej/session_linux.go`

### Desktop experience

- [System tray](https://github.com/omriharel/deej/blob/master/pkg/deej/tray.go): `pkg/deej/tray.go`
- [Notifications](https://github.com/omriharel/deej/blob/master/pkg/deej/notify.go): `pkg/deej/notify.go`

### Hardware input

- [Arduino firmware](https://github.com/omriharel/deej/blob/master/arduino/deej-5-sliders-vanilla/deej-5-sliders-vanilla.ino): `arduino/deej-5-sliders-vanilla/deej-5-sliders-vanilla.ino`

### Other components

- **User**
- **Operating system audio**
- **Config editor**

## Connections

- User → Arduino firmware: moves sliders (evidence: `README.md`)
- Arduino firmware → Serial reader: streams readings (evidence: `README.md`)
- Client entry → Client lifecycle: creates and initializes (evidence: `pkg/deej/cmd/main.go`)
- Client lifecycle → Configuration: loads and watches (evidence: `pkg/deej/deej.go`)
- Client lifecycle → Session mapping: initializes and releases (evidence: `pkg/deej/deej.go`)
- Client lifecycle → Serial reader: starts and stops (evidence: `pkg/deej/deej.go`)
- Client lifecycle → System tray: starts tray (evidence: `pkg/deej/deej.go`)
- Configuration → Slider mapping: builds mapping (evidence: `pkg/deej/config.go`)
- Serial reader → Session mapping: delivers slider changes (evidence: `README.md`)
- Configuration → Session mapping: provides target rules (evidence: `pkg/deej/session_map.go`)
- Session mapping → Session discovery: requests sessions (evidence: `pkg/deej/session_map.go`)
- Session discovery → Windows discovery: platform implementation
- Session discovery → Linux discovery: platform implementation
- Windows discovery → Windows controls: creates audio sessions (evidence: `pkg/deej/session_finder_windows.go`)
- Session mapping → Windows controls: sets session volume (evidence: `pkg/deej/session_map.go`)
- Session mapping → Linux controls: sets session volume
- Windows controls → Operating system audio: controls audio (evidence: `pkg/deej/session_windows.go`)
- Linux controls → Operating system audio: controls audio
- System tray → Session mapping: refreshes sessions (evidence: `pkg/deej/tray.go`)
- User → System tray: uses menu (evidence: `pkg/deej/tray.go`)
- System tray → Config editor: opens config in (evidence: `pkg/deej/tray.go`)
- Configuration → Notifications: reports reload status (evidence: `pkg/deej/config.go`)
- Client lifecycle → Notifications: reports connection errors (evidence: `pkg/deej/deej.go`)
