# oskarowski/sudoku-desktop-game architecture

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

- Interactive diagram: https://gitdiagram.com/oskarowski/sudoku-desktop-game
- Repository: https://github.com/oskarowski/sudoku-desktop-game

## Overview

##### Project type and purpose
- This is a multi-module Maven project implementing a desktop Sudoku game with an MVC pattern and JavaFX UI.
- Modules:
- View – JavaFX GUI, controllers, user interactions, save/load strategies
- Model – core domain (board, solver, validation)
- Dao – file-based DAO implementation
- JdbcDao – JDBC/SQLite-based DAO implementation

##### File structure
- Top-level `pom.xml` aggregates 4 submodules: View, Model, Dao, JdbcDao.
- View
- `App.java`, controllers (`GameController`, `MainMenuController`), strategy interfaces/implementations for saving/loading.
- Model
- Domain objects (`SudokuBoard`, rows, columns, fields), solver (`BacktrackingSudokuSolver`), validation, exceptions, ResourceBundle for messages.
- Dao
- Generic DAO interface, file-based implementation (`FileSudokuBoardDao`), factory (`SudokuBoardDaoFactory`), read/write exceptions, logging.
- JdbcDao
- JDBC DAO (`JdbcSudokuBoardDao`), schema init, SQLite schema SQL, localized exception messages, connection/transaction exceptions.
- Tests in each module use JUnit Jupiter.

##### README for additional insights
- Confirms MVC, JavaFX, strategies for “Save to File” vs “Save to DB.”
- Dependencies: JOOQ, SQLite, SLF4J/Logback, JavaFX.

a. Main components
- Presentation Layer (View module)
- Domain Layer (Model module)
- Persistence Layer – File DAO (Dao module)
- Persistence Layer – JDBC DAO (JdbcDao module)
- External systems: File System, SQLite DB
- Infrastructure: Logging (SLF4J/Logback), i18n (ResourceBundle)
b. Relationships & interactions
- User → JavaFX View → Controllers
- Controllers ↔ Domain objects (create/validate/solve boards)
- Controllers use Save/Load Strategies → DAO factory → chosen DAO
- File DAO ↔ File System (object serialization)
- JDBC DAO ↔ SQLite DB (via JOOQ/JDBC)
- Model and DAO modules throw localised exceptions caught/logged by View
c. Architectural patterns & design principles
- MVC (View/controllers – Model – no separate Service layer)
- Strategy (SaveSudokuBoardStrategy / SaveSudokuBoardToFileStrategy / SaveSudokuBoardToDatabaseStrategy)
- Factory (SudokuBoardDaoFactory)
- Layered architecture: Presentation → Domain → Persistence
- Single Responsibility (each module focuses on one concern)
d. Key technologies/frameworks
- JavaFX (UI), FXML, ResourceBundle (i18n)
- Maven multi-module
- SLF4J + Logback (logging)
- JUnit Jupiter + JaCoCo (testing & coverage)
- SQLite + JOOQ/JDBC (DB access)
- Java Serialization (file-based DAO)

