# tanyaflos76/pygame-project architecture

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

- Interactive diagram: https://gitdiagram.com/tanyaflos76/pygame-project
- Repository: https://github.com/tanyaflos76/pygame-project

## Overview

Typario is a Pygame typing game. The player chooses a language and difficulty, types words as they appear, and reaches a score-and-record game-over screen with retry/menu options. Game owns the event loop and screen dispatch; each screen signals transitions back through Game. Gameplay delegates word selection, input matching, score, and health to Spawner, which loads language word lists. Game-over records scores in SQLite. The README is empty; screen base-class details and some screen implementations are unsampled, so the graph focuses on evidenced wiring.

Main entry points: [`typario/game.py`](https://github.com/tanyaflos76/pygame-project/blob/main/typario/game.py) (Game loop), [`typario/screens/game_over.py`](https://github.com/tanyaflos76/pygame-project/blob/main/typario/screens/game_over.py) (Game-over screen), [`typario/screens/menu.py`](https://github.com/tanyaflos76/pygame-project/blob/main/typario/screens/menu.py) (Language menu), [`typario/screens/difficulty.py`](https://github.com/tanyaflos76/pygame-project/blob/main/typario/screens/difficulty.py) (Difficulty selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game runtime"]
  node_launcher["Application entry<br/>[main.py]"]
  node_game["Game loop<br/>[game.py]"]
  node_button["Button component<br/>[button.py]"]
  node_image_loader["Image loader<br/>[image.py]"]
end

subgraph group_screens["Game screens"]
  node_menu["Language menu<br/>[menu.py]"]
  node_difficulty["Difficulty selection<br/>[difficulty.py]"]
  node_game_screen["Typing screen<br/>[game.py]"]
  node_game_over["Game-over screen<br/>[game_over.py]"]
end

subgraph group_typing["Typing gameplay"]
  node_spawner["Word and score logic<br/>[spawner.py]"]
  node_word_lists["Language word lists"]
end

subgraph group_persistence["Configuration and records"]
  node_config["Game settings<br/>[config.py]"]
  node_records["Record operations<br/>[records.py]"]
  node_record_db[("Records database<br/>[records.db]")]
  node_settings_file["Settings file<br/>[config.json]"]
end

node_player(("Player"))

node_player -->|"starts"| node_launcher
node_launcher -->|"creates and runs"| node_game
node_game -->|"loads settings"| node_config
node_config -->|"reads"| node_settings_file
node_game -->|"initializes database"| node_records
node_game -->|"dispatches screen"| node_menu
node_game -->|"dispatches screen"| node_difficulty
node_game -->|"dispatches screen"| node_game_screen
node_game -->|"dispatches screen"| node_game_over
node_player -->|"chooses language"| node_menu
node_menu -->|"uses"| node_button
node_menu -->|"loads background"| node_image_loader
node_menu -->|"requests difficulty"| node_game
node_player -->|"chooses difficulty"| node_difficulty
node_difficulty -->|"uses"| node_button
node_difficulty -->|"loads background"| node_image_loader
node_difficulty -->|"requests game"| node_game
node_player -->|"types characters"| node_game_screen
node_game_screen -->|"creates and updates"| node_spawner
node_game_screen -->|"forwards input"| node_spawner
node_spawner -->|"reads words"| node_word_lists
node_game_screen -->|"requests game over"| node_game
node_game_over -->|"adds score and finds record"| node_records
node_records -->|"reads and writes"| node_record_db
node_game_over -->|"uses"| node_button
node_game_over -->|"loads background"| node_image_loader
node_game_over -->|"requests retry or menu"| node_game

click node_launcher "https://github.com/tanyaflos76/pygame-project/blob/main/typario/main.py"
click node_game "https://github.com/tanyaflos76/pygame-project/blob/main/typario/game.py"
click node_config "https://github.com/tanyaflos76/pygame-project/blob/main/typario/core/config.py"
click node_menu "https://github.com/tanyaflos76/pygame-project/blob/main/typario/screens/menu.py"
click node_difficulty "https://github.com/tanyaflos76/pygame-project/blob/main/typario/screens/difficulty.py"
click node_game_screen "https://github.com/tanyaflos76/pygame-project/blob/main/typario/screens/game.py"
click node_game_over "https://github.com/tanyaflos76/pygame-project/blob/main/typario/screens/game_over.py"
click node_spawner "https://github.com/tanyaflos76/pygame-project/blob/main/typario/lib/spawner.py"
click node_word_lists "https://github.com/tanyaflos76/pygame-project/tree/main/typario/data/languages"
click node_button "https://github.com/tanyaflos76/pygame-project/blob/main/typario/components/button.py"
click node_image_loader "https://github.com/tanyaflos76/pygame-project/blob/main/typario/utils/image.py"
click node_records "https://github.com/tanyaflos76/pygame-project/blob/main/typario/utils/records.py"
click node_record_db "https://github.com/tanyaflos76/pygame-project/blob/main/typario/data/records.db"
click node_settings_file "https://github.com/tanyaflos76/pygame-project/blob/main/config/config.json"

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_launcher,node_game,node_button,node_image_loader toneBlue
class node_menu,node_difficulty,node_game_screen,node_game_over toneAmber
class node_spawner,node_word_lists toneMint
class node_config,node_records,node_record_db,node_settings_file toneRose
class node_player toneIndigo
```

## Components

### Game runtime

- [Application entry](https://github.com/tanyaflos76/pygame-project/blob/main/typario/main.py): `typario/main.py`
- [Game loop](https://github.com/tanyaflos76/pygame-project/blob/main/typario/game.py): `typario/game.py`
- [Button component](https://github.com/tanyaflos76/pygame-project/blob/main/typario/components/button.py): `typario/components/button.py`
- [Image loader](https://github.com/tanyaflos76/pygame-project/blob/main/typario/utils/image.py): `typario/utils/image.py`

### Game screens

- [Language menu](https://github.com/tanyaflos76/pygame-project/blob/main/typario/screens/menu.py): `typario/screens/menu.py`
- [Difficulty selection](https://github.com/tanyaflos76/pygame-project/blob/main/typario/screens/difficulty.py): `typario/screens/difficulty.py`
- [Typing screen](https://github.com/tanyaflos76/pygame-project/blob/main/typario/screens/game.py): `typario/screens/game.py`
- [Game-over screen](https://github.com/tanyaflos76/pygame-project/blob/main/typario/screens/game_over.py): `typario/screens/game_over.py`

### Typing gameplay

- [Word and score logic](https://github.com/tanyaflos76/pygame-project/blob/main/typario/lib/spawner.py): `typario/lib/spawner.py`
- [Language word lists](https://github.com/tanyaflos76/pygame-project/tree/main/typario/data/languages): `typario/data/languages`

### Configuration and records

- [Game settings](https://github.com/tanyaflos76/pygame-project/blob/main/typario/core/config.py): `typario/core/config.py`
- [Record operations](https://github.com/tanyaflos76/pygame-project/blob/main/typario/utils/records.py): `typario/utils/records.py`
- [Records database](https://github.com/tanyaflos76/pygame-project/blob/main/typario/data/records.db): `typario/data/records.db`
- [Settings file](https://github.com/tanyaflos76/pygame-project/blob/main/config/config.json): `config/config.json`

### Other components

- **Player**

## Connections

- Player → Application entry: starts
- Application entry → Game loop: creates and runs
- Game loop → Game settings: loads settings
- Game settings → Settings file: reads
- Game loop → Record operations: initializes database
- Game loop → Language menu: dispatches screen
- Game loop → Difficulty selection: dispatches screen
- Game loop → Typing screen: dispatches screen
- Game loop → Game-over screen: dispatches screen
- Player → Language menu: chooses language
- Language menu → Button component: uses
- Language menu → Image loader: loads background
- Language menu → Game loop: requests difficulty
- Player → Difficulty selection: chooses difficulty
- Difficulty selection → Button component: uses
- Difficulty selection → Image loader: loads background
- Difficulty selection → Game loop: requests game
- Player → Typing screen: types characters
- Typing screen → Word and score logic: creates and updates
- Typing screen → Word and score logic: forwards input
- Word and score logic → Language word lists: reads words
- Typing screen → Game loop: requests game over
- Game-over screen → Record operations: adds score and finds record
- Record operations → Records database: reads and writes
- Game-over screen → Button component: uses
- Game-over screen → Image loader: loads background
- Game-over screen → Game loop: requests retry or menu
