# usernob/card-game architecture

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

- Interactive diagram: https://gitdiagram.com/usernob/card-game
- Repository: https://github.com/usernob/card-game

## Overview

This is an SDL-based deck-building card game. The visible workflow starts with the player interacting with the game window, passes input and frame updates through the application and game controller, and presents game pages built from layouts and widgets. Card and tarot managers provide game-domain state; bitmap fonts and texture atlases support rendering. The README lists assets but does not document gameplay; some subsystem links are therefore omitted where sampled source does not show the runtime call.

Main entry points: [`src/main.cpp`](https://github.com/usernob/card-game/blob/master/src/main.cpp) (App Lifecycle), [`src/game.cpp`](https://github.com/usernob/card-game/blob/master/src/game.cpp) (Game Controller), [`src/widget.cpp`](https://github.com/usernob/card-game/blob/master/src/widget.cpp) (UI Widgets), [`src/texturemanager.h`](https://github.com/usernob/card-game/blob/master/src/texturemanager.h) (Texture Atlases)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_entry["App Lifecycle<br/>[main.cpp]"]
end

subgraph group_gameplay["Game Domain"]
  node_controller["Game Controller<br/>[game.cpp]"]
  node_card_manager["Card Manager<br/>[card.cpp]"]
  node_tarot_manager["Tarot Manager<br/>[card.cpp]"]
  node_card_model["Card Models<br/>[card.h]"]
end

subgraph group_ui["Interface"]
  node_page_system["Page System<br/>[pages.cpp]"]
  node_game_pages["Game Pages<br/>[pages.cpp]"]
  node_layout["Layout Engine<br/>[layout.cpp]"]
  node_widgets["UI Widgets<br/>[widget.cpp]"]
end

subgraph group_render["Rendering Resources"]
  node_text["Bitmap Text<br/>[textrenderer.cpp]"]
  node_fonts["Font Resources"]
  node_texture_manager["Texture Atlases<br/>[texturemanager.h]"]
  node_atlas_assets["Atlas Assets"]
end

node_player(("Player"))
node_sdl["SDL Window"]

node_player -->|"interacts with"| node_sdl
node_sdl -->|"dispatches events"| node_entry
node_entry -->|"creates"| node_controller
node_entry -->|"updates and renders"| node_controller
node_entry -->|"forwards input"| node_controller
node_entry -->|"loads"| node_fonts
node_entry -->|"loads atlases"| node_texture_manager
node_texture_manager -->|"loads metadata"| node_atlas_assets
node_controller -.->|"owns game state"| node_card_manager
node_controller -.->|"updates game interface"| node_game_pages
node_card_manager -->|"manages cards"| node_card_model
node_tarot_manager -->|"uses tarot models"| node_card_model
node_page_system -->|"builds layouts"| node_layout
node_page_system -->|"adds widgets"| node_widgets
node_game_pages -->|"reads game state"| node_controller
node_widgets -->|"renders text"| node_text
node_text -.->|"uses font glyphs"| node_fonts
node_widgets -->|"uses textures"| node_texture_manager

click node_entry "https://github.com/usernob/card-game/blob/master/src/main.cpp"
click node_controller "https://github.com/usernob/card-game/blob/master/src/game.cpp"
click node_card_manager "https://github.com/usernob/card-game/blob/master/src/card.cpp"
click node_tarot_manager "https://github.com/usernob/card-game/blob/master/src/card.cpp"
click node_card_model "https://github.com/usernob/card-game/blob/master/src/card.h"
click node_page_system "https://github.com/usernob/card-game/blob/master/src/pages.cpp"
click node_game_pages "https://github.com/usernob/card-game/blob/master/src/pages.cpp"
click node_layout "https://github.com/usernob/card-game/blob/master/src/layout.cpp"
click node_widgets "https://github.com/usernob/card-game/blob/master/src/widget.cpp"
click node_text "https://github.com/usernob/card-game/blob/master/src/textrenderer.cpp"
click node_fonts "https://github.com/usernob/card-game/tree/master/assets/fonts"
click node_texture_manager "https://github.com/usernob/card-game/blob/master/src/texturemanager.h"
click node_atlas_assets "https://github.com/usernob/card-game/tree/master/assets/textures/atlas"

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_entry toneBlue
class node_controller,node_card_manager,node_tarot_manager,node_card_model toneAmber
class node_page_system,node_game_pages,node_layout,node_widgets toneMint
class node_text,node_fonts,node_texture_manager,node_atlas_assets toneRose
class node_player,node_sdl toneIndigo
```

## Components

### Application

- [App Lifecycle](https://github.com/usernob/card-game/blob/master/src/main.cpp): `src/main.cpp`

### Game Domain

- [Game Controller](https://github.com/usernob/card-game/blob/master/src/game.cpp): `src/game.cpp`
- [Card Manager](https://github.com/usernob/card-game/blob/master/src/card.cpp): `src/card.cpp`
- [Tarot Manager](https://github.com/usernob/card-game/blob/master/src/card.cpp): `src/card.cpp`
- [Card Models](https://github.com/usernob/card-game/blob/master/src/card.h): `src/card.h`

### Interface

- [Page System](https://github.com/usernob/card-game/blob/master/src/pages.cpp): `src/pages.cpp`
- [Game Pages](https://github.com/usernob/card-game/blob/master/src/pages.cpp): `src/pages.cpp`
- [Layout Engine](https://github.com/usernob/card-game/blob/master/src/layout.cpp): `src/layout.cpp`
- [UI Widgets](https://github.com/usernob/card-game/blob/master/src/widget.cpp): `src/widget.cpp`

### Rendering Resources

- [Bitmap Text](https://github.com/usernob/card-game/blob/master/src/textrenderer.cpp): `src/textrenderer.cpp`
- [Font Resources](https://github.com/usernob/card-game/tree/master/assets/fonts): `assets/fonts`
- [Texture Atlases](https://github.com/usernob/card-game/blob/master/src/texturemanager.h): `src/texturemanager.h`
- [Atlas Assets](https://github.com/usernob/card-game/tree/master/assets/textures/atlas): `assets/textures/atlas`

### Other components

- **Player**
- **SDL Window**

## Connections

- Player → SDL Window: interacts with
- SDL Window → App Lifecycle: dispatches events (evidence: `src/main.cpp`)
- App Lifecycle → Game Controller: creates (evidence: `src/main.cpp`)
- App Lifecycle → Game Controller: updates and renders (evidence: `src/main.cpp`)
- App Lifecycle → Game Controller: forwards input (evidence: `src/main.cpp`)
- App Lifecycle → Font Resources: loads (evidence: `src/main.cpp`)
- App Lifecycle → Texture Atlases: loads atlases (evidence: `src/main.cpp`)
- Texture Atlases → Atlas Assets: loads metadata (evidence: `src/texturemanager.h`)
- Game Controller → Card Manager: owns game state
- Game Controller → Game Pages: updates game interface
- Card Manager → Card Models: manages cards (evidence: `src/card.h`)
- Tarot Manager → Card Models: uses tarot models (evidence: `src/card.h`)
- Page System → Layout Engine: builds layouts (evidence: `src/pages.cpp`)
- Page System → UI Widgets: adds widgets (evidence: `src/pages.cpp`)
- Game Pages → Game Controller: reads game state (evidence: `src/pages.cpp`)
- UI Widgets → Bitmap Text: renders text
- Bitmap Text → Font Resources: uses font glyphs
- UI Widgets → Texture Atlases: uses textures
