# brecht6/tetris-tui architecture

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

- Interactive diagram: https://gitdiagram.com/brecht6/tetris-tui
- Repository: https://github.com/brecht6/tetris-tui

## Overview

Tetris-TUI is a terminal-playable Tetris game. The user launches it and controls pieces; the Bubble Tea model handles input and timed ticks, applies game rules, and renders the board and score. Game state and piece data are defined separately from piece movement, collision, locking, and line clearing. The excerpts show these calls directly; framework-driven dispatch is not represented as a verified edge.

Main entry points: [`main.go`](https://github.com/brecht6/tetris-tui/blob/main/main.go) (Game Loop), [`blocks.go`](https://github.com/brecht6/tetris-tui/blob/main/blocks.go) (Collision Checks), [`types.go`](https://github.com/brecht6/tetris-tui/blob/main/types.go) (Game State)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Terminal Interaction"]
  node_game["Game Loop<br/>[main.go]"]
  node_display["Board Display<br/>[main.go]"]
end

subgraph group_gameplay["Game State"]
  node_state["Game State<br/>[types.go]"]
end

subgraph group_rules["Piece Rules"]
  node_piece_motion["Piece Motion<br/>[blocks.go]"]
  node_collision["Collision Checks<br/>[blocks.go]"]
  node_board_updates["Lock and Clear<br/>[blocks.go]"]
end

node_player(("Player"))

node_player -->|"launches and controls"| node_game
node_game -->|"initializes and updates"| node_state
node_game -->|"moves and rotates"| node_piece_motion
node_game -->|"checks landing and game over"| node_collision
node_game -->|"locks pieces and scores"| node_board_updates
node_display -->|"composes current piece"| node_board_updates
node_piece_motion -->|"checks legal positions"| node_collision
node_collision -->|"reads occupied cells"| node_board_updates

click node_game "https://github.com/brecht6/tetris-tui/blob/main/main.go"
click node_display "https://github.com/brecht6/tetris-tui/blob/main/main.go"
click node_state "https://github.com/brecht6/tetris-tui/blob/main/types.go"
click node_piece_motion "https://github.com/brecht6/tetris-tui/blob/main/blocks.go"
click node_collision "https://github.com/brecht6/tetris-tui/blob/main/blocks.go"
click node_board_updates "https://github.com/brecht6/tetris-tui/blob/main/blocks.go"

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_game,node_display toneBlue
class node_state toneAmber
class node_piece_motion,node_collision,node_board_updates toneMint
class node_player toneIndigo
```

## Components

### Terminal Interaction

- [Game Loop](https://github.com/brecht6/tetris-tui/blob/main/main.go): `main.go`
- [Board Display](https://github.com/brecht6/tetris-tui/blob/main/main.go): `main.go`

### Game State

- [Game State](https://github.com/brecht6/tetris-tui/blob/main/types.go): `types.go`

### Piece Rules

- [Piece Motion](https://github.com/brecht6/tetris-tui/blob/main/blocks.go): `blocks.go`
- [Collision Checks](https://github.com/brecht6/tetris-tui/blob/main/blocks.go): `blocks.go`
- [Lock and Clear](https://github.com/brecht6/tetris-tui/blob/main/blocks.go): `blocks.go`

### Other components

- **Player**

## Connections

- Player → Game Loop: launches and controls (evidence: `README.md`)
- Game Loop → Game State: initializes and updates (evidence: `main.go`)
- Game Loop → Piece Motion: moves and rotates (evidence: `main.go`)
- Game Loop → Collision Checks: checks landing and game over (evidence: `main.go`)
- Game Loop → Lock and Clear: locks pieces and scores (evidence: `main.go`)
- Board Display → Lock and Clear: composes current piece (evidence: `main.go`)
- Piece Motion → Collision Checks: checks legal positions (evidence: `blocks.go`)
- Collision Checks → Lock and Clear: reads occupied cells (evidence: `blocks.go`)
