# swapnaniltripathy/mochi architecture

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

- Interactive diagram: https://gitdiagram.com/swapnaniltripathy/mochi
- Repository: https://github.com/swapnaniltripathy/mochi

## Overview

Mochi is an Electron desktop pet: the user interacts with the pet or system tray, the main process manages movement, behaviors, settings, and persistent stats, and renderer windows present animated reactions and controls. The graph reflects relationships visible in the supplied excerpts and README; assets and several main-process routes are documented but their wiring is not fully sampled.

Main entry points: [`src/main.js`](https://github.com/swapnaniltripathy/mochi/blob/main/src/main.js) (Pet controller), [`src/renderer.js`](https://github.com/swapnaniltripathy/mochi/blob/main/src/renderer.js) (Pet renderer), [`src/preload.js`](https://github.com/swapnaniltripathy/mochi/blob/main/src/preload.js) (IPC bridge), [`src/settings.js`](https://github.com/swapnaniltripathy/mochi/blob/main/src/settings.js) (Settings renderer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop runtime"]
  node_main["Pet controller<br/>[main.js]"]
  node_preload["IPC bridge<br/>[preload.js]"]
  node_petwindow["Pet window<br/>[index.html]"]
  node_tray["Tray controls<br/>[main.js]"]
  node_notifications["Milestone notifications<br/>[main.js]"]
end

subgraph group_pet["Pet interaction"]
  node_petview["Pet renderer<br/>[renderer.js]"]
  node_movement["Movement and behavior<br/>[main.js]"]
  node_affection["Affection and treats<br/>[main.js]"]
end

subgraph group_settings["Settings and state"]
  node_settingsview["Settings renderer<br/>[settings.js]"]
  node_settingswindow["Settings window<br/>[settings.html]"]
  node_state[("Settings and stats<br/>[main.js]")]
end

subgraph group_presentation["Animation and artwork"]
  node_sprite["Animation playback<br/>[renderer.js]"]
  node_rig["Layered rig<br/>[rig.js]"]
  node_animationassets["Animation assets<br/>[manifest.json]"]
  node_rigassets["Rig artwork<br/>[manifest.json]"]
  node_fallback["Idle sprite assets"]
end

node_user(("Desktop user"))
node_os(("Windows desktop"))

node_user -->|"interacts"| node_petview
node_petview -->|"sends IPC"| node_preload
node_preload -->|"forwards IPC"| node_main
node_main -->|"controls"| node_movement
node_main -->|"handles actions"| node_affection
node_main -->|"creates controls"| node_tray
node_main -->|"shows alerts"| node_notifications
node_main -->|"loads and saves"| node_state
node_main -->|"creates window"| node_petwindow
node_main -->|"creates window"| node_settingswindow
node_main -->|"configures bridge"| node_preload
node_main -->|"sends state"| node_petview
node_main -->|"sends settings"| node_settingsview
node_petview -->|"selects animations"| node_sprite
node_sprite -->|"loads manifest"| node_animationassets
node_sprite -->|"falls back to"| node_fallback
node_petview -.->|"uses rig renderer"| node_rig
node_rig -->|"uses layered pieces"| node_rigassets
node_settingsview -->|"requests updates"| node_preload
node_os -.->|"provides desktop services"| node_main
node_user -->|"uses controls"| node_tray

click node_main "https://github.com/swapnaniltripathy/mochi/blob/main/src/main.js"
click node_preload "https://github.com/swapnaniltripathy/mochi/blob/main/src/preload.js"
click node_petview "https://github.com/swapnaniltripathy/mochi/blob/main/src/renderer.js"
click node_settingsview "https://github.com/swapnaniltripathy/mochi/blob/main/src/settings.js"
click node_petwindow "https://github.com/swapnaniltripathy/mochi/blob/main/src/index.html"
click node_settingswindow "https://github.com/swapnaniltripathy/mochi/blob/main/src/settings.html"
click node_state "https://github.com/swapnaniltripathy/mochi/blob/main/src/main.js"
click node_movement "https://github.com/swapnaniltripathy/mochi/blob/main/src/main.js"
click node_affection "https://github.com/swapnaniltripathy/mochi/blob/main/src/main.js"
click node_tray "https://github.com/swapnaniltripathy/mochi/blob/main/src/main.js"
click node_notifications "https://github.com/swapnaniltripathy/mochi/blob/main/src/main.js"
click node_sprite "https://github.com/swapnaniltripathy/mochi/blob/main/src/renderer.js"
click node_rig "https://github.com/swapnaniltripathy/mochi/blob/main/src/rig.js"
click node_animationassets "https://github.com/swapnaniltripathy/mochi/blob/main/src/assets/animations/manifest.json"
click node_rigassets "https://github.com/swapnaniltripathy/mochi/blob/main/src/assets/rig/manifest.json"
click node_fallback "https://github.com/swapnaniltripathy/mochi/tree/main/src/assets/idle"

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_preload,node_petwindow,node_tray,node_notifications,node_user toneBlue
class node_petview,node_movement,node_affection toneAmber
class node_settingsview,node_settingswindow,node_state toneMint
class node_sprite,node_rig,node_animationassets,node_rigassets,node_fallback toneRose
class node_os toneIndigo
```

## Components

### Desktop runtime

- [Pet controller](https://github.com/swapnaniltripathy/mochi/blob/main/src/main.js): `src/main.js`
- [IPC bridge](https://github.com/swapnaniltripathy/mochi/blob/main/src/preload.js): `src/preload.js`
- [Pet window](https://github.com/swapnaniltripathy/mochi/blob/main/src/index.html): `src/index.html`
- [Tray controls](https://github.com/swapnaniltripathy/mochi/blob/main/src/main.js): `src/main.js`
- [Milestone notifications](https://github.com/swapnaniltripathy/mochi/blob/main/src/main.js): `src/main.js`

### Pet interaction

- [Pet renderer](https://github.com/swapnaniltripathy/mochi/blob/main/src/renderer.js): `src/renderer.js`
- [Movement and behavior](https://github.com/swapnaniltripathy/mochi/blob/main/src/main.js): `src/main.js`
- [Affection and treats](https://github.com/swapnaniltripathy/mochi/blob/main/src/main.js): `src/main.js`

### Settings and state

- [Settings renderer](https://github.com/swapnaniltripathy/mochi/blob/main/src/settings.js): `src/settings.js`
- [Settings window](https://github.com/swapnaniltripathy/mochi/blob/main/src/settings.html): `src/settings.html`
- [Settings and stats](https://github.com/swapnaniltripathy/mochi/blob/main/src/main.js): `src/main.js`

### Animation and artwork

- [Animation playback](https://github.com/swapnaniltripathy/mochi/blob/main/src/renderer.js): `src/renderer.js`
- [Layered rig](https://github.com/swapnaniltripathy/mochi/blob/main/src/rig.js): `src/rig.js`
- [Animation assets](https://github.com/swapnaniltripathy/mochi/blob/main/src/assets/animations/manifest.json): `src/assets/animations/manifest.json`
- [Rig artwork](https://github.com/swapnaniltripathy/mochi/blob/main/src/assets/rig/manifest.json): `src/assets/rig/manifest.json`
- [Idle sprite assets](https://github.com/swapnaniltripathy/mochi/tree/main/src/assets/idle): `src/assets/idle`

### Other components

- **Desktop user**
- **Windows desktop**

## Connections

- Desktop user → Pet renderer: interacts (evidence: `README.md`)
- Pet renderer → IPC bridge: sends IPC (evidence: `src/renderer.js`)
- IPC bridge → Pet controller: forwards IPC (evidence: `src/preload.js`)
- Pet controller → Movement and behavior: controls (evidence: `src/main.js`)
- Pet controller → Affection and treats: handles actions (evidence: `src/main.js`)
- Pet controller → Tray controls: creates controls (evidence: `src/main.js`)
- Pet controller → Milestone notifications: shows alerts (evidence: `src/main.js`)
- Pet controller → Settings and stats: loads and saves (evidence: `src/main.js`)
- Pet controller → Pet window: creates window (evidence: `src/main.js`)
- Pet controller → Settings window: creates window (evidence: `src/main.js`)
- Pet controller → IPC bridge: configures bridge (evidence: `src/main.js`)
- Pet controller → Pet renderer: sends state (evidence: `src/main.js`)
- Pet controller → Settings renderer: sends settings (evidence: `src/main.js`)
- Pet renderer → Animation playback: selects animations (evidence: `src/renderer.js`)
- Animation playback → Animation assets: loads manifest (evidence: `src/renderer.js`)
- Animation playback → Idle sprite assets: falls back to (evidence: `src/renderer.js`)
- Pet renderer → Layered rig: uses rig renderer
- Layered rig → Rig artwork: uses layered pieces (evidence: `src/rig.js`)
- Settings renderer → IPC bridge: requests updates (evidence: `src/settings.js`)
- Windows desktop → Pet controller: provides desktop services
- Desktop user → Tray controls: uses controls (evidence: `README.md`)