##### Elements
- from User → View
- View → Model
- View → Strategy → DaoFactory → (FileDao or JdbcDao)
- FileDao → File System
- JdbcDao → SQLite DB
- Blue for UI components
- Green for domain logic
- Orange for persistence
- Grey for external systems

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Maven Aggregator
    subgraph "Multi-module Maven Project"
        direction TB
        %% Presentation Layer
        subgraph "Presentation Layer (View Module)" 
            direction TB
            App["App"]:::ui
            Controllers["Controllers"]:::ui
            SubgraphFxml["FXMLLayouts"]:::ui
            Strategies["Save/Load Strategies"]:::ui
            Bundles["ResourceBundles"]:::infra
        end

        %% Domain Layer
        subgraph "Domain Layer (Model Module)"
            direction TB
            BoardModel["SudokuBoard & Components"]:::domain
            Solver["BacktrackingSudokuSolver"]:::domain
            Validation["Validation & Helpers"]:::domain
            ModelExceptions["Model Exceptions"]:::infra
        end

        %% Persistence Layer - File DAO
        subgraph "Persistence Layer - File DAO (Dao Module)"
            direction TB
            DaoInterface["DAO Interface"]:::persistence
            FileDao["FileSudokuBoardDao"]:::persistence
            DaoFactory["SudokuBoardDaoFactory"]:::persistence
            DaoExceptions["DAO Exceptions"]:::infra
        end

        %% Persistence Layer - JDBC DAO
        subgraph "Persistence Layer - JDBC DAO (JdbcDao Module)"
            direction TB
            JdbcDaoImpl["JdbcSudokuBoardDao"]:::persistence
            SchemaInit["SchemaInitializer"]:::persistence
            DbSchema["schema.sql"]:::persistence
            JdbcExceptions["JDBC Exceptions"]:::infra
        end

        %% External Systems
        subgraph "External Systems"
            direction TB
            FileSystem["File System"]:::external
            SQLiteDB["SQLite Database"]:::external
        end
    end

    %% User Interaction
    User["User"]:::external
    User -->|"launches"| App
    App -->|"initializes UI"| Controllers
    Controllers -->|"loads FXML"| SubgraphFxml
    Controllers -->|"uses strategies"| Strategies
    Controllers -->|"interacts with domain"| BoardModel
    Controllers -->|"calls solve/validate"| Solver
    Controllers -->|"validates input"| Validation
    Controllers -->|"catches exceptions"| ModelExceptions

    Strategies -->|"selects DAO"| DaoFactory
    DaoFactory -->|"provides File DAO"| FileDao
    DaoFactory -->|"provides JDBC DAO"| JdbcDaoImpl

    FileDao -->|"serializes data"| FileSystem
    JdbcDaoImpl -->|"executes SQL"| SQLiteDB
    JdbcDaoImpl -->|"initializes schema"| SchemaInit
    JdbcDaoImpl -->|"reads schema"| DbSchema
    FileDao -->|"throws"| DaoExceptions
    JdbcDaoImpl -->|"throws"| JdbcExceptions
    ModelExceptions -->|"logged by"| App
    DaoExceptions -->|"logged by"| App
    JdbcExceptions -->|"logged by"| App

    %% Click Events
    click App "https://github.com/oskarowski/sudoku-desktop-game/blob/master/View/src/main/java/sudoku/view/App.java"
    click Controllers "https://github.com/oskarowski/sudoku-desktop-game/tree/master/View/src/main/java/sudoku/view"
    click SubgraphFxml "https://github.com/oskarowski/sudoku-desktop-game/blob/master/View/src/main/resources/sudoku/view/MainMenu.fxml"
    click Strategies "https://github.com/oskarowski/sudoku-desktop-game/tree/master/View/src/main/java/sudoku/view/strategies"
    click Bundles "https://github.com/oskarowski/sudoku-desktop-game/blob/master/View/src/main/resources/sudoku/view/bundles/en_EN.properties"
    click BoardModel "https://github.com/oskarowski/sudoku-desktop-game/blob/master/Model/src/main/java/sudoku/model/models/SudokuBoard.java"
    click Solver "https://github.com/oskarowski/sudoku-desktop-game/blob/master/Model/src/main/java/sudoku/model/solver/BacktrackingSudokuSolver.java"
    click Validation "https://github.com/oskarowski/sudoku-desktop-game/blob/master/Model/src/main/java/sudoku/model/helpers/UniqueChecker.java"
    click ModelExceptions "https://github.com/oskarowski/sudoku-desktop-game/tree/master/Model/src/main/java/sudoku/model/exceptions"
    click DaoInterface "https://github.com/oskarowski/sudoku-desktop-game/blob/master/Dao/src/main/java/sudoku/dao/interfaces/Dao.java"
    click FileDao "https://github.com/oskarowski/sudoku-desktop-game/blob/master/Dao/src/main/java/sudoku/dao/models/FileSudokuBoardDao.java"
    click DaoFactory "https://github.com/oskarowski/sudoku-desktop-game/blob/master/Dao/src/main/java/sudoku/dao/factories/SudokuBoardDaoFactory.java"
    click DaoExceptions "https://github.com/oskarowski/sudoku-desktop-game/tree/master/Dao/src/main/java/sudoku/dao/exceptions"
    click JdbcDaoImpl "https://github.com/oskarowski/sudoku-desktop-game/blob/master/JdbcDao/src/main/java/sudoku/jdbcdao/JdbcSudokuBoardDao.java"
    click SchemaInit "https://github.com/oskarowski/sudoku-desktop-game/blob/master/JdbcDao/src/main/java/sudoku/jdbcdao/SchemaInitializer.java"
    click DbSchema "https://github.com/oskarowski/sudoku-desktop-game/blob/master/JdbcDao/src/main/java/sudoku/jdbcdao/database/schema.sql"
    click JdbcExceptions "https://github.com/oskarowski/sudoku-desktop-game/tree/master/JdbcDao/src/main/java/sudoku/jdbcdao/exceptions"

    %% Styles
    classDef ui fill:#B3CDE0,stroke:#333,stroke-width:1px,color:#000
    classDef domain fill:#CCEBC5,stroke:#333,stroke-width:1px,color:#000
    classDef persistence fill:#FBB4AE,stroke:#333,stroke-width:1px,color:#000
    classDef external fill:#D9D9D9,stroke:#333,stroke-width:1px,color:#000
    classDef infra fill:#DECBE4,stroke:#333,stroke-width:1px,color:#000
```
