# m-mueller/minesweeper architecture

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

- Interactive diagram: https://gitdiagram.com/m-mueller/minesweeper
- Repository: https://github.com/m-mueller/minesweeper

## Overview

This is a terminal Minesweeper game: a player chooses a game and difficulty, navigates the board, marks or reveals cells, and sees a win/loss result. The curses controller creates and updates the game; rendering presents its state. Internally, the game rules operate on a 2D table that stores mines, flags, and hints. The README documents the curses launch; the sampled source shows the controller, game, and table interactions.

Main entry points: [`minesweeper_curses.py`](https://github.com/m-mueller/minesweeper/blob/master/minesweeper_curses.py) (Game controller), [`minesweeper.py`](https://github.com/m-mueller/minesweeper/blob/master/minesweeper.py) (Random board setup), [`table.py`](https://github.com/m-mueller/minesweeper/blob/master/table.py) (2D table)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Terminal interface"]
  node_controller["Game controller"]
  node_menus["Game menus"]
  node_renderer["Screen renderer"]
end

subgraph group_game["Game logic"]
  node_factory["Random board setup<br/>[minesweeper.py]"]
  node_rules["Game rules<br/>[minesweeper.py]"]
end

subgraph group_board["Board data"]
  node_table["2D table<br/>[table.py]"]
end

node_player(("Player"))

node_player -->|"plays through"| node_controller
node_controller -->|"opens menus"| node_menus
node_controller -->|"creates game"| node_factory
node_controller -->|"updates game"| node_rules
node_controller -->|"draws screen"| node_renderer
node_factory -->|"initializes tables"| node_table
node_rules -->|"reads and updates"| node_table

click node_controller "https://github.com/m-mueller/minesweeper/blob/master/minesweeper_curses.py"
click node_menus "https://github.com/m-mueller/minesweeper/blob/master/minesweeper_curses.py"
click node_renderer "https://github.com/m-mueller/minesweeper/blob/master/minesweeper_curses.py"
click node_factory "https://github.com/m-mueller/minesweeper/blob/master/minesweeper.py"
click node_rules "https://github.com/m-mueller/minesweeper/blob/master/minesweeper.py"
click node_table "https://github.com/m-mueller/minesweeper/blob/master/table.py"

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_menus,node_renderer toneBlue
class node_factory,node_rules toneAmber
class node_table toneMint
class node_player toneIndigo
```

## Components

### Terminal interface

- [Game controller](https://github.com/m-mueller/minesweeper/blob/master/minesweeper_curses.py): `minesweeper_curses.py`
- [Game menus](https://github.com/m-mueller/minesweeper/blob/master/minesweeper_curses.py): `minesweeper_curses.py`
- [Screen renderer](https://github.com/m-mueller/minesweeper/blob/master/minesweeper_curses.py): `minesweeper_curses.py`

### Game logic

- [Random board setup](https://github.com/m-mueller/minesweeper/blob/master/minesweeper.py): `minesweeper.py`
- [Game rules](https://github.com/m-mueller/minesweeper/blob/master/minesweeper.py): `minesweeper.py`

### Board data

- [2D table](https://github.com/m-mueller/minesweeper/blob/master/table.py): `table.py`

### Other components

- **Player**

## Connections

- Player → Game controller: plays through (evidence: `README.md`)
- Game controller → Game menus: opens menus (evidence: `minesweeper_curses.py`)
- Game controller → Random board setup: creates game (evidence: `minesweeper_curses.py`)
- Game controller → Game rules: updates game (evidence: `minesweeper_curses.py`)
- Game controller → Screen renderer: draws screen (evidence: `minesweeper_curses.py`)
- Random board setup → 2D table: initializes tables (evidence: `minesweeper.py`)
- Game rules → 2D table: reads and updates (evidence: `minesweeper.py`)
