# bachhungcb/lthdt.20241-04 architecture

> Architecture diagram of the GitHub repository bachhungcb/lthdt.20241-04, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bachhungcb/lthdt.20241-04
- Repository: https://github.com/bachhungcb/lthdt.20241-04

## Overview

##### Project type and purpose
- This is a Java-based desktop puzzle game (an OOP coursework project) built with JavaFX.
- It follows an MVC-style separation between the core game logic (model), the UI views (FXML files), and controllers that mediate user interaction.

##### File structure
Top-level packages under `sourcecode/`:
- game – entry point (`Game.java`) and game loop setup
- model – domain objects (Cell, GameBoard, Player, Square, HalfCircle) and interfaces (Pickable)
- gem – concrete gem types (Gem, BigGem, SmallGem) used by the model
- screen
– application – JavaFX screens (IntroScreen, PlayScreen, HelpScreen, EndScreen) and shared data
– controller – controllers for each screen, implementing user-driven logic
– view – FXML layout files for each screen
– images, music – static resources

##### README
- Confirms this is a team assignment for an OOP class.

##### Detailed capture of essential elements
- Do not just list packages; show how data flows from user input in the View, through Controller, into Model, and back to the View.
- Screen/application classes that manage scene transitions and hold shared game state.
- Game loop or event-driven nature of PlayScreenController invoking model updates on user actions or timers.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Launcher
    GameLauncher["Game Launcher / Core Engine"]:::launcher
    click GameLauncher "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/game/Game.java"

    %% UI Application Layer
    subgraph "UI Application" 
        direction TB
        IntroApp["IntroScreen"]:::application
        PlayApp["PlayScreen"]:::application
        HelpApp["HelpScreen"]:::application
        EndApp["EndScreen"]:::application
        ShareData["ShareData"]:::application
        click IntroApp "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/screen/application/IntroScreen.java"
        click PlayApp "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/screen/application/PlayScreen.java"
        click HelpApp "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/screen/application/HelpScreen.java"
        click EndApp "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/screen/application/EndScreen.java"
        click ShareData "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/screen/application/ShareData.java"
    end

    %% Controllers
    subgraph "Controllers" 
        direction TB
        IntroCtrl["IntroScreenController"]:::controller
        PlayCtrl["PlayScreenController"]:::controller
        HelpCtrl["HelpScreenController"]:::controller
        EndCtrl["EndScreenController"]:::controller
        click IntroCtrl "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/screen/controller/IntroScreenController.java"
        click PlayCtrl "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/screen/controller/PlayScreenController.java"
        click HelpCtrl "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/screen/controller/HelpScreenController.java"
        click EndCtrl "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/screen/controller/EndScreenController.java"
    end

    %% Views
    subgraph "Views (FXML)" 
        direction TB
        IntroView["IntroScreen.fxml"]:::view
        PlayView["PlayScreen.fxml"]:::view
        HelpView["HelpScreen.fxml"]:::view
        EndView["EndScreen.fxml"]:::view
        click IntroView "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/screen/view/IntroScreen.fxml"
        click PlayView "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/screen/view/PlayScreen.fxml"
        click HelpView "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/screen/view/HelpScreen.fxml"
        click EndView "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/screen/view/EndScreen.fxml"
    end

    %% Domain Model
    subgraph "Domain Model" 
        direction TB
        Cell["Cell"]:::model
        GameBoard["GameBoard"]:::model
        Player["Player"]:::model
        Square["Square"]:::model
        HalfCircle["HalfCircle"]:::model
        Pickable["Pickable (interface)"]:::model
        Gem["Gem"]:::model
        BigGem["BigGem"]:::model
        SmallGem["SmallGem"]:::model
        click Cell "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/model/Cell.java"
        click GameBoard "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/model/GameBoard.java"
        click Player "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/model/Player.java"
        click Square "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/model/Square.java"
        click HalfCircle "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/model/HalfCircle.java"
        click Pickable "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/model/Pickable.java"
        click Gem "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/gem/Gem.java"
        click BigGem "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/gem/BigGem.java"
        click SmallGem "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/gem/SmallGem.java"
    end

    %% Resources
    subgraph "Resources" 
        direction TB
        Images["Images"]:::resources
        Music["Music (gameMusic.mp3)"]:::resources
        click Images "https://github.com/bachhungcb/lthdt.20241-04/tree/main/sourcecode/screen/images"
        click Music "https://github.com/bachhungcb/lthdt.20241-04/blob/main/sourcecode/screen/music/gameMusic.mp3"
    end

    %% Connections
    GameLauncher -->|"starts"| IntroApp
    GameLauncher -->|"initializes ShareData"| ShareData

    IntroApp -->|"loads FXML"| IntroView
    PlayApp -->|"loads FXML"| PlayView
    HelpApp -->|"loads FXML"| HelpView
    EndApp -->|"loads FXML"| EndView

    IntroApp -->|"uses controller"| IntroCtrl
    PlayApp -->|"uses controller"| PlayCtrl
    HelpApp -->|"uses controller"| HelpCtrl
    EndApp -->|"uses controller"| EndCtrl

    IntroCtrl -->|"switches scenes via"| PlayApp
    PlayCtrl -->|"onPlayAction"| GameBoard
    PlayCtrl -->|"manipulates"| Player
    PlayCtrl -->|"manipulates"| Gem
    PlayCtrl -->|"manipulates"| BigGem
    PlayCtrl -->|"manipulates"| SmallGem

    IntroCtrl -->|"updates view"| IntroView
    PlayCtrl -->|"updates view"| PlayView
    HelpCtrl -->|"updates view"| HelpView
    EndCtrl -->|"updates view"| EndView

    IntroCtrl -->|"loads resources"| Images
    PlayCtrl -->|"loads resources"| Images
    PlayCtrl -->|"plays background"| Music

    %% Styling
    classDef launcher fill:#D1C4E9,stroke:#5E35B1,color:#212121;
    classDef application fill:#E8EAF6,stroke:#3F51B5,color:#212121;
    classDef controller fill:#FFE0B2,stroke:#FB8C00,color:#212121;
    classDef view fill:#C8E6C9,stroke:#388E3C,color:#212121;
    classDef model fill:#BBDEFB,stroke:#1976D2,color:#212121;
    classDef resources fill:#EEEEEE,stroke:#9E9E9E,color:#212121;
```
