# normaalbart/dpat-sudoko architecture

> Architecture diagram of the GitHub repository normaalbart/dpat-sudoko, 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/normaalbart/dpat-sudoko
- Repository: https://github.com/normaalbart/dpat-sudoko

## Overview

##### Project Type and Purpose
- This is a desktop (or potentially GUI-based) Sudoku game application that supports different puzzle types (e.g., 4x4, 6x6, 9x9, jigsaw, samurai).
- The purpose is to manage and display Sudoku puzzles, handle user commands (like setting or removing a value), parse puzzle files, and manage game state and timer functionalities.

##### Main Components
a. User Interface (View):
– Represented by packages under “org.avans.sudoku.view”, including:
- SudokuView (general view management)
- InformationPane, TimerLabel, HelpNumbersPane (information and support components)
- Menubar and file chooser components for loading puzzles
- SudokuGridPane and cell views (BaseCellView, EmptyCellView, SudokuCellView)
b. Controller:
– “SudokuController” is the central controller that manages interactions between the view and model.
c. Model:
– Comprises classes in “org.avans.sudoku.model” (e.g., Cell, GameState, Sudoku, ValidatorGroup) which represent the game’s state and rules.
d. Command Components:
– Found under “org.avans.sudoku.command” (e.g., SetValueCommand, RemoveValueCommand, RestartGameCommand, etc.) that encapsulate user actions via the Command pattern.
e. Factories and Parsers:
– Factories (in “factory/”) use the Factory and Late Binding Factory patterns to create instances of Sudoku puzzles.
– Parsers (under “factory/parser”) are specialized for different puzzle types (General, Jigsaw, Samurai) and convert file inputs into game models.
f. Timer Components:
– Managed through the “org.avans.sudoku.timer” package, which includes various timer classes (e.g., SimpleTimer, TimerComposite) and uses the Visitor pattern for starting, stopping, and resetting the timer.
g. Utility Classes:
– For example, “TimeUtil” supports time-related functionalities.
h. External Resources:
– Puzzle files located under “sudokos” directories represent external data loaded at runtime.
– The “styles.css” in resources implies there’s some styling for the UI.

##### Establishing Relationships and Data Flow
- The application starts with Main.java invoking the main method, initializing the Controller.
- The Controller (SudokuController) mediates interactions between the View (GUI components) and the Model (game state).
- User actions in the View trigger Commands (via the ICommand interface implementations) that, in turn, update the Model.
- The Factory is used to instantiate the correct Sudoku puzzle by selecting the proper Parser based on the puzzle type.
- Timer components follow the Composite and Visitor patterns to allow nested timer management and consistent operations.
- The Observer pattern, suggested in the Behavior Patterns note, can be used for updating UI components with changes in game state.

