# baihezr/firefly architecture

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

- Interactive diagram: https://gitdiagram.com/baihezr/firefly
- Repository: https://github.com/baihezr/firefly

## Overview

Firefly is an Electron/Vue companion-raising game. Players enter the routed app, interact with the 3D companion and progression systems, and branch into shopping, music, and mini-games; optional AI chat and host-mode multiplayer extend that experience. The graph includes the desktop host and documented major capabilities. Several view implementations are unsampled, so links show only routing or other documented wiring rather than inferred view-to-store calls.

Main entry points: [`src/router/index.js`](https://github.com/baihezr/firefly/blob/main/src/router/index.js) (Route table), [`src/App.vue`](https://github.com/baihezr/firefly/blob/main/src/App.vue) (App shell), [`src/main.js`](https://github.com/baihezr/firefly/blob/main/src/main.js) (Vue bootstrap), [`src/services/ai.js`](https://github.com/baihezr/firefly/blob/main/src/services/ai.js) (AI chat service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App runtime"]
  node_vue["Vue bootstrap<br/>[main.js]"]
  node_shell["App shell<br/>[App.vue]"]
  node_routes["Route table<br/>[index.js]"]
end

subgraph group_game["Companion progression"]
  node_home["Companion home<br/>[Home.vue]"]
  node_character["3D character<br/>[PMXCharacter.vue]"]
  node_gold["Gold progression<br/>[gold.js]"]
  node_inventory["Inventory buffs<br/>[inventory.js]"]
  node_tasks["Tasks rewards<br/>[tasks.js]"]
  node_save["Save slots<br/>[saveSlots.js]"]
end

subgraph group_activities["Activities"]
  node_shop["Item shop<br/>[shop.vue]"]
  node_warehouse["Warehouse<br/>[warehouse.vue]"]
  node_chess["Gomoku game<br/>[Chess.vue]"]
  node_gomoku["Gomoku rules AI<br/>[gomoku.js]"]
  node_guess["Word guessing<br/>[GuessWord.vue]"]
  node_music["Music player<br/>[Music.vue]"]
  node_multiplayer["Multiplayer view<br/>[Multiplayer.vue]"]
end

subgraph group_platform["Platform services"]
  node_ai["AI chat service<br/>[ai.js]"]
  node_chat["Chat interface<br/>[ChatDialog.vue]"]
  node_desktop["Electron host<br/>[main.js]"]
  node_rooms["WebSocket rooms<br/>[wsServer.js]"]
  node_browserstore[("Browser storage")]
  node_serviceworker["Offline shell<br/>[sw.js]"]
end

node_player(("Player"))
node_aiendpoint{{"AI API"}}

node_player -->|"opens app"| node_vue
node_vue -->|"mounts"| node_shell
node_shell -->|"renders routes"| node_routes
node_routes -->|"routes to"| node_home
node_routes -->|"routes to"| node_shop
node_routes -->|"routes to"| node_warehouse
node_routes -->|"routes to"| node_chess
node_routes -->|"routes to"| node_guess
node_routes -->|"routes to"| node_music
node_routes -->|"routes to"| node_multiplayer
node_home -->|"presents"| node_character
node_shell -->|"initializes"| node_save
node_shell -->|"uses"| node_gold
node_shell -->|"uses"| node_inventory
node_shell -->|"uses"| node_tasks
node_tasks -->|"awards gold"| node_gold
node_shop -->|"uses currency"| node_gold
node_warehouse -->|"shows items"| node_inventory
node_chess -->|"uses rules"| node_gomoku
node_chat -->|"requests replies"| node_ai
node_ai -.->|"sends chat"| node_aiendpoint
node_desktop -->|"starts server"| node_rooms
node_desktop -->|"hosts window"| node_vue
node_vue -->|"registers"| node_serviceworker
node_shell -->|"persists state"| node_browserstore
node_ai -->|"stores config"| node_browserstore

click node_vue "https://github.com/baihezr/firefly/blob/main/src/main.js"
click node_shell "https://github.com/baihezr/firefly/blob/main/src/App.vue"
click node_routes "https://github.com/baihezr/firefly/blob/main/src/router/index.js"
click node_home "https://github.com/baihezr/firefly/blob/main/src/views/Home.vue"
click node_character "https://github.com/baihezr/firefly/blob/main/src/components/PMXCharacter.vue"
click node_gold "https://github.com/baihezr/firefly/blob/main/src/config/gold.js"
click node_inventory "https://github.com/baihezr/firefly/blob/main/src/config/inventory.js"
click node_tasks "https://github.com/baihezr/firefly/blob/main/src/config/tasks.js"
click node_save "https://github.com/baihezr/firefly/blob/main/src/config/saveSlots.js"
click node_shop "https://github.com/baihezr/firefly/blob/main/src/views/shop.vue"
click node_warehouse "https://github.com/baihezr/firefly/blob/main/src/views/warehouse.vue"
click node_chess "https://github.com/baihezr/firefly/blob/main/src/views/Chess.vue"
click node_gomoku "https://github.com/baihezr/firefly/blob/main/src/utils/gomoku.js"
click node_guess "https://github.com/baihezr/firefly/blob/main/src/views/GuessWord.vue"
click node_music "https://github.com/baihezr/firefly/blob/main/src/views/Music.vue"
click node_ai "https://github.com/baihezr/firefly/blob/main/src/services/ai.js"
click node_chat "https://github.com/baihezr/firefly/blob/main/src/components/ChatDialog.vue"
click node_desktop "https://github.com/baihezr/firefly/blob/main/electron/main.js"
click node_rooms "https://github.com/baihezr/firefly/blob/main/electron/multiplayer/wsServer.js"
click node_multiplayer "https://github.com/baihezr/firefly/blob/main/src/views/Multiplayer.vue"
click node_serviceworker "https://github.com/baihezr/firefly/blob/main/public/sw.js"

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_vue,node_shell,node_routes toneBlue
class node_home,node_character,node_gold,node_inventory,node_tasks,node_save toneAmber
class node_shop,node_warehouse,node_chess,node_gomoku,node_guess,node_music,node_multiplayer,node_aiendpoint toneMint
class node_ai,node_chat,node_desktop,node_rooms,node_browserstore,node_serviceworker toneRose
class node_player toneIndigo
```

## Components

### App runtime

- [Vue bootstrap](https://github.com/baihezr/firefly/blob/main/src/main.js): `src/main.js`
- [App shell](https://github.com/baihezr/firefly/blob/main/src/App.vue): `src/App.vue`
- [Route table](https://github.com/baihezr/firefly/blob/main/src/router/index.js): `src/router/index.js`

### Companion progression

- [Companion home](https://github.com/baihezr/firefly/blob/main/src/views/Home.vue): `src/views/Home.vue`
- [3D character](https://github.com/baihezr/firefly/blob/main/src/components/PMXCharacter.vue): `src/components/PMXCharacter.vue`
- [Gold progression](https://github.com/baihezr/firefly/blob/main/src/config/gold.js): `src/config/gold.js`
- [Inventory buffs](https://github.com/baihezr/firefly/blob/main/src/config/inventory.js): `src/config/inventory.js`
- [Tasks rewards](https://github.com/baihezr/firefly/blob/main/src/config/tasks.js): `src/config/tasks.js`
- [Save slots](https://github.com/baihezr/firefly/blob/main/src/config/saveSlots.js): `src/config/saveSlots.js`

### Activities

- [Item shop](https://github.com/baihezr/firefly/blob/main/src/views/shop.vue): `src/views/shop.vue`
- [Warehouse](https://github.com/baihezr/firefly/blob/main/src/views/warehouse.vue): `src/views/warehouse.vue`
- [Gomoku game](https://github.com/baihezr/firefly/blob/main/src/views/Chess.vue): `src/views/Chess.vue`
- [Gomoku rules AI](https://github.com/baihezr/firefly/blob/main/src/utils/gomoku.js): `src/utils/gomoku.js`
- [Word guessing](https://github.com/baihezr/firefly/blob/main/src/views/GuessWord.vue): `src/views/GuessWord.vue`
- [Music player](https://github.com/baihezr/firefly/blob/main/src/views/Music.vue): `src/views/Music.vue`
- [Multiplayer view](https://github.com/baihezr/firefly/blob/main/src/views/Multiplayer.vue): `src/views/Multiplayer.vue`

### Platform services

- [AI chat service](https://github.com/baihezr/firefly/blob/main/src/services/ai.js): `src/services/ai.js`
- [Chat interface](https://github.com/baihezr/firefly/blob/main/src/components/ChatDialog.vue): `src/components/ChatDialog.vue`
- [Electron host](https://github.com/baihezr/firefly/blob/main/electron/main.js): `electron/main.js`
- [WebSocket rooms](https://github.com/baihezr/firefly/blob/main/electron/multiplayer/wsServer.js): `electron/multiplayer/wsServer.js`
- **Browser storage**
- [Offline shell](https://github.com/baihezr/firefly/blob/main/public/sw.js): `public/sw.js`

### Other components

- **Player**
- **AI API**

## Connections

- Player → Vue bootstrap: opens app
- Vue bootstrap → App shell: mounts
- App shell → Route table: renders routes
- Route table → Companion home: routes to
- Route table → Item shop: routes to
- Route table → Warehouse: routes to
- Route table → Gomoku game: routes to
- Route table → Word guessing: routes to
- Route table → Music player: routes to
- Route table → Multiplayer view: routes to
- Companion home → 3D character: presents
- App shell → Save slots: initializes
- App shell → Gold progression: uses
- App shell → Inventory buffs: uses
- App shell → Tasks rewards: uses
- Tasks rewards → Gold progression: awards gold
- Item shop → Gold progression: uses currency
- Warehouse → Inventory buffs: shows items
- Gomoku game → Gomoku rules AI: uses rules
- Chat interface → AI chat service: requests replies
- AI chat service → AI API: sends chat
- Electron host → WebSocket rooms: starts server
- Electron host → Vue bootstrap: hosts window
- Vue bootstrap → Offline shell: registers
- App shell → Browser storage: persists state
- AI chat service → Browser storage: stores config
