# eliaws/el_mon_tribala architecture

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

- Interactive diagram: https://gitdiagram.com/eliaws/el_mon_tribala
- Repository: https://github.com/eliaws/el_mon_tribala

## Overview

1. **What this repository is**  
`el_mon_tribala` is a standalone Java card game inspired by Balatro. It is an offline, single-player run-based game where the player must clear successive blinds by reaching score targets with poker hands.

2. **Top-level architecture**  
The code is organized around a clear MVC split, but with game rules extracted into a separate `domain/` layer. In practice: the controller coordinates the run, the model stores mutable game progression, the domain encapsulates all poker/economy rules, and the view layer renders the state in either console or “zen” mode.

3. **Entry point and launch modes**  
`src/Main.java` is the application entry point. The README shows two runtime modes selected by command-line argument: `console` and `zen`. That means presentation is swapped at startup, while the underlying game logic stays the same.

4. **Control flow through the game loop**  
`controller/GameController.java` is the main orchestrator. It receives player actions from a view, applies them to the game state, and produces a `PlayResult` that likely summarizes the outcome of a move or hand. This keeps the UI from directly mutating game rules.

5. **Mutable game state vs. rule objects**  
`model/GameState.java` and `model/GamePhase.java` hold the evolving run state and the current phase of play. This layer is the bridge between UI and rules: it tracks where the player is in the run, what phase they are in, and what the controller should allow next.

6. **Core domain entities**  
The `domain/` package contains the game’s fundamental concepts: `Card`, `Rank`, `Suit`, `Deck`, `Blind`, and `Shop`. These are the data and rule objects that define the game without any rendering concerns. `Blind` represents the score challenge to beat, and `Shop` represents the between-blind economy.

7. **Progression and economy**  
`domain/consummables/Planet.java` is the main upgrade item. The README says planets improve poker combinations, so the shop is not cosmetic: it is a gameplay subsystem that modifies scoring/progression between blinds. The run is structured around 8 antes, so progression is a sequence of increasingly demanding score thresholds.

8. **Hand representation and evaluation**  
Poker logic is split into multiple layers under `domain/hand/`. `HandType` classifies a hand, `hand/combinations/*` contains concrete poker-hand implementations such as Pair, TwoPair, Straight, Flush, FullHouse, and RoyalFlush, and `PlayedHand` likely binds an actual set of cards to one of those recognized combinations.

9. **Scoring pipeline**  
`domain/hand/evaluation/HandEvaluator.java` determines what kind of hand was played, and `domain/hand/scoring/HandScorer.java` converts that evaluation into a numeric `Score`. This separation matters: recognition of the hand is distinct from calculating its value, which makes balancing easier and keeps the scoring logic isolated.

10. **Presentation layer**  
`view/View.java` is the abstraction, with `ConsoleView.java` and `ZenView.java` as concrete presenters. `Rect.java` suggests the zen interface uses positioned rectangular UI elements. The view layer reads state/results and displays them; it should not contain game rules.

11. **Assets and theming**  
`src/ressources/` contains fonts and image sets grouped by themes such as `death`, `life`, `planets`, `space`, and `time`. These assets are part of the presentation layer and reinforce that the game uses themed visuals rather than external services or dynamic content.

12. **Important architectural boundary**  
The strongest boundary in this repository is between **presentation/game flow** and **pure game rules**. That makes the scoring, hand evaluation, and progression systems reusable across both console and zen views, and it keeps the architecture suitable for diagramming as: input/view → controller → state/domain → view update, with assets only touching the final rendering step.

