# ashwath-0007/esp32-snake-game architecture

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

- Interactive diagram: https://gitdiagram.com/ashwath-0007/esp32-snake-game
- Repository: https://github.com/ashwath-0007/esp32-snake-game

## Overview

This is an ESP32 handheld Snake game. The documented user flow is button input through a menu/play/game-over state machine, with gameplay shown on an OLED and controls available to retry or return to the menu. Supporting capabilities include debounced input, a non-blocking millis()-based loop, score-driven difficulty, buzzer feedback, and persistent high scores. Only the README is available, so implementation paths and source-level call relationships cannot be verified; links below reflect documented behavior.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_controls["Controls"]
  node_input["Debounced Input"]
end

subgraph group_runtime["Game Runtime"]
  node_loop["Game Loop"]
  node_states["Menu / Play / Over"]
  node_snake["Snake Gameplay"]
  node_difficulty["Score Difficulty"]
  node_highscore["High Score Logic"]
end

subgraph group_devices["Display, Sound &amp; Storage"]
  node_render["Screen Output"]
  node_sound["Sound Feedback"]
  node_persistence["Flash Persistence"]
end

node_player(("Player"))
node_buttons["Physical Buttons"]
node_oled["SSD1306 OLED"]
node_buzzer["Buzzer"]
node_nvs[("Preferences / NVS")]

node_player -->|"presses"| node_buttons
node_buttons -->|"provides input"| node_input
node_input -->|"controls"| node_states
node_loop -->|"runs"| node_states
node_states -->|"enters play"| node_snake
node_states -->|"shows screens"| node_render
node_snake -->|"score increases"| node_difficulty
node_snake -->|"triggers cues"| node_sound
node_highscore -->|"signals records"| node_sound
node_highscore -->|"saves new records"| node_persistence
node_render -->|"renders on"| node_oled
node_sound -->|"plays on"| node_buzzer
node_persistence -->|"stores in"| node_nvs

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_input toneBlue
class node_loop,node_states,node_snake,node_difficulty,node_highscore,node_nvs toneAmber
class node_render,node_sound,node_persistence toneMint
class node_player,node_buttons,node_oled,node_buzzer toneIndigo
```

## Components

### Controls

- **Debounced Input**

### Game Runtime

- **Game Loop**
- **Menu / Play / Over**
- **Snake Gameplay**
- **Score Difficulty**
- **High Score Logic**

### Display, Sound & Storage

- **Screen Output**
- **Sound Feedback**
- **Flash Persistence**

### Other components

- **Player**
- **Physical Buttons**
- **SSD1306 OLED**
- **Buzzer**
- **Preferences / NVS**

## Connections

- Player → Physical Buttons: presses (evidence: `README.md`)
- Physical Buttons → Debounced Input: provides input (evidence: `README.md`)
- Debounced Input → Menu / Play / Over: controls (evidence: `README.md`)
- Game Loop → Menu / Play / Over: runs (evidence: `README.md`)
- Menu / Play / Over → Snake Gameplay: enters play (evidence: `README.md`)
- Menu / Play / Over → Screen Output: shows screens (evidence: `README.md`)
- Snake Gameplay → Score Difficulty: score increases (evidence: `README.md`)
- Snake Gameplay → Sound Feedback: triggers cues (evidence: `README.md`)
- High Score Logic → Sound Feedback: signals records (evidence: `README.md`)
- High Score Logic → Flash Persistence: saves new records (evidence: `README.md`)
- Screen Output → SSD1306 OLED: renders on (evidence: `README.md`)
- Sound Feedback → Buzzer: plays on (evidence: `README.md`)
- Flash Persistence → Preferences / NVS: stores in (evidence: `README.md`)
