# nguyendatgh/quizz_javafx architecture

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

- Interactive diagram: https://gitdiagram.com/nguyendatgh/quizz_javafx
- Repository: https://github.com/nguyendatgh/quizz_javafx

## Overview

##### Project Type and Purpose
- The project is a Java application managed with Maven. It appears to be a quiz application, with distinct UI screens (FXML files) and corresponding controllers. The presence of files like home.fxml, quizMain.fxml, quizResult.fxml, and quizReview.fxml alongside controllers (e.g., HomeController, QuizController, QuizResultController, QuizReviewController) indicates an application that transitions between various states (home, quiz, review, result).
- Additionally, there’s a data source (data.json) that is likely used to load quiz content, and model classes (Quiz and Question) that represent the domain entities.

##### Analyzing the File Structure
- Top-Level Structure:
- The pom.xml and setup.sh indicate Maven is used to build and run the project.
- The src directory follows the standard Maven layout (src/main/java for code, src/main/resources for configurations and view files).
- Key Components:
- The “Main.java” acts as the application bootstrapper.
- The “controller” package contains various controllers handling different UI events / navigation.
- The “model” package provides the domain models, which represent the quiz and its questions.
- The “resources” folder includes FXML files and images that build the visual aspects via JavaFX.
- The “data.json” file under resources is used as a data source for the quiz questions.

a. Main Components:
– Application Entry Point: Main.java
– UI Layer:
- FXML Files (home.fxml, quizMain.fxml, quizResult.fxml, quizReview.fxml)
- Controllers (HomeController, QuizController, QuizResultController, QuizReviewController) that manage the UI logic and user interactions.
– Business/Domain Layer:
- Model Classes (Quiz, Question) representing the quiz data structure.
– Data Layer:
- The data.json file, which provides quiz data.
– Build & Dependency Management:
- Maven (pom.xml) as the project build and dependency management tool.
– Additional: The demo folder can be represented as a supplementary or example module that might show sample usage or demonstration images.

b. Relationships and Interactions:
– The Main.java component launches the application and loads the UI.
– UI Components: Controllers interact with both the FXML-defined views and the business logic; they retrieve model data (such as quiz questions) possibly by reading from data.json.
– Data Flow: Data flows from the JSON resource through the domain model classes to the controllers and then to the user interface.
– Maven is used to compile, package, and manage dependencies throughout.

c. Architectural Patterns and Design Principles:
– MVC Pattern: The use of FXML for view definition, controllers for handling user logic, and models for representing data suggests an MVC (Model-View-Controller) pattern.
– Separation of Concerns: Each component is divided into clear responsibilities (UI, logic, data).
– Modularization: The directory structure supports separation between presentation and business/data layers.

d. Relevant Technologies & Frameworks:
– Java and JavaFX (implied by FXML files and controller packages).
– Maven for build management.
– JSON for data storage.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Entry
    subgraph "Application Entry"
        Main("Main.java (Entry Point)"):::bootstrap
    end

    %% UI Layer
    subgraph "UI Layer"
        direction TB
        HomeFXML("home.fxml (Home Screen)"):::ui
        HomeCtrl("HomeController"):::ui
        QuizMainFXML("quizMain.fxml (Quiz Screen)"):::ui
        QuizCtrl("QuizController"):::ui
        QuizResultFXML("quizResult.fxml (Result Screen)"):::ui
        QuizResultCtrl("QuizResultController"):::ui
        QuizReviewFXML("quizReview.fxml (Review Screen)"):::ui
        QuizReviewCtrl("QuizReviewController"):::ui
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        QuizModel("Quiz Model"):::domain
        QuestionModel("Question Model"):::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        Data("data.json"):::data
    end

    %% Build & Management
    subgraph "Build & Management"
        direction TB
        Maven("Maven (pom.xml)"):::build
        Setup("setup.sh"):::build
    end

    %% Supplementary
    subgraph "Supplementary"
        Demo("Demo Folder"):::demo
    end

    %% Connections
    Main -->|"initializes"| HomeFXML

    HomeFXML -- "binds" --> HomeCtrl

    QuizMainFXML -- "binds" --> QuizCtrl
    QuizResultFXML -- "binds" --> QuizResultCtrl
    QuizReviewFXML -- "binds" --> QuizReviewCtrl

    %% Data interactions
    QuizCtrl -->|"loads"| Data
    Data -->|"populates"| QuizModel
    Data -->|"populates"| QuestionModel
    QuizCtrl -->|"uses"| QuizModel
    QuizCtrl -->|"uses"| QuestionModel

    %% Build interactions
    Setup -->|"triggers build"| Maven
    Maven -->|"builds"| Main
    Maven -->|"bundles"| Data
    Maven -->|"packages"| QuizModel
    Maven -->|"packages"| QuestionModel

    %% Styles
    classDef bootstrap fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef ui fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef domain fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef data fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef build fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef demo fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;

    %% Click Events
    click Main "https://github.com/nguyendatgh/quizz_javafx/blob/main/src/main/java/com/example/Main.java"
    click HomeFXML "https://github.com/nguyendatgh/quizz_javafx/blob/main/src/main/resources/home.fxml"
    click QuizMainFXML "https://github.com/nguyendatgh/quizz_javafx/blob/main/src/main/resources/quizMain.fxml"
    click QuizResultFXML "https://github.com/nguyendatgh/quizz_javafx/blob/main/src/main/resources/quizResult.fxml"
    click QuizReviewFXML "https://github.com/nguyendatgh/quizz_javafx/blob/main/src/main/resources/quizReview.fxml"
    click HomeCtrl "https://github.com/nguyendatgh/quizz_javafx/blob/main/src/main/java/com/example/controller/HomeController.java"
    click QuizCtrl "https://github.com/nguyendatgh/quizz_javafx/blob/main/src/main/java/com/example/controller/QuizController.java"
    click QuizResultCtrl "https://github.com/nguyendatgh/quizz_javafx/blob/main/src/main/java/com/example/controller/QuizResultController.java"
    click QuizReviewCtrl "https://github.com/nguyendatgh/quizz_javafx/blob/main/src/main/java/com/example/controller/QuizReviewController.java"
    click QuizModel "https://github.com/nguyendatgh/quizz_javafx/blob/main/src/main/java/com/example/model/Quiz.java"
    click QuestionModel "https://github.com/nguyendatgh/quizz_javafx/blob/main/src/main/java/com/example/model/Question.java"
    click Data "https://github.com/nguyendatgh/quizz_javafx/blob/main/src/main/resources/data.json"
    click Maven "https://github.com/nguyendatgh/quizz_javafx/blob/main/pom.xml"
    click Setup "https://github.com/nguyendatgh/quizz_javafx/blob/main/setup.sh"
    click Demo "https://github.com/nguyendatgh/quizz_javafx/tree/main/demo"
```
