# shogo00713/horsegame architecture

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

- Interactive diagram: https://gitdiagram.com/shogo00713/horsegame
- Repository: https://github.com/shogo00713/horsegame

## Overview

Horse Game is a browser-based horse-racing betting simulation. Players choose a bet type, horses, and stakes; submitting a valid set of bets starts a race whose result is determined before its animation. The game calculates winning payouts, updates the player’s money and horse conditions, then returns to betting. The graph also includes odds and race-history views, help/tutorial content, and theme controls. Relationships are based on the README and indexed or excerpted source; unsampled implementation details are represented only where documented.

Main entry points: [`src/App.tsx`](https://github.com/shogo00713/horsegame/blob/main/src/App.tsx) (Game screen), [`src/hooks/useHorseGame.ts`](https://github.com/shogo00713/horsegame/blob/main/src/hooks/useHorseGame.ts) (Game state and flow), [`src/components/Header.tsx`](https://github.com/shogo00713/horsegame/blob/main/src/components/Header.tsx) (Header), [`src/components/BetPanel.tsx`](https://github.com/shogo00713/horsegame/blob/main/src/components/BetPanel.tsx) (Bet panel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_entry["React entry<br/>[index.tsx]"]
  node_appview["Game screen<br/>[App.tsx]"]
  node_header["Header<br/>[Header.tsx]"]
  node_theme["Theme state<br/>[useTheme.ts]"]
  node_tutorialstate["Tutorial state<br/>[useTutorial.ts]"]
  node_gamehook["Game state and flow<br/>[useHorseGame.ts]"]
end

subgraph group_betting["Betting"]
  node_betpanel["Bet panel<br/>[BetPanel.tsx]"]
  node_beteditor["Bet editor<br/>[BetEditor.tsx]"]
  node_betrules["Bet validation<br/>[checkBetRules.ts]"]
end

subgraph group_race["Race and payouts"]
  node_results["Race results"]
  node_odds["Odds calculation<br/>[calculateOdds.ts]"]
  node_payoutcalc["Payout calculation<br/>[calculatePayout.ts]"]
  node_animation["Race animation"]
  node_resultpanel["Race display<br/>[ResultPanel.tsx]"]
  node_payoutpanel["Payout display<br/>[PayoutPanel.tsx]"]
end

subgraph group_support["Player support"]
  node_history["Race history<br/>[HistoryModal.tsx]"]
  node_guide["Game guide<br/>[guide.ts]"]
  node_guidecontent["Guide view<br/>[GuideContent.tsx]"]
  node_menu["Menu<br/>[MenuModal.tsx]"]
  node_tutorial["Tutorial<br/>[Tutorial.tsx]"]
end

subgraph group_domain["Game domain"]
  node_runners["Runner data<br/>[runners.ts]"]
  node_stats["Horse strength"]
  node_conditions["Horse conditions"]
end

node_player(("Player"))
node_browser(("Browser"))
node_conditionstore[("Browser storage")]

node_player -->|"plays"| node_appview
node_entry -->|"mounts"| node_appview
node_appview -->|"uses"| node_gamehook
node_appview -->|"renders"| node_header
node_appview -->|"renders"| node_betpanel
node_appview -->|"renders"| node_resultpanel
node_appview -->|"renders"| node_payoutpanel
node_appview -->|"renders"| node_history
node_appview -->|"renders"| node_menu
node_appview -->|"renders"| node_tutorial
node_appview -->|"uses"| node_theme
node_appview -->|"uses"| node_tutorialstate
node_betpanel -->|"renders"| node_beteditor
node_beteditor -->|"validates with"| node_betrules
node_betpanel -->|"submits bets"| node_gamehook
node_gamehook -->|"checks bets"| node_betrules
node_gamehook -->|"loads"| node_runners
node_gamehook -->|"determines finish"| node_results
node_gamehook -->|"calculates returns"| node_payoutcalc
node_gamehook -->|"updates"| node_conditions
node_gamehook -->|"reads and writes"| node_conditionstore
node_runners -->|"uses"| node_odds
node_results -->|"uses"| node_conditions
node_odds -->|"applies"| node_conditions
node_payoutcalc -->|"gets multiplier"| node_odds
node_resultpanel -->|"runs script"| node_animation
node_gamehook -->|"provides result"| node_resultpanel
node_gamehook -->|"provides payout"| node_payoutpanel
node_history -->|"summarizes horses"| node_stats
node_menu -->|"renders"| node_guidecontent
node_guidecontent -->|"displays"| node_guide
node_tutorial -->|"displays"| node_guide
node_header -->|"opens"| node_history
node_header -->|"opens"| node_menu
node_player -.->|"uses"| node_browser

click node_entry "https://github.com/shogo00713/horsegame/blob/main/src/index.tsx"
click node_appview "https://github.com/shogo00713/horsegame/blob/main/src/App.tsx"
click node_header "https://github.com/shogo00713/horsegame/blob/main/src/components/Header.tsx"
click node_theme "https://github.com/shogo00713/horsegame/blob/main/src/hooks/useTheme.ts"
click node_tutorialstate "https://github.com/shogo00713/horsegame/blob/main/src/hooks/useTutorial.ts"
click node_gamehook "https://github.com/shogo00713/horsegame/blob/main/src/hooks/useHorseGame.ts"
click node_betpanel "https://github.com/shogo00713/horsegame/blob/main/src/components/BetPanel.tsx"
click node_beteditor "https://github.com/shogo00713/horsegame/blob/main/src/components/BetEditor.tsx"
click node_betrules "https://github.com/shogo00713/horsegame/blob/main/src/logic/checkBetRules.ts"
click node_runners "https://github.com/shogo00713/horsegame/blob/main/src/data/runners.ts"
click node_stats "https://github.com/shogo00713/horsegame/blob/main/src/logic/calculateHorseStats.ts"
click node_conditions "https://github.com/shogo00713/horsegame/blob/main/src/logic/updateHorseCondition.ts"
click node_results "https://github.com/shogo00713/horsegame/blob/main/src/logic/determineRaceResults.ts"
click node_odds "https://github.com/shogo00713/horsegame/blob/main/src/logic/calculateOdds.ts"
click node_payoutcalc "https://github.com/shogo00713/horsegame/blob/main/src/logic/calculatePayout.ts"
click node_animation "https://github.com/shogo00713/horsegame/blob/main/src/logic/controlRaceAnimation.ts"
click node_resultpanel "https://github.com/shogo00713/horsegame/blob/main/src/components/ResultPanel.tsx"
click node_payoutpanel "https://github.com/shogo00713/horsegame/blob/main/src/components/PayoutPanel.tsx"
click node_history "https://github.com/shogo00713/horsegame/blob/main/src/components/HistoryModal.tsx"
click node_guide "https://github.com/shogo00713/horsegame/blob/main/src/data/guide.ts"
click node_guidecontent "https://github.com/shogo00713/horsegame/blob/main/src/components/GuideContent.tsx"
click node_menu "https://github.com/shogo00713/horsegame/blob/main/src/components/MenuModal.tsx"
click node_tutorial "https://github.com/shogo00713/horsegame/blob/main/src/components/Tutorial.tsx"

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_entry,node_appview,node_header,node_theme,node_tutorialstate,node_gamehook,node_browser toneBlue
class node_betpanel,node_beteditor,node_betrules,node_conditionstore toneAmber
class node_results,node_odds,node_payoutcalc,node_animation,node_resultpanel,node_payoutpanel toneMint
class node_history,node_guide,node_guidecontent,node_menu,node_tutorial toneRose
class node_runners,node_stats,node_conditions,node_player toneIndigo
```

## Components

### Application

- [React entry](https://github.com/shogo00713/horsegame/blob/main/src/index.tsx): `src/index.tsx`
- [Game screen](https://github.com/shogo00713/horsegame/blob/main/src/App.tsx): `src/App.tsx`
- [Header](https://github.com/shogo00713/horsegame/blob/main/src/components/Header.tsx): `src/components/Header.tsx`
- [Theme state](https://github.com/shogo00713/horsegame/blob/main/src/hooks/useTheme.ts): `src/hooks/useTheme.ts`
- [Tutorial state](https://github.com/shogo00713/horsegame/blob/main/src/hooks/useTutorial.ts): `src/hooks/useTutorial.ts`
- [Game state and flow](https://github.com/shogo00713/horsegame/blob/main/src/hooks/useHorseGame.ts): `src/hooks/useHorseGame.ts`

### Betting

- [Bet panel](https://github.com/shogo00713/horsegame/blob/main/src/components/BetPanel.tsx): `src/components/BetPanel.tsx`
- [Bet editor](https://github.com/shogo00713/horsegame/blob/main/src/components/BetEditor.tsx): `src/components/BetEditor.tsx`
- [Bet validation](https://github.com/shogo00713/horsegame/blob/main/src/logic/checkBetRules.ts): `src/logic/checkBetRules.ts`

### Race and payouts

- [Race results](https://github.com/shogo00713/horsegame/blob/main/src/logic/determineRaceResults.ts): `src/logic/determineRaceResults.ts`
- [Odds calculation](https://github.com/shogo00713/horsegame/blob/main/src/logic/calculateOdds.ts): `src/logic/calculateOdds.ts`
- [Payout calculation](https://github.com/shogo00713/horsegame/blob/main/src/logic/calculatePayout.ts): `src/logic/calculatePayout.ts`
- [Race animation](https://github.com/shogo00713/horsegame/blob/main/src/logic/controlRaceAnimation.ts): `src/logic/controlRaceAnimation.ts`
- [Race display](https://github.com/shogo00713/horsegame/blob/main/src/components/ResultPanel.tsx): `src/components/ResultPanel.tsx`
- [Payout display](https://github.com/shogo00713/horsegame/blob/main/src/components/PayoutPanel.tsx): `src/components/PayoutPanel.tsx`

### Player support

- [Race history](https://github.com/shogo00713/horsegame/blob/main/src/components/HistoryModal.tsx): `src/components/HistoryModal.tsx`
- [Game guide](https://github.com/shogo00713/horsegame/blob/main/src/data/guide.ts): `src/data/guide.ts`
- [Guide view](https://github.com/shogo00713/horsegame/blob/main/src/components/GuideContent.tsx): `src/components/GuideContent.tsx`
- [Menu](https://github.com/shogo00713/horsegame/blob/main/src/components/MenuModal.tsx): `src/components/MenuModal.tsx`
- [Tutorial](https://github.com/shogo00713/horsegame/blob/main/src/components/Tutorial.tsx): `src/components/Tutorial.tsx`

### Game domain

- [Runner data](https://github.com/shogo00713/horsegame/blob/main/src/data/runners.ts): `src/data/runners.ts`
- [Horse strength](https://github.com/shogo00713/horsegame/blob/main/src/logic/calculateHorseStats.ts): `src/logic/calculateHorseStats.ts`
- [Horse conditions](https://github.com/shogo00713/horsegame/blob/main/src/logic/updateHorseCondition.ts): `src/logic/updateHorseCondition.ts`

### Other components

- **Player**
- **Browser**
- **Browser storage**

## Connections

- Player → Game screen: plays (evidence: `README.md`)
- React entry → Game screen: mounts (evidence: `src/index.tsx`)
- Game screen → Game state and flow: uses (evidence: `src/App.tsx`)
- Game screen → Header: renders (evidence: `src/App.tsx`)
- Game screen → Bet panel: renders (evidence: `src/App.tsx`)
- Game screen → Race display: renders (evidence: `src/App.tsx`)
- Game screen → Payout display: renders (evidence: `src/App.tsx`)
- Game screen → Race history: renders (evidence: `src/App.tsx`)
- Game screen → Menu: renders (evidence: `src/App.tsx`)
- Game screen → Tutorial: renders (evidence: `src/App.tsx`)
- Game screen → Theme state: uses (evidence: `src/App.tsx`)
- Game screen → Tutorial state: uses (evidence: `src/App.tsx`)
- Bet panel → Bet editor: renders (evidence: `src/components/BetPanel.tsx`)
- Bet editor → Bet validation: validates with (evidence: `src/components/BetEditor.tsx`)
- Bet panel → Game state and flow: submits bets (evidence: `src/App.tsx`)
- Game state and flow → Bet validation: checks bets (evidence: `src/hooks/useHorseGame.ts`)
- Game state and flow → Runner data: loads (evidence: `src/hooks/useHorseGame.ts`)
- Game state and flow → Race results: determines finish (evidence: `src/hooks/useHorseGame.ts`)
- Game state and flow → Payout calculation: calculates returns (evidence: `src/hooks/useHorseGame.ts`)
- Game state and flow → Horse conditions: updates (evidence: `src/hooks/useHorseGame.ts`)
- Game state and flow → Browser storage: reads and writes (evidence: `src/hooks/useHorseGame.ts`)
- Runner data → Odds calculation: uses (evidence: `src/data/runners.ts`)
- Race results → Horse conditions: uses (evidence: `src/logic/determineRaceResults.ts`)
- Odds calculation → Horse conditions: applies (evidence: `src/logic/calculateOdds.ts`)
- Payout calculation → Odds calculation: gets multiplier (evidence: `src/logic/calculatePayout.ts`)
- Race display → Race animation: runs script (evidence: `src/components/ResultPanel.tsx`)
- Game state and flow → Race display: provides result (evidence: `src/App.tsx`)
- Game state and flow → Payout display: provides payout (evidence: `src/App.tsx`)
- Race history → Horse strength: summarizes horses (evidence: `src/components/HistoryModal.tsx`)
- Menu → Guide view: renders (evidence: `src/components/MenuModal.tsx`)
- Guide view → Game guide: displays (evidence: `src/components/GuideContent.tsx`)
- Tutorial → Game guide: displays (evidence: `src/components/Tutorial.tsx`)
- Header → Race history: opens (evidence: `src/App.tsx`)
- Header → Menu: opens (evidence: `src/App.tsx`)
- Player → Browser: uses
