# namidev-79/selyh-desktop architecture

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

- Interactive diagram: https://gitdiagram.com/namidev-79/selyh-desktop
- Repository: https://github.com/namidev-79/selyh-desktop

## Overview

Selyh is a Tauri desktop agent that lives in the system tray and surfaces check-ins, scales, and guided exercises during suitable pauses. The user journey runs from device pairing and setup through scheduled prompts, local-first responses, and optional synchronization; the dashboard exposes status, history, transparency, and preferences. Rust owns credentials, API access, scheduling, and local storage, while React windows call the core through a typed command bridge. The README documents major capabilities not fully visible in the excerpts; edges for those flows cite the README, and unsampled implementation details are not inferred.

Main entry points: [`src/main.tsx`](https://github.com/namidev-79/selyh-desktop/blob/main/src/main.tsx) (Window view router), [`src/windows/dashboard/Dashboard.tsx`](https://github.com/namidev-79/selyh-desktop/blob/main/src/windows/dashboard/Dashboard.tsx) (Dashboard), [`src/lib/agent.ts`](https://github.com/namidev-79/selyh-desktop/blob/main/src/lib/agent.ts) (Typed command bridge), [`src-tauri/src/api.rs`](https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/api.rs) (Authenticated API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Desktop experience"]
  node_router["Window view router<br/>[main.tsx]"]
  node_onboarding["Device onboarding<br/>[Onboarding.tsx]"]
  node_checkin["Check-in window<br/>[Checkin.tsx]"]
  node_scale["Scale window<br/>[Scale.tsx]"]
  node_exercise["Exercise window<br/>[Exercise.tsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_ui["Shared UI and copy<br/>[ui.tsx]"]
  node_bridge["Typed command bridge<br/>[agent.ts]"]
end

subgraph group_runtime["Agent runtime"]
  node_commands["Tauri commands<br/>[commands.rs]"]
  node_tray["Tray and windows<br/>[tray.rs]"]
  node_state["Shared agent state<br/>[state.rs]"]
  node_config["Service configuration<br/>[config.rs]"]
end

subgraph group_security["API and storage"]
  node_auth["Device pairing<br/>[auth.rs]"]
  node_api_client["Authenticated API client<br/>[api.rs]"]
  node_keychain[("System keychain<br/>[keychain.rs]")]
  node_sync[("Offline sync store<br/>[sync.rs]")]
end

subgraph group_wellbeing["Wellbeing features"]
  node_scheduler["Prompt scheduler<br/>[scheduler.rs]"]
  node_activity["Idle and busy detection<br/>[activity.rs]"]
  node_sensor["Passive daily sensor<br/>[sensor.rs]"]
end

node_person(("User"))
node_web{{"Selyh web"}}
node_backend{{"Selyh API"}}

node_person -->|"opens app"| node_router
node_router -->|"routes view"| node_onboarding
node_router -->|"routes view"| node_checkin
node_router -->|"routes view"| node_scale
node_router -->|"routes view"| node_exercise
node_router -->|"routes view"| node_dashboard
node_onboarding -->|"invokes commands"| node_bridge
node_checkin -->|"invokes commands"| node_bridge
node_scale -->|"invokes commands"| node_bridge
node_exercise -->|"invokes commands"| node_bridge
node_dashboard -->|"invokes commands"| node_bridge
node_onboarding -->|"renders"| node_ui
node_checkin -->|"renders"| node_ui
node_scale -->|"renders"| node_ui
node_exercise -->|"renders"| node_ui
node_dashboard -->|"renders"| node_ui
node_bridge -->|"invokes"| node_commands
node_person -->|"approves pairing"| node_web
node_onboarding -->|"starts pairing"| node_auth
node_auth -->|"requests device token"| node_backend
node_auth -->|"uses client"| node_api_client
node_api_client -->|"loads and saves tokens"| node_keychain
node_api_client -->|"uses API URL"| node_config
node_commands -->|"calls API"| node_api_client
node_api_client -->|"HTTP requests"| node_backend
node_commands -->|"flushes queued data"| node_sync
node_sync -->|"posts sync batches"| node_backend
node_commands -->|"snoozes prompts"| node_scheduler
node_scheduler -->|"checks idle and busy"| node_activity
node_scheduler -->|"shows prompt windows"| node_tray
node_scheduler -->|"requests next prompt"| node_backend
node_sensor -->|"measures inactivity"| node_activity
node_sensor -->|"checks consent state"| node_state
node_sensor -->|"stores daily summaries"| node_sync
node_person -->|"uses tray menu"| node_tray
node_tray -->|"opens panel"| node_dashboard
node_checkin -->|"queues response"| node_sync
node_scale -->|"saves progress"| node_backend
node_exercise -->|"sends response"| node_backend
node_dashboard -->|"reads check-in history"| node_sync
node_dashboard -->|"views signal summary"| node_sensor

click node_router "https://github.com/namidev-79/selyh-desktop/blob/main/src/main.tsx"
click node_onboarding "https://github.com/namidev-79/selyh-desktop/blob/main/src/windows/onboarding/Onboarding.tsx"
click node_checkin "https://github.com/namidev-79/selyh-desktop/blob/main/src/windows/checkin/Checkin.tsx"
click node_scale "https://github.com/namidev-79/selyh-desktop/blob/main/src/windows/scale/Scale.tsx"
click node_exercise "https://github.com/namidev-79/selyh-desktop/blob/main/src/windows/exercise/Exercise.tsx"
click node_dashboard "https://github.com/namidev-79/selyh-desktop/blob/main/src/windows/dashboard/Dashboard.tsx"
click node_ui "https://github.com/namidev-79/selyh-desktop/blob/main/src/components/ui.tsx"
click node_bridge "https://github.com/namidev-79/selyh-desktop/blob/main/src/lib/agent.ts"
click node_commands "https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/commands.rs"
click node_tray "https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/tray.rs"
click node_scheduler "https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/scheduler.rs"
click node_activity "https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/activity.rs"
click node_sensor "https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/sensor.rs"
click node_auth "https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/auth.rs"
click node_api_client "https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/api.rs"
click node_keychain "https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/keychain.rs"
click node_sync "https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/sync.rs"
click node_state "https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/state.rs"
click node_config "https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/config.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_router,node_onboarding,node_checkin,node_scale,node_exercise,node_dashboard,node_ui,node_bridge,node_person toneBlue
class node_commands,node_tray,node_state,node_config toneAmber
class node_auth,node_api_client,node_keychain,node_sync,node_backend toneMint
class node_scheduler,node_activity,node_sensor toneRose
class node_web toneIndigo
```

## Components

### Desktop experience

- [Window view router](https://github.com/namidev-79/selyh-desktop/blob/main/src/main.tsx): `src/main.tsx`
- [Device onboarding](https://github.com/namidev-79/selyh-desktop/blob/main/src/windows/onboarding/Onboarding.tsx): `src/windows/onboarding/Onboarding.tsx`
- [Check-in window](https://github.com/namidev-79/selyh-desktop/blob/main/src/windows/checkin/Checkin.tsx): `src/windows/checkin/Checkin.tsx`
- [Scale window](https://github.com/namidev-79/selyh-desktop/blob/main/src/windows/scale/Scale.tsx): `src/windows/scale/Scale.tsx`
- [Exercise window](https://github.com/namidev-79/selyh-desktop/blob/main/src/windows/exercise/Exercise.tsx): `src/windows/exercise/Exercise.tsx`
- [Dashboard](https://github.com/namidev-79/selyh-desktop/blob/main/src/windows/dashboard/Dashboard.tsx): `src/windows/dashboard/Dashboard.tsx`
- [Shared UI and copy](https://github.com/namidev-79/selyh-desktop/blob/main/src/components/ui.tsx): `src/components/ui.tsx`
- [Typed command bridge](https://github.com/namidev-79/selyh-desktop/blob/main/src/lib/agent.ts): `src/lib/agent.ts`

### Agent runtime

- [Tauri commands](https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/commands.rs): `src-tauri/src/commands.rs`
- [Tray and windows](https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/tray.rs): `src-tauri/src/tray.rs`
- [Shared agent state](https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/state.rs): `src-tauri/src/state.rs`
- [Service configuration](https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/config.rs): `src-tauri/src/config.rs`

### API and storage

- [Device pairing](https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/auth.rs): `src-tauri/src/auth.rs`
- [Authenticated API client](https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/api.rs): `src-tauri/src/api.rs`
- [System keychain](https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/keychain.rs): `src-tauri/src/keychain.rs`
- [Offline sync store](https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/sync.rs): `src-tauri/src/sync.rs`

### Wellbeing features

- [Prompt scheduler](https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/scheduler.rs): `src-tauri/src/scheduler.rs`
- [Idle and busy detection](https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/activity.rs): `src-tauri/src/activity.rs`
- [Passive daily sensor](https://github.com/namidev-79/selyh-desktop/blob/main/src-tauri/src/sensor.rs): `src-tauri/src/sensor.rs`

### Other components

- **User**
- **Selyh web**
- **Selyh API**

## Connections

- User → Window view router: opens app (evidence: `src/main.tsx`)
- Window view router → Device onboarding: routes view (evidence: `src/main.tsx`)
- Window view router → Check-in window: routes view (evidence: `src/main.tsx`)
- Window view router → Scale window: routes view (evidence: `src/main.tsx`)
- Window view router → Exercise window: routes view (evidence: `src/main.tsx`)
- Window view router → Dashboard: routes view (evidence: `src/main.tsx`)
- Device onboarding → Typed command bridge: invokes commands (evidence: `src/lib/agent.ts`)
- Check-in window → Typed command bridge: invokes commands (evidence: `src/lib/agent.ts`)
- Scale window → Typed command bridge: invokes commands (evidence: `src/lib/agent.ts`)
- Exercise window → Typed command bridge: invokes commands (evidence: `src/lib/agent.ts`)
- Dashboard → Typed command bridge: invokes commands (evidence: `src/lib/agent.ts`)
- Device onboarding → Shared UI and copy: renders (evidence: `src/windows/onboarding/Onboarding.tsx`)
- Check-in window → Shared UI and copy: renders (evidence: `src/windows/checkin/Checkin.tsx`)
- Scale window → Shared UI and copy: renders (evidence: `src/windows/scale/Scale.tsx`)
- Exercise window → Shared UI and copy: renders (evidence: `src/windows/exercise/Exercise.tsx`)
- Dashboard → Shared UI and copy: renders (evidence: `src/windows/dashboard/Dashboard.tsx`)
- Typed command bridge → Tauri commands: invokes (evidence: `src/lib/agent.ts`)
- User → Selyh web: approves pairing (evidence: `README.md`)
- Device onboarding → Device pairing: starts pairing (evidence: `README.md`)
- Device pairing → Selyh API: requests device token (evidence: `README.md`)
- Device pairing → Authenticated API client: uses client (evidence: `src-tauri/src/auth.rs`)
- Authenticated API client → System keychain: loads and saves tokens (evidence: `src-tauri/src/api.rs`)
- Authenticated API client → Service configuration: uses API URL (evidence: `src-tauri/src/api.rs`)
- Tauri commands → Authenticated API client: calls API (evidence: `README.md`)
- Authenticated API client → Selyh API: HTTP requests (evidence: `README.md`)
- Tauri commands → Offline sync store: flushes queued data (evidence: `src-tauri/src/commands.rs`)
- Offline sync store → Selyh API: posts sync batches (evidence: `README.md`)
- Tauri commands → Prompt scheduler: snoozes prompts (evidence: `src-tauri/src/commands.rs`)
- Prompt scheduler → Idle and busy detection: checks idle and busy (evidence: `src-tauri/src/scheduler.rs`)
- Prompt scheduler → Tray and windows: shows prompt windows (evidence: `src-tauri/src/scheduler.rs`)
- Prompt scheduler → Selyh API: requests next prompt (evidence: `README.md`)
- Passive daily sensor → Idle and busy detection: measures inactivity (evidence: `src-tauri/src/sensor.rs`)
- Passive daily sensor → Shared agent state: checks consent state (evidence: `src-tauri/src/sensor.rs`)
- Passive daily sensor → Offline sync store: stores daily summaries (evidence: `README.md`)
- User → Tray and windows: uses tray menu (evidence: `README.md`)
- Tray and windows → Dashboard: opens panel (evidence: `src-tauri/src/tray.rs`)
- Check-in window → Offline sync store: queues response (evidence: `README.md`)
- Scale window → Selyh API: saves progress (evidence: `README.md`)
- Exercise window → Selyh API: sends response (evidence: `README.md`)
- Dashboard → Offline sync store: reads check-in history
- Dashboard → Passive daily sensor: views signal summary (evidence: `README.md`)
