# onitaiaoi/where-daylight-pauses architecture

> Architecture diagram of the GitHub repository onitaiaoi/where-daylight-pauses, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/onitaiaoi/where-daylight-pauses
- Repository: https://github.com/onitaiaoi/where-daylight-pauses

## Overview

#### Purpose and Entry Point
This is a browser-based TypeScript game/application centered on player state, character interactions, UI screens, inventory, daily mood, and AI-backed chat. The primary bootstrap is `src/main.ts`, rendered through `index.html`. Core game constants and configuration are in `src/core/GameConfig.ts` and `src/config.ts`.

#### Application Composition
The app is organized as a client-side experience with feature-specific UI controllers rather than a server application. Major screens include the main HUD, character view, town map, rest house, passport, inventory, authentication, and NPC dialog:
- `src/ui/MainHUD.ts`
- `src/ui/TownMapUI.ts`
- `src/ui/NpcDialogUI.ts`

These modules likely own DOM construction/event handling for their respective game surfaces and are coordinated from the main runtime.

#### Player Identity and Persistence Boundary
Firebase is the persistence and identity boundary. `src/firebase/config.ts` initializes Firebase integration, while `src/firebase/playerData.ts` encapsulates reading and writing player-specific state. Authentication presentation is handled by `src/ui/AuthUI.ts`.

Primary flow: application startup initializes Firebase/configuration, authenticates or identifies a player, then loads player data for UI and game-state initialization. UI modules should depend on the player-data layer rather than directly coupling to Firebase.

#### Game State, Items, and Character Progression
Game-wide rules and player-facing state are defined across:
- `src/core/GameConfig.ts`
- `src/config/itemRegistry.ts`
- `src/utils/inventoryUtils.ts`

`itemRegistry.ts` is the canonical item-definition boundary; inventory operations should resolve item IDs through it rather than duplicating metadata. `inventoryUtils.ts` likely performs inventory transformations used by `src/ui/InventoryUI.ts`. Character and daily-state presentation are separated into `src/ui/CharacterUI.ts` and `src/ui/DailyMoodUI.ts`.

#### Conversational and AI Interaction
NPC/player chat is a distinct subsystem. `src/ui/ChatUI.ts` and `src/ui/NpcDialogUI.ts` provide interaction surfaces, while `src/ai/geminiService.ts` is the external AI-service adapter. Chat appearance/configuration is centralized in `src/config/chatSkinsConfig.ts`.

Control flow should remain: UI captures dialog input → AI service generates or retrieves a response → UI renders response and applies any allowed game-state effects. The Gemini adapter is the external-service boundary and should isolate provider-specific API behavior from UI modules.

#### Navigation and Gameplay Surfaces
The town map acts as the likely navigation hub (`src/ui/TownMapUI.ts`) between gameplay areas. The rest house and passport represent specialized gameplay/profile screens:
- `src/ui/RestHouseUI.ts`
- `src/ui/PassportUI.ts`
- `src/ui/MainHUD.ts`

`MainHUD` is the persistent cross-screen control/status layer; feature screens should avoid independently managing global navigation or shared player state.

#### Runtime and Assets
The runtime is a Node-managed TypeScript frontend project, indicated by `package.json`, root `tsconfig.json`, and installed dependencies in `node_modules`. Static client assets are served from `public/assets/images`. A nested `daylight-pauses/` package has its own `package.json` and TypeScript configuration, indicating a separate or embedded package boundary that should not be assumed to share the root runtime configuration.

