# gnanachandrik/tiny-desktop-pet architecture

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

- Interactive diagram: https://gitdiagram.com/gnanachandrik/tiny-desktop-pet
- Repository: https://github.com/gnanachandrik/tiny-desktop-pet

## Overview

Tiny Desktop Pet is an Electron companion for Windows and macOS. The user-facing workflow is: summon or receive a scheduled visit, interact with the pet, and optionally open chat; settings and pause controls configure that behavior. The main process owns windows, tray actions, scheduling, persistence, and chat replies, while renderer scripts provide the pet, summon, settings, and chat interfaces through a restricted IPC bridge. README-documented capabilities include encrypted API-key storage and customizable reminder messages; the excerpts do not show how the message-category file is consumed.

Main entry points: [`main.js`](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js) (Main Process), [`preload.js`](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/preload.js) (IPC Bridge), [`renderer/pet.js`](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/renderer/pet.js) (Pet Interaction), [`renderer/summon.js`](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/renderer/summon.js) (Summon Button)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["App Runtime"]
  node_main["Main Process<br/>[main.js]"]
  node_tray["Tray Controls<br/>[main.js]"]
  node_scheduler["Visit Scheduler<br/>[main.js]"]
  node_settings_store[("Settings Store<br/>[main.js]")]
  node_bridge["IPC Bridge<br/>[preload.js]"]
end

subgraph group_pet_ui["Pet Interfaces"]
  node_pet_window["Pet Window<br/>[main.js]"]
  node_pet_interface["Pet Interaction<br/>[pet.js]"]
  node_summon_window["Summon Window<br/>[main.js]"]
  node_summon_button["Summon Button<br/>[summon.js]"]
end

subgraph group_controls_chat["Controls and Chat"]
  node_settings_window["Settings Window<br/>[main.js]"]
  node_settings_form["Settings Form<br/>[settings.js]"]
  node_chat_window["Chat Window<br/>[main.js]"]
  node_chat_interface["Chat Interface<br/>[chat.js]"]
  node_reply_handler["Reply Handler<br/>[main.js]"]
end

subgraph group_content["Pet Content"]
  node_personality["Pet Personality<br/>[personality.txt]"]
  node_reminder_messages["Reminder Messages<br/>[messages.json]"]
end

node_user(("User"))
node_openai{{"OpenAI API"}}

node_user -->|"uses"| node_tray
node_tray -->|"summons"| node_pet_window
node_tray -->|"opens"| node_chat_window
node_tray -->|"opens"| node_settings_window
node_tray -->|"pauses"| node_scheduler
node_scheduler -->|"shows visits"| node_pet_window
node_main -->|"reads and writes"| node_settings_store
node_main -->|"creates and updates"| node_pet_window
node_main -->|"creates"| node_summon_window
node_main -->|"opens"| node_settings_window
node_main -->|"opens"| node_chat_window
node_summon_button -->|"requests summon"| node_bridge
node_pet_interface -->|"requests actions"| node_bridge
node_settings_form -->|"saves settings"| node_bridge
node_chat_interface -->|"sends message"| node_bridge
node_bridge -->|"invokes IPC"| node_main
node_main -->|"sends events"| node_pet_interface
node_main -->|"dispatches chat"| node_reply_handler
node_reply_handler -->|"reads prompt"| node_personality
node_reply_handler -->|"sends chat and prompt"| node_openai

click node_main "https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js"
click node_tray "https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js"
click node_scheduler "https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js"
click node_settings_store "https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js"
click node_bridge "https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/preload.js"
click node_pet_window "https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js"
click node_pet_interface "https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/renderer/pet.js"
click node_summon_window "https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js"
click node_summon_button "https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/renderer/summon.js"
click node_settings_window "https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js"
click node_settings_form "https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/renderer/settings.js"
click node_chat_window "https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js"
click node_chat_interface "https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/renderer/chat.js"
click node_reply_handler "https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js"
click node_personality "https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/config/personality.txt"
click node_reminder_messages "https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/config/messages.json"

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_tray,node_scheduler,node_settings_store,node_bridge,node_user toneBlue
class node_pet_window,node_pet_interface,node_summon_window,node_summon_button toneAmber
class node_settings_window,node_settings_form,node_chat_window,node_chat_interface,node_reply_handler,node_openai toneMint
class node_personality,node_reminder_messages toneRose
```

## Components

### App Runtime

- [Main Process](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js): `main.js`
- [Tray Controls](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js): `main.js`
- [Visit Scheduler](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js): `main.js`
- [Settings Store](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js): `main.js`
- [IPC Bridge](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/preload.js): `preload.js`

### Pet Interfaces

- [Pet Window](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js): `main.js`
- [Pet Interaction](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/renderer/pet.js): `renderer/pet.js`
- [Summon Window](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js): `main.js`
- [Summon Button](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/renderer/summon.js): `renderer/summon.js`

### Controls and Chat

- [Settings Window](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js): `main.js`
- [Settings Form](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/renderer/settings.js): `renderer/settings.js`
- [Chat Window](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js): `main.js`
- [Chat Interface](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/renderer/chat.js): `renderer/chat.js`
- [Reply Handler](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/main.js): `main.js`

### Pet Content

- [Pet Personality](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/config/personality.txt): `config/personality.txt`
- [Reminder Messages](https://github.com/gnanachandrik/tiny-desktop-pet/blob/main/config/messages.json): `config/messages.json`

### Other components

- **User**
- **OpenAI API**

## Connections

- User → Tray Controls: uses (evidence: `README.md`)
- Tray Controls → Pet Window: summons (evidence: `main.js`)
- Tray Controls → Chat Window: opens (evidence: `main.js`)
- Tray Controls → Settings Window: opens (evidence: `main.js`)
- Tray Controls → Visit Scheduler: pauses (evidence: `main.js`)
- Visit Scheduler → Pet Window: shows visits (evidence: `main.js`)
- Main Process → Settings Store: reads and writes (evidence: `main.js`)
- Main Process → Pet Window: creates and updates (evidence: `main.js`)
- Main Process → Summon Window: creates (evidence: `main.js`)
- Main Process → Settings Window: opens (evidence: `main.js`)
- Main Process → Chat Window: opens (evidence: `main.js`)
- Summon Button → IPC Bridge: requests summon (evidence: `renderer/summon.js`)
- Pet Interaction → IPC Bridge: requests actions (evidence: `renderer/pet.js`)
- Settings Form → IPC Bridge: saves settings (evidence: `renderer/settings.js`)
- Chat Interface → IPC Bridge: sends message (evidence: `renderer/chat.js`)
- IPC Bridge → Main Process: invokes IPC (evidence: `preload.js`)
- Main Process → Pet Interaction: sends events (evidence: `main.js`)
- Main Process → Reply Handler: dispatches chat (evidence: `main.js`)
- Reply Handler → Pet Personality: reads prompt (evidence: `main.js`)
- Reply Handler → OpenAI API: sends chat and prompt (evidence: `main.js`)
