# lamkhanh05/project-slang-word architecture

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

- Interactive diagram: https://gitdiagram.com/lamkhanh05/project-slang-word
- Repository: https://github.com/lamkhanh05/project-slang-word

## Overview

##### Project type and purpose
- This is a standalone JavaFX desktop application for managing and quizzing on “slang words.”
- It follows an MVC-style pattern (Model, View, Controller) with a DAO layer for data access and a service layer for business logic.

##### High-level file-structure analysis
- Top-level directories:
- data/ — persistent storage files (slang.txt, slang.dat, DAMH#1.pdf)
- src/ — application source code, subdivided into dao, model, service, view, and main packages
- Key packages:
- dao — SlangDAO.java interacts with data files
- model — SlangWord.java and QuizQuestion.java define core domain objects
- service — SlangService.java implements business logic (lookup, quiz generation, scoring)
- view — MainView.fxml, MainViewController.java, style.css define the UI layer via JavaFX
- main — MainApp.java bootstraps the JavaFX application

##### Core components
a. User Interface (View + Controller)
– MainView.fxml (layout)
– MainViewController (event handlers, input validation)
b. Application Layer
– MainApp (JavaFX Application lifecycle: init → start → stop)
c. Business Logic Layer
– SlangService (business rules: search, random quiz, scoring)
d. Data Access Layer
– SlangDAO (CRUD‐style access to slang.txt / slang.dat)
– data/ directory (source files, optional PDF documentation)
e. Data Models
– SlangWord (fields: word, definitions, history)
– QuizQuestion (question text, options, correct answer)

##### Relationships and interactions
- MainApp initializes the JavaFX runtime and loads MainView.fxml
→ Instantiates MainViewController
- MainViewController handles user events (e.g., “Search,” “Start Quiz”)
→ Delegates to SlangService
- SlangService applies business logic
→ Calls SlangDAO for data reads/writes
- SlangDAO reads from/writes to files in the data/ directory
- Service returns model objects (SlangWord, QuizQuestion) back to controller
- Controller updates the View (JavaFX scene graph)

##### Architectural patterns and principles
- MVC: clear separation between View (FXML + CSS), Controller (JavaFX event handlers), Model (POJOs)
- DAO pattern: abstract data‐file operations behind SlangDAO
- Service layer: isolates business logic from both UI and data access
- Convention over configuration: uses package layout and JavaFX defaults to reduce boilerplate

##### Relevant technologies/frameworks
- Java 8+ / OpenJDK
- JavaFX (FXML, Scene Builder conventions)
- CSS for styling
- Plain text / serialized data files (slang.txt, slang.dat)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Application Layer
    subgraph "Application Layer"
        direction TB
        MainApp["MainApp\n(JavaFX lifecycle)"]:::app
    end

    %% UI Layer
    subgraph "UI Layer"
        direction TB
        MainViewFXML["MainView.fxml\n(View Layout)"]:::ui
        StyleCSS["style.css\n(UI Styling)"]:::ui
    end

    %% Controller Layer
    subgraph "Controller Layer"
        direction TB
        MainViewController["MainViewController.java\n(Event Handlers)"]:::controller
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        SlangService["SlangService.java\n(Business Logic)"]:::service
    end

    %% DAO Layer
    subgraph "DAO Layer"
        direction TB
        SlangDAO["SlangDAO.java\n(Data Access)"]:::dao
    end

    %% Data Model
    subgraph "Domain Model"
        direction TB
        SlangWord["SlangWord.java\n(Domain Model)"]:::model
        QuizQuestion["QuizQuestion.java\n(Domain Model)"]:::model
    end

    %% Data Store
    subgraph "Data Store"
        direction TB
        SlangTXT["slang.txt"]:::data
        SlangDAT["slang.dat"]:::data
        DAMHPDF["DAMH#1.pdf"]:::data
    end

    %% Relationships
    MainApp -->|loads FXML| MainViewFXML
    MainApp -->|initializes controller| MainViewController
    MainViewFXML -->|uses style| StyleCSS
    MainViewController -->|delegates to| SlangService
    SlangService -->|uses| SlangDAO
    SlangService -->|returns models| SlangWord
    SlangService -->|returns models| QuizQuestion
    SlangDAO -->|reads/writes| SlangTXT
    SlangDAO -->|reads/writes| SlangDAT
    SlangDAO -->|references doc| DAMHPDF
    MainViewController -->|updates view| MainViewFXML

    %% Click Events
    click MainApp "https://github.com/lamkhanh05/project-slang-word/blob/main/src/main/MainApp.java"
    click MainViewFXML "https://github.com/lamkhanh05/project-slang-word/blob/main/src/view/MainView.fxml"
    click StyleCSS "https://github.com/lamkhanh05/project-slang-word/blob/main/src/view/style.css"
    click MainViewController "https://github.com/lamkhanh05/project-slang-word/blob/main/src/view/MainViewController.java"
    click SlangService "https://github.com/lamkhanh05/project-slang-word/blob/main/src/service/SlangService.java"
    click SlangDAO "https://github.com/lamkhanh05/project-slang-word/blob/main/src/dao/SlangDAO.java"
    click SlangTXT "https://github.com/lamkhanh05/project-slang-word/blob/main/data/slang.txt"
    click SlangDAT "https://github.com/lamkhanh05/project-slang-word/blob/main/data/slang.dat"
    click DAMHPDF "https://github.com/lamkhanh05/project-slang-word/blob/main/data/DAMH#1.pdf"
    click SlangWord "https://github.com/lamkhanh05/project-slang-word/blob/main/src/model/SlangWord.java"
    click QuizQuestion "https://github.com/lamkhanh05/project-slang-word/blob/main/src/model/QuizQuestion.java"

    %% Styles
    classDef app fill:#EFEFFF,stroke:#8888FF,stroke-width:1px
    classDef ui fill:#CCEEFF,stroke:#3399FF,stroke-width:1px
    classDef controller fill:#AEDFFF,stroke:#0066CC,stroke-width:1px
    classDef service fill:#CFFFCF,stroke:#33AA33,stroke-width:1px
    classDef dao fill:#FFD0A2,stroke:#FF9900,stroke-width:1px
    classDef model fill:#E0CCFF,stroke:#9933CC,stroke-width:1px
    classDef data fill:#FFEECC,stroke:#CC9900,stroke-width:1px
```
