# eugeny11/tetris-game architecture

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

- Interactive diagram: https://gitdiagram.com/eugeny11/tetris-game
- Repository: https://github.com/eugeny11/tetris-game

## Overview

This is a browser-based Tetris game. The player’s keyboard or touch input enters the controller, which invokes game rules and redraws the board; timed drops continue until game over. The engine handles piece movement, collisions, ghost position, row clearing, and spawning, while shared utilities provide piece data and grid helpers. The README also documents responsive styling and Hammer.js touch gestures. Source excerpts show controller-to-engine and rendering behavior; the HTML/CSS presentation details are represented by their repository paths, not inspected implementation.

Main entry points: [`script.js`](https://github.com/eugeny11/tetris-game/blob/main/script.js) (Game controller), [`tetris.js`](https://github.com/eugeny11/tetris-game/blob/main/tetris.js) (Game engine), [`utilities.js`](https://github.com/eugeny11/tetris-game/blob/main/utilities.js) (Pieces and helpers), [`index.html`](https://github.com/eugeny11/tetris-game/blob/main/index.html) (Game board)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Input and display"]
  node_controller["Game controller<br/>[script.js]"]
  node_board["Game board<br/>[index.html]"]
  node_styling["Responsive styling<br/>[style.css]"]
end

subgraph group_game["Tetris rules"]
  node_engine["Game engine<br/>[tetris.js]"]
end

subgraph group_shared["Game data and helpers"]
  node_rules["Pieces and helpers<br/>[utilities.js]"]
end

node_player(("Player"))
node_hammer["Hammer.js gestures"]

node_player -->|"controls"| node_controller
node_controller -->|"calls game rules"| node_engine
node_engine -->|"uses piece data"| node_rules
node_controller -->|"uses grid helpers"| node_rules
node_controller -->|"draws cells"| node_board
node_controller -->|"registers gestures"| node_hammer

click node_controller "https://github.com/eugeny11/tetris-game/blob/main/script.js"
click node_board "https://github.com/eugeny11/tetris-game/blob/main/index.html"
click node_styling "https://github.com/eugeny11/tetris-game/blob/main/style.css"
click node_engine "https://github.com/eugeny11/tetris-game/blob/main/tetris.js"
click node_rules "https://github.com/eugeny11/tetris-game/blob/main/utilities.js"

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_controller,node_board,node_styling toneBlue
class node_engine toneAmber
class node_rules toneMint
class node_player,node_hammer toneIndigo
```

## Components

### Input and display

- [Game controller](https://github.com/eugeny11/tetris-game/blob/main/script.js): `script.js`
- [Game board](https://github.com/eugeny11/tetris-game/blob/main/index.html): `index.html`
- [Responsive styling](https://github.com/eugeny11/tetris-game/blob/main/style.css): `style.css`

### Tetris rules

- [Game engine](https://github.com/eugeny11/tetris-game/blob/main/tetris.js): `tetris.js`

### Game data and helpers

- [Pieces and helpers](https://github.com/eugeny11/tetris-game/blob/main/utilities.js): `utilities.js`

### Other components

- **Player**
- **Hammer.js gestures**

## Connections

- Player → Game controller: controls (evidence: `README.md`)
- Game controller → Game engine: calls game rules (evidence: `script.js`)
- Game engine → Pieces and helpers: uses piece data (evidence: `tetris.js`)
- Game controller → Pieces and helpers: uses grid helpers (evidence: `script.js`)
- Game controller → Game board: draws cells (evidence: `script.js`)
- Game controller → Hammer.js gestures: registers gestures (evidence: `script.js`)
