# beelzebubcode/snake-game architecture

> Architecture diagram of the GitHub repository beelzebubcode/snake-game, 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/beelzebubcode/snake-game
- Repository: https://github.com/beelzebubcode/snake-game

## Overview

LexiSnake is a browser word game: the player starts or resumes a run, steers a snake to collect letters and chests, then enters a portal to form an English word and see its Thai meaning. The React app coordinates the game engine, Phaser board, tutorial, settings, and journal; the engine applies game rules and consults vocabulary data. Browser storage retains settings and learning progress. Major documented features include bilingual UI, multiple maps and skins, audio, touch and keyboard controls, and a seven-step tutorial. Some wiring is supported only by the source index or README, so uncertain links are omitted.

Main entry points: [`Web/src/App.tsx`](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/App.tsx) (App coordinator), [`Web/src/i18n/messages.ts`](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/i18n/messages.ts) (Translation lookup), [`Web/src/game/engine.ts`](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/game/engine.ts) (Game rules engine), [`Web/src/components/JournalBook.tsx`](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/components/JournalBook.tsx) (Word journal)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Game experience"]
  node_app["App coordinator<br/>[App.tsx]"]
  node_settings["Settings panel<br/>[SettingsPanel.tsx]"]
  node_journal["Word journal<br/>[JournalBook.tsx]"]
  node_tutorial["Tutorial lessons<br/>[TutorialLesson.tsx]"]
  node_tutorial_review["Tutorial review<br/>[TutorialReview.tsx]"]
  node_modal["Modal UI<br/>[Modal.tsx]"]
  node_art["Game artwork<br/>[Art.tsx]"]
end

subgraph group_runtime["Game runtime"]
  node_engine["Game rules engine<br/>[engine.ts]"]
  node_board["Phaser board<br/>[PhaserBoard.tsx]"]
  node_appearance["Maps and skins<br/>[appearance.ts]"]
  node_input["Control mapping<br/>[input.ts]"]
  node_game_types["Game state types<br/>[types.ts]"]
  node_tutorial_flow["Tutorial flow<br/>[tutorial.ts]"]
end

subgraph group_learning["Word learning"]
  node_vocabulary["Vocabulary lookup<br/>[vocabulary.ts]"]
  node_dictionary["Vocabulary data<br/>[vocabulary.json]"]
end

subgraph group_language["Localization"]
  node_i18n_provider["Language provider<br/>[index.tsx]"]
  node_messages["Translation lookup<br/>[messages.ts]"]
  node_english["English catalog<br/>[en.ts]"]
  node_thai["Thai catalog<br/>[th.ts]"]
end

subgraph group_services["Browser services"]
  node_storage[("Save storage<br/>[storage.ts]")]
  node_audio["Audio service<br/>[audio.ts]"]
end

node_player(("Player"))
node_browser(("Browser"))

node_player -->|"starts play"| node_app
node_app -->|"coordinates"| node_engine
node_app -->|"renders"| node_board
node_app -->|"opens"| node_settings
node_app -->|"opens"| node_journal
node_app -->|"shows"| node_tutorial
node_app -->|"shows"| node_tutorial_review
node_app -->|"renders"| node_modal
node_app -->|"renders"| node_art
node_app -->|"handles controls"| node_input
node_app -->|"provides language"| node_i18n_provider
node_app -->|"loads and saves"| node_storage
node_app -->|"controls audio"| node_audio
node_app -->|"loads dictionary"| node_vocabulary
node_engine -->|"checks words"| node_vocabulary
node_engine -->|"translates prompts"| node_messages
node_board -->|"reads game state"| node_engine
node_board -->|"draws appearance"| node_appearance
node_settings -->|"uses map options"| node_appearance
node_tutorial -->|"renders lessons"| node_tutorial_flow
node_tutorial -->|"uses modal"| node_modal
node_journal -->|"reads saved words"| node_storage
node_journal -->|"plays sounds"| node_audio
node_vocabulary -->|"fetches data"| node_dictionary
node_storage -->|"uses local storage"| node_browser
node_i18n_provider -->|"creates translator"| node_messages
node_messages -->|"reads catalog"| node_english
node_messages -->|"reads catalog"| node_thai
node_game_types -->|"types message keys"| node_messages