Main entry points: [`src/main.ts`](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/main.ts) (Application Bootstrap), [`src/firebase/playerData.ts`](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/firebase/playerData.ts) (Player Data), [`src/ui/TownMapUI.ts`](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/TownMapUI.ts) (Town Map), [`src/ui/ChatUI.ts`](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/ChatUI.ts) (Chat UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client Runtime"]
  node_html["HTML Entry<br/>browser entry<br/>[index.html]"]
  node_main["Application Bootstrap<br/>TypeScript entry<br/>[main.ts]"]
  node_app_config["App Configuration<br/>runtime config<br/>[config.ts]"]
  node_assets["Client Assets<br/>static assets"]
  node_embedded_package["Daylight Pauses Package<br/>embedded package"]
end

subgraph group_state["Game State"]
  node_game_config["Game Rules<br/>game config<br/>[GameConfig.ts]"]
  node_item_registry["Item Registry<br/>item definitions<br/>[itemRegistry.ts]"]
  node_inventory_logic["Inventory Operations<br/>state utility<br/>[inventoryUtils.ts]"]
  node_chat_skins["Chat Skins<br/>chat config<br/>[chatSkinsConfig.ts]"]
end

subgraph group_ui["UI Surfaces"]
  node_main_hud["Main HUD<br/>persistent UI<br/>[MainHUD.ts]"]
  node_town_map["Town Map<br/>navigation UI<br/>[TownMapUI.ts]"]
  node_character["Character Screen<br/>profile UI<br/>[CharacterUI.ts]"]
  node_daily_mood["Daily Mood<br/>state UI<br/>[DailyMoodUI.ts]"]
  node_inventory_ui["Inventory Screen<br/>inventory UI<br/>[InventoryUI.ts]"]
  node_rest_house["Rest House<br/>gameplay UI<br/>[RestHouseUI.ts]"]
  node_passport["Passport<br/>profile UI<br/>[PassportUI.ts]"]
  node_auth_ui["Authentication<br/>identity UI<br/>[AuthUI.ts]"]
  node_npc_dialog["NPC Dialog<br/>conversation UI<br/>[NpcDialogUI.ts]"]
  node_chat_ui["Chat UI<br/>conversation UI<br/>[ChatUI.ts]"]
end

subgraph group_integrations["External Boundaries"]
  node_player_data["Player Data<br/>persistence facade<br/>[playerData.ts]"]
  node_firebase[("Firebase<br/>identity and database<br/>[config.ts]")]
  node_gemini{{"Gemini Adapter<br/>AI service adapter<br/>[geminiService.ts]"}}
end

node_html -->|"loads"| node_main
node_main -->|"reads"| node_app_config
node_main -->|"initializes with"| node_game_config
node_main -->|"starts identity flow"| node_auth_ui
node_auth_ui -->|"authenticates through"| node_firebase
node_main -->|"loads player state"| node_player_data
node_player_data -->|"persists via"| node_firebase
node_main -->|"mounts"| node_main_hud
node_main -->|"mounts"| node_town_map
node_main_hud -->|"reads shared state"| node_player_data
node_town_map -->|"navigates to"| node_character
node_town_map -->|"navigates to"| node_inventory_ui
node_town_map -->|"navigates to"| node_rest_house
node_town_map -->|"navigates to"| node_passport
node_town_map -->|"opens"| node_npc_dialog
node_character -->|"presents state"| node_player_data
node_daily_mood -->|"presents state"| node_player_data
node_inventory_ui -->|"uses"| node_inventory_logic
node_inventory_logic -->|"resolves item IDs"| node_item_registry
node_inventory_ui -->|"updates inventory"| node_player_data
node_npc_dialog -->|"uses"| node_chat_ui
node_chat_ui -->|"applies"| node_chat_skins
node_chat_ui -->|"sends dialog input"| node_gemini
node_gemini -->|"returns response"| node_chat_ui
node_npc_dialog -.->|"applies allowed effects"| node_player_data
node_main -.->|"serves visuals"| node_assets

click node_html "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/index.html"
click node_main "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/main.ts"
click node_game_config "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/core/GameConfig.ts"
click node_app_config "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/config.ts"
click node_player_data "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/firebase/playerData.ts"
click node_firebase "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/firebase/config.ts"
click node_item_registry "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/config/itemRegistry.ts"
click node_inventory_logic "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/utils/inventoryUtils.ts"
click node_main_hud "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/MainHUD.ts"
click node_town_map "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/TownMapUI.ts"
click node_character "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/CharacterUI.ts"
click node_daily_mood "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/DailyMoodUI.ts"
click node_inventory_ui "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/InventoryUI.ts"
click node_rest_house "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/RestHouseUI.ts"
click node_passport "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/PassportUI.ts"
click node_auth_ui "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/AuthUI.ts"
click node_npc_dialog "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/NpcDialogUI.ts"
click node_chat_ui "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/ChatUI.ts"
click node_chat_skins "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/config/chatSkinsConfig.ts"
click node_gemini "https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ai/geminiService.ts"
click node_assets "https://github.com/onitaiaoi/where-daylight-pauses/tree/main/public/assets/images"
click node_embedded_package "https://github.com/onitaiaoi/where-daylight-pauses/tree/main/daylight-pauses"

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_html,node_main,node_app_config,node_assets,node_embedded_package toneBlue
class node_game_config,node_item_registry,node_inventory_logic,node_chat_skins toneAmber
class node_main_hud,node_town_map,node_character,node_daily_mood,node_inventory_ui,node_rest_house,node_passport,node_auth_ui,node_npc_dialog,node_chat_ui toneMint
class node_player_data,node_firebase,node_gemini toneRose
```

## Components

### Client Runtime

- [HTML Entry](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/index.html): browser entry · `index.html`
- [Application Bootstrap](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/main.ts): TypeScript entry · Initializes the client runtime and coordinates screens. · `src/main.ts`
- [App Configuration](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/config.ts): runtime config · `src/config.ts`
- [Client Assets](https://github.com/onitaiaoi/where-daylight-pauses/tree/main/public/assets/images): static assets · `public/assets/images`
- [Daylight Pauses Package](https://github.com/onitaiaoi/where-daylight-pauses/tree/main/daylight-pauses): embedded package · Separate package with its own runtime configuration. · `daylight-pauses`

### Game State

- [Game Rules](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/core/GameConfig.ts): game config · `src/core/GameConfig.ts`
- [Item Registry](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/config/itemRegistry.ts): item definitions · Canonical metadata for item IDs. · `src/config/itemRegistry.ts`
- [Inventory Operations](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/utils/inventoryUtils.ts): state utility · `src/utils/inventoryUtils.ts`
- [Chat Skins](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/config/chatSkinsConfig.ts): chat config · `src/config/chatSkinsConfig.ts`

### UI Surfaces

- [Main HUD](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/MainHUD.ts): persistent UI · Cross-screen controls and status. · `src/ui/MainHUD.ts`
- [Town Map](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/TownMapUI.ts): navigation UI · Navigation hub for gameplay areas. · `src/ui/TownMapUI.ts`
- [Character Screen](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/CharacterUI.ts): profile UI · `src/ui/CharacterUI.ts`
- [Daily Mood](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/DailyMoodUI.ts): state UI · `src/ui/DailyMoodUI.ts`
- [Inventory Screen](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/InventoryUI.ts): inventory UI · `src/ui/InventoryUI.ts`
- [Rest House](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/RestHouseUI.ts): gameplay UI · `src/ui/RestHouseUI.ts`
- [Passport](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/PassportUI.ts): profile UI · `src/ui/PassportUI.ts`
- [Authentication](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/AuthUI.ts): identity UI · `src/ui/AuthUI.ts`
- [NPC Dialog](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/NpcDialogUI.ts): conversation UI · `src/ui/NpcDialogUI.ts`
- [Chat UI](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ui/ChatUI.ts): conversation UI · `src/ui/ChatUI.ts`

### External Boundaries

- [Player Data](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/firebase/playerData.ts): persistence facade · Encapsulates player-specific reads and writes. · `src/firebase/playerData.ts`
- [Firebase](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/firebase/config.ts): identity and database · Authentication and persistent player-state boundary. · `src/firebase/config.ts`
- [Gemini Adapter](https://github.com/onitaiaoi/where-daylight-pauses/blob/main/src/ai/geminiService.ts): AI service adapter · Isolates provider-specific AI behavior from UI. · `src/ai/geminiService.ts`

## Connections

- HTML Entry → Application Bootstrap: loads
- Application Bootstrap → App Configuration: reads
- Application Bootstrap → Game Rules: initializes with
- Application Bootstrap → Authentication: starts identity flow
- Authentication → Firebase: authenticates through
- Application Bootstrap → Player Data: loads player state
- Player Data → Firebase: persists via
- Application Bootstrap → Main HUD: mounts
- Application Bootstrap → Town Map: mounts
- Main HUD → Player Data: reads shared state
- Town Map → Character Screen: navigates to
- Town Map → Inventory Screen: navigates to
- Town Map → Rest House: navigates to
- Town Map → Passport: navigates to
- Town Map → NPC Dialog: opens
- Character Screen → Player Data: presents state
- Daily Mood → Player Data: presents state
- Inventory Screen → Inventory Operations: uses
- Inventory Operations → Item Registry: resolves item IDs
- Inventory Screen → Player Data: updates inventory
- NPC Dialog → Chat UI: uses
- Chat UI → Chat Skins: applies
- Chat UI → Gemini Adapter: sends dialog input
- Gemini Adapter → Chat UI: returns response
- NPC Dialog → Player Data: applies allowed effects
- Application Bootstrap → Client Assets: serves visuals
