# jirayutnajan/pixelharvest-progmeth_project architecture

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

- Interactive diagram: https://gitdiagram.com/jirayutnajan/pixelharvest-progmeth_project
- Repository: https://github.com/jirayutnajan/pixelharvest-progmeth_project

## Overview

##### Main Components
- Application Layer – The entry point is in src/application/Main.java. This launches the game, sets up the environment, and starts the game loop.
- Game Logic – Components in the src/game package (GameController, GameSceneController) manage game state and transitions between scenes.
- Scenes & UI – The src/scenes and src/ui packages include various canvases (GameCanvas, MenuCanvas, TutorialCanvas, etc.) and UI controls such as buttons, dialogs, inventories, and player stats (PlayerHp, PlayerHunger). Also, the src/ui/dialog package holds specialized dialogs.
- Player Management – The src/player package handles the player object and animations.
- World & Map Management – The src/world package is responsible for the game world. Under it, the map subpackage defines different map types (CityMap, FarmMap, HouseMap, etc.), tile layouts, and even in-game elements like different tile types and vegetable objects.
- Utilities – The src/util package contains constants, interfaces (like Drawable, Renderable), which likely support common functions across various modules.
- External Libraries – Make a note of JavaFX (controls, FXML, media) as external dependencies that interface with your UI and media components.

##### Relationships and Data Flow
- The Application Layer is the bootstrapping point and interacts with the Game Logic to pass control to different Scenes.
- Game Logic coordinates with Scene Controllers, which in turn manage UI components (dialogs, canvas drawing routines) and objects (player, tiles, maps).
- The World/Map module interacts with the Game Logic to generate and update the game’s environment based on CSV map data and tile resources.
- Assets (e.g., CSV tile maps, images, sound files) are loaded by various modules—ensure to represent these as external resources feeding into the application.
- Utility classes support common functionality across all these modules.

##### Architectural Patterns
- The project is structured in a way that resembles an MVC (Model-View-Controller) or layered architectural design:
– Model: World/Map and Player packages act as data models.
– View: UI and scenes (canvases and dialogs) serve as the visual representation.
– Controller: Game logic components (GameController, GameSceneController) handle user inputs and scene management.
- There’s also a separation between game logic and resource management, showing a clear distinction of concerns.