click node_app "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/App.tsx"
click node_settings "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/components/SettingsPanel.tsx"
click node_journal "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/components/JournalBook.tsx"
click node_tutorial "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/components/TutorialLesson.tsx"
click node_tutorial_review "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/components/TutorialReview.tsx"
click node_modal "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/components/Modal.tsx"
click node_art "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/components/Art.tsx"
click node_engine "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/game/engine.ts"
click node_board "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/game/PhaserBoard.tsx"
click node_appearance "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/game/appearance.ts"
click node_input "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/game/input.ts"
click node_game_types "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/game/types.ts"
click node_tutorial_flow "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/game/tutorial.ts"
click node_vocabulary "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/data/vocabulary.ts"
click node_dictionary "https://github.com/beelzebubcode/snake-game/blob/main/Web/public/data/vocabulary.json"
click node_i18n_provider "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/i18n/index.tsx"
click node_messages "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/i18n/messages.ts"
click node_english "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/i18n/en.ts"
click node_thai "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/i18n/th.ts"
click node_storage "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/services/storage.ts"
click node_audio "https://github.com/beelzebubcode/snake-game/blob/main/Web/src/services/audio.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_settings,node_journal,node_tutorial,node_tutorial_review,node_modal,node_art,node_browser toneBlue
class node_engine,node_board,node_appearance,node_input,node_game_types,node_tutorial_flow toneAmber
class node_vocabulary,node_dictionary toneMint
class node_i18n_provider,node_messages,node_english,node_thai toneRose
class node_storage,node_audio,node_player toneIndigo
```

## Components

### Game experience

- [App coordinator](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/App.tsx): `Web/src/App.tsx`
- [Settings panel](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/components/SettingsPanel.tsx): `Web/src/components/SettingsPanel.tsx`
- [Word journal](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/components/JournalBook.tsx): `Web/src/components/JournalBook.tsx`
- [Tutorial lessons](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/components/TutorialLesson.tsx): `Web/src/components/TutorialLesson.tsx`
- [Tutorial review](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/components/TutorialReview.tsx): `Web/src/components/TutorialReview.tsx`
- [Modal UI](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/components/Modal.tsx): `Web/src/components/Modal.tsx`
- [Game artwork](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/components/Art.tsx): `Web/src/components/Art.tsx`

### Game runtime

- [Game rules engine](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/game/engine.ts): `Web/src/game/engine.ts`
- [Phaser board](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/game/PhaserBoard.tsx): `Web/src/game/PhaserBoard.tsx`
- [Maps and skins](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/game/appearance.ts): `Web/src/game/appearance.ts`
- [Control mapping](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/game/input.ts): `Web/src/game/input.ts`
- [Game state types](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/game/types.ts): `Web/src/game/types.ts`
- [Tutorial flow](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/game/tutorial.ts): `Web/src/game/tutorial.ts`

### Word learning

- [Vocabulary lookup](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/data/vocabulary.ts): `Web/src/data/vocabulary.ts`
- [Vocabulary data](https://github.com/beelzebubcode/snake-game/blob/main/Web/public/data/vocabulary.json): `Web/public/data/vocabulary.json`

### Localization

- [Language provider](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/i18n/index.tsx): `Web/src/i18n/index.tsx`
- [Translation lookup](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/i18n/messages.ts): `Web/src/i18n/messages.ts`
- [English catalog](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/i18n/en.ts): `Web/src/i18n/en.ts`
- [Thai catalog](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/i18n/th.ts): `Web/src/i18n/th.ts`

### Browser services

- [Save storage](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/services/storage.ts): `Web/src/services/storage.ts`
- [Audio service](https://github.com/beelzebubcode/snake-game/blob/main/Web/src/services/audio.ts): `Web/src/services/audio.ts`

### Other components

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

## Connections

- Player → App coordinator: starts play (evidence: `README.md`)
- App coordinator → Game rules engine: coordinates (evidence: `Web/src/App.tsx`)
- App coordinator → Phaser board: renders (evidence: `Web/src/App.tsx`)
- App coordinator → Settings panel: opens (evidence: `Web/src/App.tsx`)
- App coordinator → Word journal: opens (evidence: `Web/src/App.tsx`)
- App coordinator → Tutorial lessons: shows (evidence: `Web/src/App.tsx`)
- App coordinator → Tutorial review: shows (evidence: `Web/src/App.tsx`)
- App coordinator → Modal UI: renders (evidence: `Web/src/App.tsx`)
- App coordinator → Game artwork: renders (evidence: `Web/src/App.tsx`)
- App coordinator → Control mapping: handles controls (evidence: `Web/src/App.tsx`)
- App coordinator → Language provider: provides language (evidence: `Web/src/App.tsx`)
- App coordinator → Save storage: loads and saves (evidence: `Web/src/App.tsx`)
- App coordinator → Audio service: controls audio (evidence: `Web/src/App.tsx`)
- App coordinator → Vocabulary lookup: loads dictionary (evidence: `Web/src/App.tsx`)
- Game rules engine → Vocabulary lookup: checks words (evidence: `Web/src/game/engine.ts`)
- Game rules engine → Translation lookup: translates prompts (evidence: `Web/src/game/engine.ts`)
- Phaser board → Game rules engine: reads game state (evidence: `Web/src/game/PhaserBoard.tsx`)
- Phaser board → Maps and skins: draws appearance (evidence: `Web/src/game/PhaserBoard.tsx`)
- Settings panel → Maps and skins: uses map options (evidence: `Web/src/components/SettingsPanel.tsx`)
- Tutorial lessons → Tutorial flow: renders lessons (evidence: `Web/src/components/TutorialLesson.tsx`)
- Tutorial lessons → Modal UI: uses modal (evidence: `Web/src/components/TutorialLesson.tsx`)
- Word journal → Save storage: reads saved words (evidence: `Web/src/components/JournalBook.tsx`)
- Word journal → Audio service: plays sounds (evidence: `Web/src/components/JournalBook.tsx`)
- Vocabulary lookup → Vocabulary data: fetches data (evidence: `Web/src/data/vocabulary.ts`)
- Save storage → Browser: uses local storage (evidence: `Web/src/services/storage.ts`)
- Language provider → Translation lookup: creates translator (evidence: `Web/src/i18n/index.tsx`)
- Translation lookup → English catalog: reads catalog (evidence: `Web/src/i18n/messages.ts`)
- Translation lookup → Thai catalog: reads catalog (evidence: `Web/src/i18n/messages.ts`)
- Game state types → Translation lookup: types message keys (evidence: `Web/src/game/types.ts`)