##### Architectural Patterns and Design Principles
- The Command pattern isolates user interactions.
- Factory and Late Binding patterns facilitate creating various puzzle types, hinting at dynamic instance creation.
- Composite and Visitor patterns in the Timer module represent how timer operations are managed hierarchically.
- Observer and other behavioral patterns indicate the existence of reactive update mechanisms between components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interface (View)"
        SV["SudokuView"]:::view
        IP["InformationPane"]:::view
        TL["TimerLabel"]:::view
        HN["HelpNumbersPane"]:::view
        SMB["SudokuMenuBar"]:::view
        SFC["SudokuFileChooser"]:::view
        SGP["SudokuGridPane"]:::view
        BCV["BaseCellView"]:::view
        ECV["EmptyCellView"]:::view
        SCV["SudokuCellView"]:::view
    end

    subgraph "Controller"
        SC["SudokuController"]:::controller
    end

    subgraph "Model"
        C["Cell"]:::model
        GS["GameState"]:::model
        SU["Sudoku"]:::model
        VG["ValidatorGroup"]:::model
    end

    subgraph "Command Module"
        IC["ICommand"]:::command
        SVC["SetValueCommand"]:::command
        RMC["RemoveValueCommand"]:::command
        RGC["RestartGameCommand"]:::command
        LNGC["LoadNewGameCommand"]:::command
        THVC["ToggleHulpValueCommand"]:::command
        HVC["HulpValueCommand"]:::command
    end

    subgraph "Factory and Parser Module"
        SF["SudokuFactory"]:::factory
        ISP["ISudokuParser"]:::factory
        GSP["GeneralSudokuParser"]:::factory
        JSP["JigsawSudokuParser"]:::factory
        SSP["SamuraiSudokuParser"]:::factory
    end

    subgraph "Timer Module"
        ITC["ITimerComponent"]:::timer
        ITV["ITimerVisitor"]:::timer
        ST["SimpleTimer"]:::timer
        TC["TimerComposite"]:::timer
        STV["StartTimerVisitor"]:::timer
        SPV["StopTimerVisitor"]:::timer
        RTV["ResetTimerVisitor"]:::timer
    end

    subgraph "Utility and Resources"
        TU["TimeUtil"]:::utility
        CSS["styles.css"]:::resource
        PF["Puzzle Files"]:::resource
    end

    ME["Main"]:::entry

    %% Relationships
    ME -->|"initiates"| SC
    SV -->|"triggersEvent"| SC
    SC -->|"updates"| C
    SC -->|"updates"| GS
    SC -->|"updates"| SU
    SC -->|"updates"| VG
    SC -->|"executes"| SVC
    SC -->|"executes"| RMC
    SC -->|"executes"| RGC
    SC -->|"executes"| LNGC
    SC -->|"executes"| THVC
    SC -->|"executes"| HVC

    SF -->|"creates"| GSP
    SF -->|"creates"| JSP
    SF -->|"creates"| SSP

    TC -->|"appliesVisitor"| STV
    TC -->|"appliesVisitor"| SPV
    TC -->|"appliesVisitor"| RTV

    GS -->|"notifies"| SV

    %% UI Components Relationship within View
    SV -->|"manages"| IP
    SV -->|"manages"| TL
    SV -->|"manages"| HN
    SV -->|"manages"| SMB
    SV -->|"manages"| SFC
    SV -->|"manages"| SGP
    SV -->|"manages"| BCV
    SV -->|"manages"| ECV
    SV -->|"manages"| SCV

    %% Click Events for User Interface
    click SV "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/view/SudokuView.java"
    click IP "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/view/informationpane/InformationPane.java"
    click TL "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/view/informationpane/TimerLabel.java"
    click HN "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/view/informationpane/HelpNumbersPane.java"
    click SMB "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/view/menubar/SudokuMenuBar.java"
    click SFC "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/view/menubar/SudokuFileChooser.java"
    click SGP "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/view/sudoko/SudokuGridPane.java"
    click BCV "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/view/sudoko/cell/BaseCellView.java"
    click ECV "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/view/sudoko/cell/EmptyCellView.java"
    click SCV "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/view/sudoko/cell/SudokuCellView.java"

    %% Click Event for Controller
    click SC "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/controller/SudokuController.java"

    %% Click Events for Model
    click C "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/model/Cell.java"
    click GS "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/model/GameState.java"
    click SU "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/model/Sudoku.java"
    click VG "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/model/ValidatorGroup.java"

    %% Click Events for Command Module
    click IC "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/command/ICommand.java"
    click SVC "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/command/SetValueCommand.java"
    click RMC "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/command/RemoveValueCommand.java"
    click RGC "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/command/RestartGameCommand.java"
    click LNGC "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/command/LoadNewGameCommand.java"
    click THVC "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/command/ToggleHulpValueCommand.java"
    click HVC "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/command/HulpValueCommand.java"

    %% Click Events for Factory and Parser Module
    click SF "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/factory/SudokuFactory.java"
    click ISP "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/factory/parser/ISudokuParser.java"
    click GSP "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/factory/parser/GeneralSudokuParser.java"
    click JSP "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/factory/parser/JigsawSudokuParser.java"
    click SSP "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/factory/parser/SamuraiSudokuParser.java"

    %% Click Events for Timer Module
    click ITC "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/timer/ITimerComponent.java"
    click ITV "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/timer/ITimerVisitor.java"
    click ST "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/timer/SimpleTimer.java"
    click TC "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/timer/TimerComposite.java"
    click STV "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/timer/StartTimerVisitor.java"
    click SPV "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/timer/StopTimerVisitor.java"
    click RTV "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/timer/ResetTimerVisitor.java"

    %% Click Event for Utility
    click TU "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/util/TimeUtil.java"

    %% Click Events for Resources
    click CSS "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/resources/styles.css"
    click PF "https://github.com/normaalbart/dpat-sudoko/tree/main/sudokos/"

    %% Click Event for Application Entry Point
    click ME "https://github.com/normaalbart/dpat-sudoko/blob/main/src/main/java/org/avans/sudoku/Main.java"

    %% Styles
    classDef view fill:#FFA500,stroke:#333,stroke-width:2px;
    classDef controller fill:#1E90FF,stroke:#333,stroke-width:2px;
    classDef model fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef command fill:#DA70D6,stroke:#333,stroke-width:2px;
    classDef factory fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef timer fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef utility fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef resource fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef entry fill:#E0FFFF,stroke:#333,stroke-width:2px;
```
