# nucket/nekoai architecture

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

- Interactive diagram: https://gitdiagram.com/nucket/nekoai
- Repository: https://github.com/nucket/nekoai

## Overview

NekoAI is a Tauri desktop pet: the user sees an animated companion that moves around the desktop, responds to chat through a selected AI provider, and can be configured across app windows. The principal workflow runs through the main pet window, which coordinates movement, rendering, chat context and memory, then displays replies in a speech bubble. Separate branches cover settings and pet selection, the house and panel windows, and Rust desktop services. Edges reflect excerpts, source-index references, or README statements; some backend command wiring is not fully shown.

Main entry points: [`src/App.tsx`](https://github.com/nucket/nekoai/blob/main/src/App.tsx) (Pet app), [`src-tauri/src/lib.rs`](https://github.com/nucket/nekoai/blob/main/src-tauri/src/lib.rs) (Tauri services), [`src/store/configStore.ts`](https://github.com/nucket/nekoai/blob/main/src/store/configStore.ts) (Config store), [`src/hooks/usePetMovement.ts`](https://github.com/nucket/nekoai/blob/main/src/hooks/usePetMovement.ts) (Pet movement)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pet_ui["Pet experience"]
  node_app["Pet app<br/>[App.tsx]"]
  node_movement["Pet movement<br/>[usePetMovement.ts]"]
  node_idle["Idle sequencing"]
  node_mood["Mood engine<br/>[useMoodEngine.ts]"]
  node_renderer["Pet renderer<br/>[PetRenderer.tsx]"]
  node_animation["Animation resolver"]
  node_speech["Speech bubble<br/>[SpeechBubble.tsx]"]
  node_pet_types["Pet definitions<br/>[pet.ts]"]
  node_app_state["Runtime mood state<br/>[index.ts]"]
end

subgraph group_ai_chat["AI and memory"]
  node_ai_router["AI provider router<br/>[index.ts]"]
  node_providers["AI providers"]
  node_ai_http["AI HTTP helper<br/>[http.ts]"]
  node_ai_memory["Conversation memory<br/>[memory.ts]"]
end

subgraph group_desktop["Desktop services"]
  node_desktop_context["Active app context"]
  node_native["Tauri services<br/>[lib.rs]"]
  node_cursor["Cursor tracking<br/>[cursor_tracker.rs]"]
  node_window_monitor["Desktop monitor<br/>[desktop_monitor.rs]"]
  node_storage[("Persistent storage<br/>[storage.rs]")]
end

subgraph group_configuration["Windows and settings"]
  node_house["Pet house<br/>[HouseWindow.tsx]"]
  node_panel["Panel window<br/>[PanelWindow.tsx]"]
  node_settings["Settings<br/>[SettingsPanel.tsx]"]
  node_selector["Pet selector<br/>[PetSelector.tsx]"]
  node_config[("Config store<br/>[configStore.ts]")]
end

node_user(("Desktop user"))

node_user -->|"interacts with"| node_app
node_app -->|"coordinates"| node_movement
node_app -->|"renders"| node_renderer
node_app -->|"resolves animations"| node_animation
node_app -->|"renders"| node_speech
node_app -->|"uses"| node_idle
node_app -->|"uses"| node_mood
node_movement -->|"reads work area"| node_window_monitor
node_movement -.->|"sets animation state"| node_renderer
node_renderer -->|"uses definitions"| node_pet_types
node_app -->|"builds chat context"| node_ai_router
node_app -->|"loads facts"| node_ai_memory
node_ai_router -->|"creates provider"| node_providers
node_providers -->|"uses HTTP helper"| node_ai_http
node_app -->|"persists chat"| node_storage
node_app -->|"uses context"| node_desktop_context
node_desktop_context -.->|"invokes desktop commands"| node_native
node_app -.->|"invokes native commands"| node_native
node_native -->|"registers services"| node_cursor
node_native -->|"registers services"| node_window_monitor
node_native -->|"registers services"| node_storage
node_mood -->|"updates mood"| node_app_state
node_app -->|"loads settings"| node_config
node_config -->|"persists config"| node_native
node_app -->|"shows settings"| node_settings
node_app -->|"shows selector"| node_selector
node_settings -->|"updates settings"| node_config
node_settings -->|"tests provider"| node_ai_router
node_selector -->|"changes active pet"| node_config
node_house -->|"reads settings"| node_config
node_panel -->|"reads settings"| node_config

click node_app "https://github.com/nucket/nekoai/blob/main/src/App.tsx"
click node_movement "https://github.com/nucket/nekoai/blob/main/src/hooks/usePetMovement.ts"
click node_idle "https://github.com/nucket/nekoai/blob/main/src/hooks/useIdleSequencer.ts"
click node_mood "https://github.com/nucket/nekoai/blob/main/src/hooks/useMoodEngine.ts"
click node_renderer "https://github.com/nucket/nekoai/blob/main/src/pets/PetRenderer.tsx"
click node_animation "https://github.com/nucket/nekoai/blob/main/src/pets/resolveAnimation.ts"
click node_speech "https://github.com/nucket/nekoai/blob/main/src/components/SpeechBubble.tsx"
click node_pet_types "https://github.com/nucket/nekoai/blob/main/src/types/pet.ts"
click node_ai_router "https://github.com/nucket/nekoai/blob/main/src/ai/index.ts"
click node_providers "https://github.com/nucket/nekoai/tree/main/src/ai/providers"
click node_ai_http "https://github.com/nucket/nekoai/blob/main/src/ai/http.ts"
click node_ai_memory "https://github.com/nucket/nekoai/blob/main/src/ai/memory.ts"
click node_desktop_context "https://github.com/nucket/nekoai/blob/main/src/hooks/useDesktopContext.ts"
click node_native "https://github.com/nucket/nekoai/blob/main/src-tauri/src/lib.rs"
click node_cursor "https://github.com/nucket/nekoai/blob/main/src-tauri/src/cursor_tracker.rs"
click node_window_monitor "https://github.com/nucket/nekoai/blob/main/src-tauri/src/desktop_monitor.rs"
click node_storage "https://github.com/nucket/nekoai/blob/main/src-tauri/src/storage.rs"
click node_house "https://github.com/nucket/nekoai/blob/main/src/HouseWindow.tsx"
click node_panel "https://github.com/nucket/nekoai/blob/main/src/PanelWindow.tsx"
click node_settings "https://github.com/nucket/nekoai/blob/main/src/components/SettingsPanel.tsx"
click node_selector "https://github.com/nucket/nekoai/blob/main/src/components/PetSelector.tsx"
click node_config "https://github.com/nucket/nekoai/blob/main/src/store/configStore.ts"
click node_app_state "https://github.com/nucket/nekoai/blob/main/src/store/index.ts"

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_app,node_movement,node_idle,node_mood,node_renderer,node_animation,node_speech,node_pet_types,node_app_state,node_user toneBlue
class node_ai_router,node_providers,node_ai_http,node_ai_memory toneAmber
class node_desktop_context,node_native,node_cursor,node_window_monitor,node_storage toneMint
class node_house,node_panel,node_settings,node_selector,node_config toneRose
```

## Components

### Pet experience

- [Pet app](https://github.com/nucket/nekoai/blob/main/src/App.tsx): `src/App.tsx`
- [Pet movement](https://github.com/nucket/nekoai/blob/main/src/hooks/usePetMovement.ts): `src/hooks/usePetMovement.ts`
- [Idle sequencing](https://github.com/nucket/nekoai/blob/main/src/hooks/useIdleSequencer.ts): `src/hooks/useIdleSequencer.ts`
- [Mood engine](https://github.com/nucket/nekoai/blob/main/src/hooks/useMoodEngine.ts): `src/hooks/useMoodEngine.ts`
- [Pet renderer](https://github.com/nucket/nekoai/blob/main/src/pets/PetRenderer.tsx): `src/pets/PetRenderer.tsx`
- [Animation resolver](https://github.com/nucket/nekoai/blob/main/src/pets/resolveAnimation.ts): `src/pets/resolveAnimation.ts`
- [Speech bubble](https://github.com/nucket/nekoai/blob/main/src/components/SpeechBubble.tsx): `src/components/SpeechBubble.tsx`
- [Pet definitions](https://github.com/nucket/nekoai/blob/main/src/types/pet.ts): `src/types/pet.ts`
- [Runtime mood state](https://github.com/nucket/nekoai/blob/main/src/store/index.ts): `src/store/index.ts`

### AI and memory

- [AI provider router](https://github.com/nucket/nekoai/blob/main/src/ai/index.ts): `src/ai/index.ts`
- [AI providers](https://github.com/nucket/nekoai/tree/main/src/ai/providers): `src/ai/providers`
- [AI HTTP helper](https://github.com/nucket/nekoai/blob/main/src/ai/http.ts): `src/ai/http.ts`
- [Conversation memory](https://github.com/nucket/nekoai/blob/main/src/ai/memory.ts): `src/ai/memory.ts`

### Desktop services

- [Active app context](https://github.com/nucket/nekoai/blob/main/src/hooks/useDesktopContext.ts): `src/hooks/useDesktopContext.ts`
- [Tauri services](https://github.com/nucket/nekoai/blob/main/src-tauri/src/lib.rs): `src-tauri/src/lib.rs`
- [Cursor tracking](https://github.com/nucket/nekoai/blob/main/src-tauri/src/cursor_tracker.rs): `src-tauri/src/cursor_tracker.rs`
- [Desktop monitor](https://github.com/nucket/nekoai/blob/main/src-tauri/src/desktop_monitor.rs): `src-tauri/src/desktop_monitor.rs`
- [Persistent storage](https://github.com/nucket/nekoai/blob/main/src-tauri/src/storage.rs): `src-tauri/src/storage.rs`

### Windows and settings

- [Pet house](https://github.com/nucket/nekoai/blob/main/src/HouseWindow.tsx): `src/HouseWindow.tsx`
- [Panel window](https://github.com/nucket/nekoai/blob/main/src/PanelWindow.tsx): `src/PanelWindow.tsx`
- [Settings](https://github.com/nucket/nekoai/blob/main/src/components/SettingsPanel.tsx): `src/components/SettingsPanel.tsx`
- [Pet selector](https://github.com/nucket/nekoai/blob/main/src/components/PetSelector.tsx): `src/components/PetSelector.tsx`
- [Config store](https://github.com/nucket/nekoai/blob/main/src/store/configStore.ts): `src/store/configStore.ts`

### Other components

- **Desktop user**

## Connections

- Desktop user → Pet app: interacts with
- Pet app → Pet movement: coordinates (evidence: `src/App.tsx`)
- Pet app → Pet renderer: renders (evidence: `src/App.tsx`)
- Pet app → Animation resolver: resolves animations (evidence: `src/App.tsx`)
- Pet app → Speech bubble: renders (evidence: `src/App.tsx`)
- Pet app → Idle sequencing: uses (evidence: `src/App.tsx`)
- Pet app → Mood engine: uses (evidence: `src/App.tsx`)
- Pet movement → Desktop monitor: reads work area (evidence: `src/hooks/usePetMovement.ts`)
- Pet movement → Pet renderer: sets animation state
- Pet renderer → Pet definitions: uses definitions (evidence: `src/pets/PetRenderer.tsx`)
- Pet app → AI provider router: builds chat context (evidence: `src/App.tsx`)
- Pet app → Conversation memory: loads facts (evidence: `src/App.tsx`)
- AI provider router → AI providers: creates provider (evidence: `src/ai/index.ts`)
- AI providers → AI HTTP helper: uses HTTP helper (evidence: `src/ai/providers/anthropic.ts`)
- Pet app → Persistent storage: persists chat
- Pet app → Active app context: uses context (evidence: `src/App.tsx`)
- Active app context → Tauri services: invokes desktop commands
- Pet app → Tauri services: invokes native commands
- Tauri services → Cursor tracking: registers services (evidence: `src-tauri/src/lib.rs`)
- Tauri services → Desktop monitor: registers services (evidence: `src-tauri/src/lib.rs`)
- Tauri services → Persistent storage: registers services (evidence: `src-tauri/src/lib.rs`)
- Mood engine → Runtime mood state: updates mood (evidence: `src/hooks/useMoodEngine.ts`)
- Pet app → Config store: loads settings (evidence: `src/App.tsx`)
- Config store → Tauri services: persists config (evidence: `src/store/configStore.ts`)
- Pet app → Settings: shows settings (evidence: `src/App.tsx`)
- Pet app → Pet selector: shows selector (evidence: `src/App.tsx`)
- Settings → Config store: updates settings (evidence: `src/components/SettingsPanel.tsx`)
- Settings → AI provider router: tests provider (evidence: `src/components/SettingsPanel.tsx`)
- Pet selector → Config store: changes active pet (evidence: `src/components/PetSelector.tsx`)
- Pet house → Config store: reads settings (evidence: `src/HouseWindow.tsx`)
- Panel window → Config store: reads settings (evidence: `src/PanelWindow.tsx`)
