# seven-ljy77/desktop-pet architecture

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

- Interactive diagram: https://gitdiagram.com/seven-ljy77/desktop-pet
- Repository: https://github.com/seven-ljy77/desktop-pet

## Overview

Desktop Pet is a Windows/macOS desktop companion whose hover or short-click interaction fetches dynamic text and displays it in a separate bubble; dragging, tray controls, and pet settings are additional user flows. The desktop UI invokes Tauri commands, which bridge to the FastAPI interaction endpoint; the service selects fresh copy from a JSON file and returns presentation hints. The README also documents Caddy-based production routing. Some platform and deployment internals are represented at their enclosing directory because their source was not sampled.

Main entry points: [`apps/desktop/src-tauri/src/lib.rs`](https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src-tauri/src/lib.rs) (Tauri app commands), [`services/api/app/main.py`](https://github.com/seven-ljy77/desktop-pet/blob/main/services/api/app/main.py) (Interaction API), [`apps/desktop/src/main.ts`](https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src/main.ts) (Pet interaction UI), [`apps/desktop/src/api.ts`](https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src/api.ts) (Tauri client API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop experience"]
  node_pet_ui["Pet interaction UI<br/>[main.ts]"]
  node_bubble_ui["Bubble and settings views<br/>[main.ts]"]
  node_client_api["Tauri client API<br/>[api.ts]"]
  node_client_config["Interaction timing<br/>[config.ts]"]
end

subgraph group_native["Tauri runtime"]
  node_native_app["Tauri app commands<br/>[lib.rs]"]
  node_native_interaction["HTTP interaction client<br/>[interaction.rs]"]
  node_window_ops["Window and pet state<br/>[windows.rs]"]
  node_tray["Tray controls<br/>[tray.rs]"]
  node_platform["Platform window setup"]
end

subgraph group_backend["Interaction service"]
  node_api_route["Interaction API<br/>[main.py]"]
  node_api_models["Request and response models<br/>[models.py]"]
  node_interaction_service["Copy selection"]
  node_message_data["Dynamic message catalog<br/>[messages.json]"]
end

subgraph group_ops["Production access"]
  node_caddy["Caddy proxy"]
end

node_user(("Pet user"))
node_external_client(("Desktop client"))

node_user -->|"hovers or clicks"| node_pet_ui
node_pet_ui -->|"uses timing"| node_client_config
node_pet_ui -->|"invokes commands"| node_client_api
node_client_api -->|"invokes Tauri"| node_native_app
node_native_app -->|"dispatches request"| node_native_interaction
node_native_interaction -->|"posts interaction"| node_api_route
node_api_route -->|"creates response"| node_interaction_service
node_api_route -->|"validates payload"| node_api_models
node_interaction_service -->|"builds response"| node_api_models
node_interaction_service -->|"reads copy"| node_message_data
node_native_app -->|"manages windows"| node_window_ops
node_native_app -->|"configures platform"| node_platform
node_native_app -->|"creates tray"| node_tray
node_tray -->|"resets position"| node_window_ops
node_client_api -->|"requests bubble and settings"| node_native_app
node_native_app -->|"shows or hides bubble"| node_window_ops
node_pet_ui -->|"renders bubble view"| node_bubble_ui
node_api_route -->|"serves HTTP"| node_external_client
node_external_client -.->|"routes production traffic"| node_caddy
node_caddy -.->|"forwards requests"| node_api_route

click node_pet_ui "https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src/main.ts"
click node_bubble_ui "https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src/main.ts"
click node_client_api "https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src/api.ts"
click node_client_config "https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src/config.ts"
click node_native_app "https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src-tauri/src/lib.rs"
click node_native_interaction "https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src-tauri/src/interaction.rs"
click node_window_ops "https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src-tauri/src/windows.rs"
click node_tray "https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src-tauri/src/tray.rs"
click node_platform "https://github.com/seven-ljy77/desktop-pet/tree/main/apps/desktop/src-tauri/src/platform"
click node_api_route "https://github.com/seven-ljy77/desktop-pet/blob/main/services/api/app/main.py"
click node_api_models "https://github.com/seven-ljy77/desktop-pet/blob/main/services/api/app/models.py"
click node_interaction_service "https://github.com/seven-ljy77/desktop-pet/blob/main/services/api/app/interaction_service.py"
click node_message_data "https://github.com/seven-ljy77/desktop-pet/blob/main/services/api/app/data/messages.json"
click node_caddy "https://github.com/seven-ljy77/desktop-pet/tree/main/deploy"

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_pet_ui,node_bubble_ui,node_client_api,node_client_config,node_user,node_external_client toneBlue
class node_native_app,node_native_interaction,node_window_ops,node_tray,node_platform toneAmber
class node_api_route,node_api_models,node_interaction_service,node_message_data toneMint
class node_caddy toneRose
```

## Components

### Desktop experience

- [Pet interaction UI](https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src/main.ts): `apps/desktop/src/main.ts`
- [Bubble and settings views](https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src/main.ts): `apps/desktop/src/main.ts`
- [Tauri client API](https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src/api.ts): `apps/desktop/src/api.ts`
- [Interaction timing](https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src/config.ts): `apps/desktop/src/config.ts`

### Tauri runtime

- [Tauri app commands](https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src-tauri/src/lib.rs): `apps/desktop/src-tauri/src/lib.rs`
- [HTTP interaction client](https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src-tauri/src/interaction.rs): `apps/desktop/src-tauri/src/interaction.rs`
- [Window and pet state](https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src-tauri/src/windows.rs): `apps/desktop/src-tauri/src/windows.rs`
- [Tray controls](https://github.com/seven-ljy77/desktop-pet/blob/main/apps/desktop/src-tauri/src/tray.rs): `apps/desktop/src-tauri/src/tray.rs`
- [Platform window setup](https://github.com/seven-ljy77/desktop-pet/tree/main/apps/desktop/src-tauri/src/platform): `apps/desktop/src-tauri/src/platform`

### Interaction service

- [Interaction API](https://github.com/seven-ljy77/desktop-pet/blob/main/services/api/app/main.py): `services/api/app/main.py`
- [Request and response models](https://github.com/seven-ljy77/desktop-pet/blob/main/services/api/app/models.py): `services/api/app/models.py`
- [Copy selection](https://github.com/seven-ljy77/desktop-pet/blob/main/services/api/app/interaction_service.py): `services/api/app/interaction_service.py`
- [Dynamic message catalog](https://github.com/seven-ljy77/desktop-pet/blob/main/services/api/app/data/messages.json): `services/api/app/data/messages.json`

### Production access

- [Caddy proxy](https://github.com/seven-ljy77/desktop-pet/tree/main/deploy): `deploy`

### Other components

- **Pet user**
- **Desktop client**

## Connections

- Pet user → Pet interaction UI: hovers or clicks (evidence: `README.md`)
- Pet interaction UI → Interaction timing: uses timing (evidence: `apps/desktop/src/main.ts`)
- Pet interaction UI → Tauri client API: invokes commands (evidence: `apps/desktop/src/main.ts`)
- Tauri client API → Tauri app commands: invokes Tauri (evidence: `apps/desktop/src/api.ts`)
- Tauri app commands → HTTP interaction client: dispatches request (evidence: `apps/desktop/src-tauri/src/lib.rs`)
- HTTP interaction client → Interaction API: posts interaction (evidence: `README.md`)
- Interaction API → Copy selection: creates response (evidence: `services/api/app/main.py`)
- Interaction API → Request and response models: validates payload (evidence: `services/api/app/main.py`)
- Copy selection → Request and response models: builds response (evidence: `services/api/app/interaction_service.py`)
- Copy selection → Dynamic message catalog: reads copy (evidence: `README.md`)
- Tauri app commands → Window and pet state: manages windows (evidence: `apps/desktop/src-tauri/src/lib.rs`)
- Tauri app commands → Platform window setup: configures platform (evidence: `apps/desktop/src-tauri/src/lib.rs`)
- Tauri app commands → Tray controls: creates tray (evidence: `apps/desktop/src-tauri/src/lib.rs`)
- Tray controls → Window and pet state: resets position (evidence: `apps/desktop/src-tauri/src/tray.rs`)
- Tauri client API → Tauri app commands: requests bubble and settings (evidence: `apps/desktop/src/api.ts`)
- Tauri app commands → Window and pet state: shows or hides bubble (evidence: `apps/desktop/src-tauri/src/lib.rs`)
- Pet interaction UI → Bubble and settings views: renders bubble view (evidence: `apps/desktop/src/main.ts`)
- Interaction API → Desktop client: serves HTTP (evidence: `README.md`)
- Desktop client → Caddy proxy: routes production traffic (evidence: `README.md`)
- Caddy proxy → Interaction API: forwards requests (evidence: `README.md`)