Main entry points: [`src/controller/GameController.java`](https://github.com/eliaws/el_mon_tribala/blob/main/src/controller/GameController.java) (Game controller), [`src/view/View.java`](https://github.com/eliaws/el_mon_tribala/blob/main/src/view/View.java) (View), [`src/Main.java`](https://github.com/eliaws/el_mon_tribala/blob/main/src/Main.java) (Main), [`src/model/GameState.java`](https://github.com/eliaws/el_mon_tribala/blob/main/src/model/GameState.java) (Game state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_main["Main<br/>entrypoint<br/>[Main.java]"]
end

subgraph group_flow["Game Flow"]
  node_controller["Game controller<br/>orchestrator"]
  node_play_result["Play result<br/>[PlayResult.java]"]
  node_game_state[("Game state<br/>[GameState.java]")]
  node_game_phase{{"Game phase<br/>enum<br/>[GamePhase.java]"}}
end

subgraph group_rules["Domain Rules"]
  node_card["Card<br/>domain entity<br/>[Card.java]"]
  node_rank{{"Rank<br/>domain enum<br/>[Rank.java]"}}
  node_suit{{"Suit<br/>domain enum<br/>[Suit.java]"}}
  node_deck[("Deck<br/>domain entity<br/>[Deck.java]")]
  node_blind{{"Blind<br/>progression rule<br/>[Blind.java]"}}
  node_shop["Shop<br/>economy rule<br/>[Shop.java]"]
  node_planet["Planet<br/>consumable<br/>[Planet.java]"]
  node_hand_eval["Hand evaluator<br/>analysis<br/>[HandEvaluator.java]"]
  node_hand_scorer["Hand scorer<br/>scoring<br/>[HandScorer.java]"]
  node_score["Score<br/>value object<br/>[Score.java]"]
  node_played_hand["Played hand<br/>hand model<br/>[PlayedHand.java]"]
  node_hand_type{{"Hand type<br/>classification<br/>[HandType.java]"}}
end

subgraph group_ui["Presentation"]
  node_view["View<br/>presentation api<br/>[View.java]"]
  node_console_view["Console view<br/>terminal ui<br/>[ConsoleView.java]"]
  node_zen_view["Zen view<br/>visual ui<br/>[ZenView.java]"]
  node_rect["Rect<br/>layout primitive<br/>[Rect.java]"]
end

node_main -->|"starts game"| node_controller
node_main -->|"console mode"| node_console_view
node_main -->|"zen mode"| node_zen_view
node_controller -->|"reads/writes"| node_game_state
node_controller -->|"produces"| node_play_result
node_controller -->|"drives"| node_view
node_view -.->|"implemented by"| node_console_view
node_view -.->|"implemented by"| node_zen_view
node_zen_view -->|"lays out"| node_rect
node_game_state -->|"tracks"| node_game_phase
node_deck -->|"contains"| node_card
node_card -->|"has"| node_rank
node_card -->|"has"| node_suit
node_controller -->|"advances"| node_blind
node_controller -->|"enters"| node_shop
node_shop -->|"offers"| node_planet
node_hand_eval -->|"builds"| node_played_hand
node_hand_eval -->|"recognizes"| node_hand_type
node_hand_scorer -->|"consumes"| node_hand_eval
node_hand_scorer -->|"returns"| node_score
node_played_hand -->|"classified as"| node_hand_type
node_game_state -.->|"uses"| node_hand_scorer
node_view -->|"renders"| node_play_result

click node_main "https://github.com/eliaws/el_mon_tribala/blob/main/src/Main.java"
click node_controller "https://github.com/eliaws/el_mon_tribala/blob/main/src/controller/GameController.java"
click node_play_result "https://github.com/eliaws/el_mon_tribala/blob/main/src/controller/PlayResult.java"
click node_game_state "https://github.com/eliaws/el_mon_tribala/blob/main/src/model/GameState.java"
click node_game_phase "https://github.com/eliaws/el_mon_tribala/blob/main/src/model/GamePhase.java"
click node_view "https://github.com/eliaws/el_mon_tribala/blob/main/src/view/View.java"
click node_console_view "https://github.com/eliaws/el_mon_tribala/blob/main/src/view/ConsoleView.java"
click node_zen_view "https://github.com/eliaws/el_mon_tribala/blob/main/src/view/ZenView.java"
click node_rect "https://github.com/eliaws/el_mon_tribala/blob/main/src/view/Rect.java"
click node_card "https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/Card.java"
click node_rank "https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/Rank.java"
click node_suit "https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/Suit.java"
click node_deck "https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/Deck.java"
click node_blind "https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/Blind.java"
click node_shop "https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/Shop.java"
click node_planet "https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/consummables/Planet.java"
click node_hand_eval "https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/hand/evaluation/HandEvaluator.java"
click node_hand_scorer "https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/hand/scoring/HandScorer.java"
click node_score "https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/hand/scoring/Score.java"
click node_played_hand "https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/hand/combinations/PlayedHand.java"
click node_hand_type "https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/hand/HandType.java"

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_main toneBlue
class node_controller,node_play_result,node_game_state,node_game_phase toneAmber
class node_card,node_rank,node_suit,node_deck,node_blind,node_shop,node_planet,node_hand_eval,node_hand_scorer,node_score,node_played_hand,node_hand_type toneMint
class node_view,node_console_view,node_zen_view,node_rect toneRose
```

## Components

### Application

Entry point and runtime selection

- [Main](https://github.com/eliaws/el_mon_tribala/blob/main/src/Main.java): entrypoint · Starts the game and selects runtime mode · `src/Main.java`

### Game Flow

Orchestration and mutable run state

- [Game controller](https://github.com/eliaws/el_mon_tribala/blob/main/src/controller/GameController.java): orchestrator · Coordinates player actions, game state, and play outcomes · `src/controller/GameController.java`
- [Play result](https://github.com/eliaws/el_mon_tribala/blob/main/src/controller/PlayResult.java): result · Summarizes the outcome of a move or hand · `src/controller/PlayResult.java`
- [Game state](https://github.com/eliaws/el_mon_tribala/blob/main/src/model/GameState.java): state · Holds mutable run progression and current context · `src/model/GameState.java`
- [Game phase](https://github.com/eliaws/el_mon_tribala/blob/main/src/model/GamePhase.java): enum · Tracks the current phase of play · `src/model/GamePhase.java`

### Domain Rules

Cards, hands, scoring, shop, and blinds

- [Card](https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/Card.java): domain entity · Represents a playing card · `src/domain/Card.java`
- [Rank](https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/Rank.java): domain enum · Card rank values · `src/domain/Rank.java`
- [Suit](https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/Suit.java): domain enum · Card suit values · `src/domain/Suit.java`
- [Deck](https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/Deck.java): domain entity · Card deck and draw flow · `src/domain/Deck.java`
- [Blind](https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/Blind.java): progression rule · Score target that must be cleared · `src/domain/Blind.java`
- [Shop](https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/Shop.java): economy rule · Between-blind upgrade and purchase flow · `src/domain/Shop.java`
- [Planet](https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/consummables/Planet.java): consumable · Upgrade item that improves poker combinations · `src/domain/consummables/Planet.java`
- [Hand evaluator](https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/hand/evaluation/HandEvaluator.java): analysis · Recognizes the poker combination played · `src/domain/hand/evaluation/HandEvaluator.java`
- [Hand scorer](https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/hand/scoring/HandScorer.java): scoring · Converts evaluated hands into points · `src/domain/hand/scoring/HandScorer.java`
- [Score](https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/hand/scoring/Score.java): value object · Numeric scoring result · `src/domain/hand/scoring/Score.java`
- [Played hand](https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/hand/combinations/PlayedHand.java): hand model · Bound set of cards and its recognized combination · `src/domain/hand/combinations/PlayedHand.java`
- [Hand type](https://github.com/eliaws/el_mon_tribala/blob/main/src/domain/hand/HandType.java): classification · Hand category used by evaluation and scoring · `src/domain/hand/HandType.java`

### Presentation

Views and themed assets

- [View](https://github.com/eliaws/el_mon_tribala/blob/main/src/view/View.java): presentation api · Abstract view interface for rendering and input · `src/view/View.java`
- [Console view](https://github.com/eliaws/el_mon_tribala/blob/main/src/view/ConsoleView.java): terminal ui · Text-based presentation mode · `src/view/ConsoleView.java`
- [Zen view](https://github.com/eliaws/el_mon_tribala/blob/main/src/view/ZenView.java): visual ui · Graphical presentation mode · `src/view/ZenView.java`
- [Rect](https://github.com/eliaws/el_mon_tribala/blob/main/src/view/Rect.java): layout primitive · Positioned rectangle used by the zen interface · `src/view/Rect.java`

## Connections

- Main → Game controller: starts game · Launches the run loop and runtime mode
- Main → Console view: console mode · Selects text presentation at startup
- Main → Zen view: zen mode · Selects visual presentation at startup
- Game controller → Game state: reads/writes · Updates mutable run state
- Game controller → Play result: produces · Returns move or hand outcome
- Game controller → View: drives · Sends state and outcomes to presentation
- View → Console view: implemented by · Console rendering path
- View → Zen view: implemented by · Zen rendering path
- Zen view → Rect: lays out · Uses rectangles for interface geometry
- Game state → Game phase: tracks · Stores current phase of play
- Deck → Card: contains · Draws and manages cards
- Card → Rank: has · Card rank value
- Card → Suit: has · Card suit value
- Game controller → Blind: advances · Moves through score targets
- Game controller → Shop: enters · Routes between blinds to economy flow
- Shop → Planet: offers · Provides upgrade consumables
- Hand evaluator → Played hand: builds · Classifies a set of cards as a played hand
- Hand evaluator → Hand type: recognizes · Maps cards to a hand category
- Hand scorer → Hand evaluator: consumes · Scores the evaluated combination
- Hand scorer → Score: returns · Produces numeric score
- Played hand → Hand type: classified as · Stores the detected hand category
- Game state → Hand scorer: uses · Run progression depends on scored hands
- View → Play result: renders · Displays outcome feedback
