# michaelkolesidis/hangman architecture

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

- Interactive diagram: https://gitdiagram.com/michaelkolesidis/hangman
- Repository: https://github.com/michaelkolesidis/hangman

## Overview

1. **Project shape**
   - This is a **single-process Java terminal game** with no web UI, server, database, or network dependencies.
   - The architecture is intentionally small and object-oriented: each `.java` file appears to own one responsibility.

2. **Entry point and game coordinator**
   - `Hangman.java` is likely the application entry point.
   - `Game.java` is the central orchestrator: it probably owns the main loop, game state, win/lose checks, and coordination between input, word selection, and output.

3. **Console presentation layer**
   - `Printer.java` is the output boundary to the terminal.
   - It likely renders the current hangman figure, masked word, guessed letters, prompts, and end-of-round messages.
   - This is the only visible UI layer in the repo.

4. **User input boundary**
   - `Input.java` appears to be a base abstraction for reading user input from the terminal.
   - `LetterInput.java` and `PlayAgain.java` likely specialize that boundary for two distinct interactions:
     - guessing a letter during play
     - deciding whether to restart after a round ends

5. **Parsing and validation**
   - `Parser.java` and `WordParser.java` suggest a parsing layer that converts raw text into validated game inputs or normalized words.
   - This layer likely keeps malformed console input from reaching the core game logic.

6. **Word source and selection**
   - `wordlist.txt` is the only external data file and acts as the game's vocabulary source.
   - `Picker.java`, `WordPicker.java`, and `WordParser.java` likely form the word-selection path:
     - load or parse candidate words from the text file
     - pick one secret word for the current round

7. **Core in-memory state**
   - The game state is probably held entirely in memory inside `Game.java` and related objects.
   - Typical state here would be the secret word, guessed letters, remaining attempts, and round status.
   - There is no evidence of persistence beyond the static word list.

8. **Primary data flow**
   - Startup: `Hangman` creates/starts `Game`.
   - Initialization: a word is sourced from `wordlist.txt` through the picker/parser classes.
   - Loop: the player enters guesses via input classes; parsers validate them; game state updates.
   - Feedback: `Printer` renders the updated state after each guess.
   - Termination: the game ends on win/lose, then `PlayAgain` may trigger a new round.

9. **Subsystem boundaries**
   - **UI boundary:** `Printer`
   - **Input boundary:** `Input`, `LetterInput`, `PlayAgain`
   - **Data boundary:** `wordlist.txt`
   - **Game orchestration:** `Game`, `Hangman`
   - **Selection/parsing utilities:** `Parser`, `WordParser`, `Picker`, `WordPicker`

10. **Deployment/runtime characteristics**
   - The only required runtime is the **Java JVM**.
   - The app is likely run directly from the command line and depends on relative access to `wordlist.txt`.

11. **Diagram takeaway**
   - If you draw this architecture, it should look like a **thin CLI shell around a core game loop**, with terminal input/output at the edges and a local text file as the only external data source.