##### Relevant Technologies and Frameworks
- Java (and likely Eclipse IDE configuration based on the .project and .settings files)
- JavaFX SDK (for GUI, media control, and possibly FXML support)
- CSV files for tile maps indicate a data-driven approach to scene design.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Layer
    subgraph "Application Layer"
        A("Main (Application Layer)"):::app
    end

    %% Game Logic
    subgraph "Game Logic"
        B("GameController"):::logic
        C("GameSceneController"):::logic
    end

    %% Scenes & UI
    subgraph "Scenes & UI"
        subgraph "Scenes"
            D1("GameCanvas"):::ui
            D2("MenuCanvas"):::ui
            D3("TutorialCanvas"):::ui
            D4("DeadCanvas"):::ui
            D5("EndCanvas"):::ui
            D6("WinCanvas"):::ui
        end
        subgraph "UI Controls"
            E1("ButtonRect"):::ui
            E2("Coin"):::ui
            E3("GameClock"):::ui
            E4("Inventory"):::ui
            E5("PlayerHp"):::ui
            E6("PlayerHunger"):::ui
        end
        subgraph "Dialogs"
            F1("Dialog"):::ui
            F2("StoreComputerDialog"):::ui
            F3("VegComputerDialog"):::ui
        end
    end

    %% Player Management
    subgraph "Player Management"
        G("Player"):::player
        H("PlayerAnimation"):::player
    end

    %% World & Map Management
    subgraph "World & Map Management"
        subgraph "Map Handling"
            I1("CityMap"):::world
            I2("FarmMap"):::world
            I3("HouseMap"):::world
            I4("Map"):::world
            I5("Store7Map"):::world
            I6("TileMap"):::world
            I7("VegStoreMap"):::world
        end
        subgraph "Vegetables"
            J1("BaseVegetable"):::world
            J2("Beetroot"):::world
            J3("Potato"):::world
            J4("Turnip"):::world
        end
        subgraph "Tiles"
            K1("Bed"):::world
            K2("Door"):::world
            K3("Farmland"):::world
            K4("SelectTile"):::world
            K5("StoreComputer"):::world
            K6("Tile"):::world
            K7("VegComputer"):::world
        end
    end

    %% Utilities
    subgraph "Utilities"
        L("Constants"):::util
        M("Drawable"):::util
        N("Renderable"):::util
    end

    %% Assets & Resources
    subgraph "Assets & Resources"
        O("Sound Effects"):::asset
        P("Tilemaps"):::asset
        Q("Tile Images"):::asset
    end

    %% External Libraries
    subgraph "External Libraries"
        R("JavaFX"):::external
    end

    %% Connections between components
    A -->|"launches"| B
    A -->|"launches"| C
    B -->|"coordinates"| C

    %% Game Logic to Scenes & UI
    B -->|"controls"| D1
    B -->|"controls"| D2
    B -->|"controls"| D3
    B -->|"controls"| D4
    B -->|"controls"| D5
    B -->|"controls"| D6
    B -->|"triggers updates in"| I1
    B -->|"triggers updates in"| I2
    B -->|"triggers updates in"| I3
    B -->|"triggers updates in"| I4
    B -->|"triggers updates in"| I5
    B -->|"triggers updates in"| I6
    B -->|"triggers updates in"| I7
    B -->|"manages"| G

    C -->|"controls dialogs"| F1
    C -->|"controls dialogs"| F2
    C -->|"controls dialogs"| F3

    %% UI Controls sending actions to Game Logic
    E1 -->|"triggers"| B
    E2 -->|"triggers"| B
    E3 -->|"triggers"| B
    E4 -->|"triggers"| B
    E5 -->|"triggers"| B
    E6 -->|"triggers"| B

    %% Assets feeding into World & Scenes
    P -->|"supplies CSV data to"| I1
    P -->|"supplies CSV data to"| I2
    P -->|"supplies CSV data to"| I3
    P -->|"supplies CSV data to"| I4
    P -->|"supplies CSV data to"| I5
    P -->|"supplies CSV data to"| I6
    P -->|"supplies CSV data to"| I7

    Q -->|"provides images to"| D1
    Q -->|"provides images to"| D2
    Q -->|"provides images to"| D3

    O -->|"provides audio to"| D1
    O -->|"provides audio to"| D2
    O -->|"provides audio to"| D3

    %% UI and related modules use External Libraries
    D1 -->|"uses"| R
    D2 -->|"uses"| R
    D3 -->|"uses"| R
    F1 -->|"uses"| R
    E1 -->|"uses"| R

    %% Utilities support various modules
    B -.->|"utilizes"| L
    D1 -.->|"utilizes"| L
    I1 -.->|"utilizes"| L

    %% Click Events
    click A "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/application/Main.java"
    click B "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/game/GameController.java"
    click C "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/game/GameSceneController.java"
    click D1 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/scenes/GameCanvas.java"
    click D2 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/scenes/MenuCanvas.java"
    click D3 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/scenes/TutorialCanvas.java"
    click D4 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/scenes/DeadCanvas.java"
    click D5 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/scenes/EndCanvas.java"
    click D6 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/scenes/WinCanvas.java"
    click E1 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/ui/ButtonRect.java"
    click E2 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/ui/Coin.java"
    click E3 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/ui/GameClock.java"
    click E4 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/ui/Inventory.java"
    click E5 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/ui/PlayerHp.java"
    click E6 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/ui/PlayerHunger.java"
    click F1 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/ui/dialog/Dialog.java"
    click F2 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/ui/dialog/StoreComputerDialog.java"
    click F3 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/ui/dialog/VegComputerDialog.java"
    click G "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/player/Player.java"
    click H "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/player/PlayerAnimation.java"
    click I1 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/map/CityMap.java"
    click I2 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/map/FarmMap.java"
    click I3 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/map/HouseMap.java"
    click I4 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/map/Map.java"
    click I5 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/map/Store7Map.java"
    click I6 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/map/TileMap.java"
    click I7 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/map/VegStoreMap.java"
    click J1 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/map/vegetable/BaseVegetable.java"
    click J2 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/map/vegetable/Beetroot.java"
    click J3 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/map/vegetable/Potato.java"
    click J4 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/map/vegetable/Turnip.java"
    click K1 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/tile/Bed.java"
    click K2 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/tile/Door.java"
    click K3 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/tile/Farmland.java"
    click K4 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/tile/SelectTile.java"
    click K5 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/tile/StoreComputer.java"
    click K6 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/tile/Tile.java"
    click K7 "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/world/tile/VegComputer.java"
    click L "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/util/Constants.java"
    click M "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/util/Drawable.java"
    click N "https://github.com/jirayutnajan/pixelharvest-progmeth_project/blob/main/src/util/Renderable.java"

classDef app fill:#f9c,stroke:#333,stroke-width:2px;
classDef logic fill:#bbf,stroke:#333,stroke-width:2px;
classDef ui fill:#cfc,stroke:#333,stroke-width:2px;
classDef player fill:#ff9,stroke:#333,stroke-width:2px;
classDef world fill:#fdc,stroke:#333,stroke-width:2px;
classDef util fill:#eee,stroke:#333,stroke-width:2px;
classDef asset fill:#fcc,stroke:#333,stroke-width:2px;
classDef external fill:#cff,stroke:#333,stroke-width:2px;
```
