# chimpirilin/desmoche architecture

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

- Interactive diagram: https://gitdiagram.com/chimpirilin/desmoche
- Repository: https://github.com/chimpirilin/desmoche

## Overview

This repository implements a browser-based card game with a React board and automated players. The principal workflow mounts the board, creates a game model, and starts a game state machine; turns are then dispatched through bot-turn logic, which draws, optionally melds, and discards while coordinating card animations. The model layer owns players, cards, deck and discard state, and meld piles. The README is only a TODO, so game rules beyond the sampled behavior and the purpose of the event/controller modules are unclear; those modules are omitted rather than assigned speculative roles.

Main entry points: [`src/finite_state_machines/botTurnFsm.ts`](https://github.com/chimpirilin/desmoche/blob/main/src/finite_state_machines/botTurnFsm.ts) (Bot turn machine), [`src/component/GameArea.tsx`](https://github.com/chimpirilin/desmoche/blob/main/src/component/GameArea.tsx) (Game board), [`src/models/Game.ts`](https://github.com/chimpirilin/desmoche/blob/main/src/models/Game.ts) (Game model), [`src/models/Card.ts`](https://github.com/chimpirilin/desmoche/blob/main/src/models/Card.ts) (Card type)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Game interface"]
  node_app["App shell<br/>[App.tsx]"]
  node_gamearea["Game board<br/>[GameArea.tsx]"]
  node_playercards["Player cards<br/>[PlayerCards.tsx]"]
  node_meldsui["Meld display<br/>[MeldsPile.tsx]"]
  node_pilesui["Deck and discard"]
end

subgraph group_flow["Turn orchestration"]
  node_gamefsm["Game machine<br/>[gameFsm.ts]"]
  node_botfsm["Bot turn machine<br/>[botTurnFsm.ts]"]
end

subgraph group_domain["Game domain"]
  node_game["Game model<br/>[Game.ts]"]
  node_bot["Bot strategy<br/>[BotPlayer.ts]"]
  node_playerlogic["Player state<br/>[Player.ts]"]
  node_deck[("Card deck<br/>[Deck.ts]")]
  node_discardpile[("Discard pile<br/>[DiscardPile.ts]")]
  node_meldpile[("Meld piles<br/>[MeldPile.ts]")]
  node_card["Card type<br/>[Card.ts]"]
end

subgraph group_visual["Card animations"]
  node_drawanim["Deck draw<br/>[draw_from_deck.ts]"]
  node_discardanim["Discard animation<br/>[discard.ts]"]
  node_discarddrawanim["Discard draw"]
  node_meldanim["Meld animation<br/>[meld.ts]"]
end

node_player(("Player"))

node_player -.->|"opens"| node_app
node_app -->|"renders"| node_gamearea
node_gamearea -->|"creates"| node_game
node_gamearea -->|"creates"| node_gamefsm
node_gamearea -->|"renders"| node_playercards
node_gamearea -->|"renders"| node_meldsui
node_gamearea -->|"renders"| node_pilesui
node_gamefsm -->|"starts turns"| node_botfsm
node_gamefsm -->|"uses game"| node_game
node_botfsm -->|"runs strategy"| node_bot
node_botfsm -->|"updates first play"| node_game
node_botfsm -->|"animates draw"| node_drawanim
node_botfsm -->|"animates discard"| node_discardanim
node_botfsm -->|"animates pickup"| node_discarddrawanim
node_botfsm -->|"animates meld"| node_meldanim
node_game -->|"creates"| node_deck
node_game -->|"creates"| node_discardpile
node_game -->|"creates players"| node_bot
node_bot -->|"extends"| node_playerlogic
node_bot -->|"manages melds"| node_meldpile
node_playerlogic -->|"draws from"| node_deck
node_playerlogic -->|"discards to"| node_discardpile
node_playerlogic -.->|"holds piles"| node_meldpile
node_deck -->|"stores"| node_card
node_discardpile -->|"stores"| node_card
node_meldpile -.->|"stores"| node_card
node_drawanim -->|"displays"| node_card
node_discardanim -->|"animates"| node_card
node_discarddrawanim -.->|"animates"| node_card
node_meldanim -.->|"targets display"| node_meldsui

click node_app "https://github.com/chimpirilin/desmoche/blob/main/src/App.tsx"
click node_gamearea "https://github.com/chimpirilin/desmoche/blob/main/src/component/GameArea.tsx"
click node_playercards "https://github.com/chimpirilin/desmoche/blob/main/src/component/PlayerCards.tsx"
click node_meldsui "https://github.com/chimpirilin/desmoche/blob/main/src/component/MeldsPile.tsx"
click node_pilesui "https://github.com/chimpirilin/desmoche/blob/main/src/component/DeckAndDiscardPile.tsx"
click node_gamefsm "https://github.com/chimpirilin/desmoche/blob/main/src/finite_state_machines/gameFsm.ts"
click node_botfsm "https://github.com/chimpirilin/desmoche/blob/main/src/finite_state_machines/botTurnFsm.ts"
click node_game "https://github.com/chimpirilin/desmoche/blob/main/src/models/Game.ts"
click node_bot "https://github.com/chimpirilin/desmoche/blob/main/src/models/BotPlayer.ts"
click node_playerlogic "https://github.com/chimpirilin/desmoche/blob/main/src/models/Player.ts"
click node_deck "https://github.com/chimpirilin/desmoche/blob/main/src/models/Deck.ts"
click node_discardpile "https://github.com/chimpirilin/desmoche/blob/main/src/models/DiscardPile.ts"
click node_meldpile "https://github.com/chimpirilin/desmoche/blob/main/src/models/MeldPile.ts"
click node_card "https://github.com/chimpirilin/desmoche/blob/main/src/models/Card.ts"
click node_drawanim "https://github.com/chimpirilin/desmoche/blob/main/src/animations/draw_from_deck.ts"
click node_discardanim "https://github.com/chimpirilin/desmoche/blob/main/src/animations/discard.ts"
click node_discarddrawanim "https://github.com/chimpirilin/desmoche/blob/main/src/animations/draw_from_discard_pile.ts"
click node_meldanim "https://github.com/chimpirilin/desmoche/blob/main/src/animations/meld.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_gamearea,node_playercards,node_meldsui,node_pilesui toneBlue
class node_gamefsm,node_botfsm toneAmber
class node_game,node_bot,node_playerlogic,node_deck,node_discardpile,node_meldpile,node_card toneMint
class node_drawanim,node_discardanim,node_discarddrawanim,node_meldanim toneRose
class node_player toneIndigo
```

## Components

### Game interface

- [App shell](https://github.com/chimpirilin/desmoche/blob/main/src/App.tsx): `src/App.tsx`
- [Game board](https://github.com/chimpirilin/desmoche/blob/main/src/component/GameArea.tsx): `src/component/GameArea.tsx`
- [Player cards](https://github.com/chimpirilin/desmoche/blob/main/src/component/PlayerCards.tsx): `src/component/PlayerCards.tsx`
- [Meld display](https://github.com/chimpirilin/desmoche/blob/main/src/component/MeldsPile.tsx): `src/component/MeldsPile.tsx`
- [Deck and discard](https://github.com/chimpirilin/desmoche/blob/main/src/component/DeckAndDiscardPile.tsx): `src/component/DeckAndDiscardPile.tsx`

### Turn orchestration

- [Game machine](https://github.com/chimpirilin/desmoche/blob/main/src/finite_state_machines/gameFsm.ts): `src/finite_state_machines/gameFsm.ts`
- [Bot turn machine](https://github.com/chimpirilin/desmoche/blob/main/src/finite_state_machines/botTurnFsm.ts): `src/finite_state_machines/botTurnFsm.ts`

### Game domain

- [Game model](https://github.com/chimpirilin/desmoche/blob/main/src/models/Game.ts): `src/models/Game.ts`
- [Bot strategy](https://github.com/chimpirilin/desmoche/blob/main/src/models/BotPlayer.ts): `src/models/BotPlayer.ts`
- [Player state](https://github.com/chimpirilin/desmoche/blob/main/src/models/Player.ts): `src/models/Player.ts`
- [Card deck](https://github.com/chimpirilin/desmoche/blob/main/src/models/Deck.ts): `src/models/Deck.ts`
- [Discard pile](https://github.com/chimpirilin/desmoche/blob/main/src/models/DiscardPile.ts): `src/models/DiscardPile.ts`
- [Meld piles](https://github.com/chimpirilin/desmoche/blob/main/src/models/MeldPile.ts): `src/models/MeldPile.ts`
- [Card type](https://github.com/chimpirilin/desmoche/blob/main/src/models/Card.ts): `src/models/Card.ts`

### Card animations

- [Deck draw](https://github.com/chimpirilin/desmoche/blob/main/src/animations/draw_from_deck.ts): `src/animations/draw_from_deck.ts`
- [Discard animation](https://github.com/chimpirilin/desmoche/blob/main/src/animations/discard.ts): `src/animations/discard.ts`
- [Discard draw](https://github.com/chimpirilin/desmoche/blob/main/src/animations/draw_from_discard_pile.ts): `src/animations/draw_from_discard_pile.ts`
- [Meld animation](https://github.com/chimpirilin/desmoche/blob/main/src/animations/meld.ts): `src/animations/meld.ts`

### Other components

- **Player**

## Connections

- Player → App shell: opens
- App shell → Game board: renders (evidence: `src/App.tsx`)
- Game board → Game model: creates (evidence: `src/component/GameArea.tsx`)
- Game board → Game machine: creates (evidence: `src/component/GameArea.tsx`)
- Game board → Player cards: renders (evidence: `src/component/GameArea.tsx`)
- Game board → Meld display: renders (evidence: `src/component/GameArea.tsx`)
- Game board → Deck and discard: renders (evidence: `src/component/GameArea.tsx`)
- Game machine → Bot turn machine: starts turns (evidence: `src/finite_state_machines/gameFsm.ts`)
- Game machine → Game model: uses game (evidence: `src/finite_state_machines/gameFsm.ts`)
- Bot turn machine → Bot strategy: runs strategy (evidence: `src/finite_state_machines/botTurnFsm.ts`)
- Bot turn machine → Game model: updates first play (evidence: `src/finite_state_machines/botTurnFsm.ts`)
- Bot turn machine → Deck draw: animates draw (evidence: `src/finite_state_machines/botTurnFsm.ts`)
- Bot turn machine → Discard animation: animates discard (evidence: `src/finite_state_machines/botTurnFsm.ts`)
- Bot turn machine → Discard draw: animates pickup (evidence: `src/finite_state_machines/botTurnFsm.ts`)
- Bot turn machine → Meld animation: animates meld (evidence: `src/finite_state_machines/botTurnFsm.ts`)
- Game model → Card deck: creates (evidence: `src/models/Game.ts`)
- Game model → Discard pile: creates (evidence: `src/models/Game.ts`)
- Game model → Bot strategy: creates players (evidence: `src/models/Game.ts`)
- Bot strategy → Player state: extends (evidence: `src/models/BotPlayer.ts`)
- Bot strategy → Meld piles: manages melds (evidence: `src/models/BotPlayer.ts`)
- Player state → Card deck: draws from (evidence: `src/models/Player.ts`)
- Player state → Discard pile: discards to (evidence: `src/models/Player.ts`)
- Player state → Meld piles: holds piles (evidence: `src/models/Player.ts`)
- Card deck → Card type: stores (evidence: `src/models/Deck.ts`)
- Discard pile → Card type: stores (evidence: `src/models/DiscardPile.ts`)
- Meld piles → Card type: stores (evidence: `src/models/MeldPile.ts`)
- Deck draw → Card type: displays (evidence: `src/animations/draw_from_deck.ts`)
- Discard animation → Card type: animates (evidence: `src/animations/discard.ts`)
- Discard draw → Card type: animates
- Meld animation → Meld display: targets display