Main entry points: [`Game.java`](https://github.com/michaelkolesidis/hangman/blob/main/Game.java) (Game), [`WordPicker.java`](https://github.com/michaelkolesidis/hangman/blob/main/WordPicker.java) (WordPicker), [`LetterInput.java`](https://github.com/michaelkolesidis/hangman/blob/main/LetterInput.java) (LetterInput), [`PlayAgain.java`](https://github.com/michaelkolesidis/hangman/blob/main/PlayAgain.java) (PlayAgain)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["CLI Runtime"]
  node_hangman(("Hangman<br/>entrypoint<br/>[Hangman.java]"))
  node_game["Game<br/>orchestrator<br/>[Game.java]"]
  node_printer["Printer<br/>terminal output<br/>[Printer.java]"]
  node_input["Input<br/>[Input.java]"]
  node_letter["LetterInput<br/>letter input<br/>[LetterInput.java]"]
  node_again["PlayAgain<br/>replay input<br/>[PlayAgain.java]"]
end

subgraph group_words["Word Pipeline"]
  node_parser["Parser<br/>parse/validate<br/>[Parser.java]"]
  node_wordparser["WordParser<br/>word parsing<br/>[WordParser.java]"]
  node_picker["Picker<br/>selection base<br/>[Picker.java]"]
  node_wordpicker["WordPicker<br/>word selection<br/>[WordPicker.java]"]
  node_wordlist["wordlist.txt<br/>word source<br/>[wordlist.txt]"]
end

node_hangman -->|"launches"| node_game
node_game -->|"renders"| node_printer
node_game -->|"requests guess"| node_letter
node_game -->|"requests replay"| node_again
node_game -->|"gets word"| node_wordpicker
node_letter -->|"extends"| node_input
node_again -->|"extends"| node_input
node_letter -->|"validates"| node_parser
node_again -->|"parses"| node_parser
node_wordpicker -->|"uses"| node_picker
node_wordpicker -->|"normalizes"| node_wordparser
node_wordpicker -->|"reads"| node_wordlist
node_wordparser -->|"builds on"| node_parser

click node_hangman "https://github.com/michaelkolesidis/hangman/blob/main/Hangman.java"
click node_game "https://github.com/michaelkolesidis/hangman/blob/main/Game.java"
click node_printer "https://github.com/michaelkolesidis/hangman/blob/main/Printer.java"
click node_input "https://github.com/michaelkolesidis/hangman/blob/main/Input.java"
click node_letter "https://github.com/michaelkolesidis/hangman/blob/main/LetterInput.java"
click node_again "https://github.com/michaelkolesidis/hangman/blob/main/PlayAgain.java"
click node_parser "https://github.com/michaelkolesidis/hangman/blob/main/Parser.java"
click node_wordparser "https://github.com/michaelkolesidis/hangman/blob/main/WordParser.java"
click node_picker "https://github.com/michaelkolesidis/hangman/blob/main/Picker.java"
click node_wordpicker "https://github.com/michaelkolesidis/hangman/blob/main/WordPicker.java"
click node_wordlist "https://github.com/michaelkolesidis/hangman/blob/main/wordlist.txt"

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_hangman,node_game,node_printer,node_input,node_letter,node_again toneBlue
class node_parser,node_wordparser,node_picker,node_wordpicker,node_wordlist toneAmber
```

## Components

### CLI Runtime

Entry point, game loop, terminal I/O

- [Hangman](https://github.com/michaelkolesidis/hangman/blob/main/Hangman.java): entrypoint · Starts the application · `Hangman.java`
- [Game](https://github.com/michaelkolesidis/hangman/blob/main/Game.java): orchestrator · Runs rounds and owns game state · `Game.java`
- [Printer](https://github.com/michaelkolesidis/hangman/blob/main/Printer.java): terminal output · Renders game state and prompts · `Printer.java`
- [Input](https://github.com/michaelkolesidis/hangman/blob/main/Input.java): input base · Base console input abstraction · `Input.java`
- [LetterInput](https://github.com/michaelkolesidis/hangman/blob/main/LetterInput.java): letter input · Reads and validates letter guesses · `LetterInput.java`
- [PlayAgain](https://github.com/michaelkolesidis/hangman/blob/main/PlayAgain.java): replay input · Handles round restart choice · `PlayAgain.java`

### Word Pipeline

Parsing and selecting secret words

- [Parser](https://github.com/michaelkolesidis/hangman/blob/main/Parser.java): parse/validate · General text parsing and validation · `Parser.java`
- [WordParser](https://github.com/michaelkolesidis/hangman/blob/main/WordParser.java): word parsing · Normalizes candidate words · `WordParser.java`
- [Picker](https://github.com/michaelkolesidis/hangman/blob/main/Picker.java): selection base · Base word selection abstraction · `Picker.java`
- [WordPicker](https://github.com/michaelkolesidis/hangman/blob/main/WordPicker.java): word selection · Chooses the secret word for a round · `WordPicker.java`
- [wordlist.txt](https://github.com/michaelkolesidis/hangman/blob/main/wordlist.txt): word source · Vocabulary file used by the picker · `wordlist.txt`

## Connections

- Hangman → Game: launches · Application entry creates the game loop
- Game → Printer: renders · Game sends state and prompts to the terminal
- Game → LetterInput: requests guess · Game asks for the next letter guess
- Game → PlayAgain: requests replay · Game asks whether to start another round
- Game → WordPicker: gets word · Game obtains a secret word for each round
- LetterInput → Input: extends · Specialized console input
- PlayAgain → Input: extends · Specialized console input
- LetterInput → Parser: validates · Letter input is parsed and checked
- PlayAgain → Parser: parses · Replay choice is parsed and checked
- WordPicker → Picker: uses · WordPicker builds on selection logic
- WordPicker → WordParser: normalizes · Candidate words are parsed before selection
- WordPicker → wordlist.txt: reads · Secret words come from the text file
- WordParser → Parser: builds on · Word-specific parsing reuses generic parsing
