# jukisyuri/bookstore_projectctdl architecture

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

- Interactive diagram: https://gitdiagram.com/jukisyuri/bookstore_projectctdl
- Repository: https://github.com/jukisyuri/bookstore_projectctdl

## Overview

##### Main Components
- Data Layer:
- Data Files: Represented by the text files (e.g., customer_account.txt, listbook.txt) in the src/data directory.
- File I/O Utilities: Include FileLoader.java and FileWriter.java for reading and writing data.
- Business Logic Layer (Model):
- Domain Models: Classes like Book.java, Customer.java, Order.java.
- Managers: Classes managing domain logic such as BookManager.java, CustomerManager.java, OrderManager.java, and OrderBook.java.
- Central System Logic: MainSystem.java, Model.java, and IModel.java which likely define the core interactions and contracts between the various model components.
- Utility Components:
- Additional Helpers: AnalyzeDate.java for date formatting/validation, TextPrompt.java, and even ToolRandomAccount.js (an external helper script/tool) that might be used to generate random account-related data.
- Presentation Layer (View):
- GUI Components: The view is built with Java Swing. This includes MainFrame.java as the main container and specific panels (BookManagerPanel.java, BookStoreManagerPanel.java, CustomerManagerPanel.java, OrderManagerPanel.java) that provide the user interface for each module.

##### Relationships and Interactions
- The Presentation layer (views) interacts with the Business Logic layer (model) to perform actions such as adding, editing, or deleting books, customers, and orders. For instance, button actions on BookManagerPanel trigger updates via BookManager.java.
- The Business Logic layer uses Utility methods (FileLoader/FileWriter) to persist and retrieve data from the text files in the Data layer.
- The central MainSystem.java likely coordinates the overall flow between the GUI and the underlying model, ensuring that user actions are correctly processed and changes are stored.

##### Architectural Patterns and Design Principles
- Layered Architecture: Clearly separating presentation (Swing views), business logic (models and managers), and data (text files).
- MVC-Like Approach: Although there isn’t an explicit controller directory, the MainSystem component acts as a coordination hub between the view and model. The panels act as views while model classes encapsulate the business logic.
- Single Responsibility: Each component (e.g., FileWriter, FileLoader, model managers) is designated for specific tasks, ensuring clear separation of concerns.

##### Technologies and Frameworks
- Programming Language: Java.
- GUI Framework: Java Swing.
- Data Persistence: Simple text file storage.
- Additional Scripts: Inclusion of a JavaScript file (ToolRandomAccount.js) which might be used for generating random account data, suggesting a utility role external to the Java main application.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        MF["MainFrame"]:::view
        BMP["BookManagerPanel"]:::view
        BSMP["BookStoreManagerPanel"]:::view
        CMP["CustomerManagerPanel"]:::view
        OMP["OrderManagerPanel"]:::view
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        subgraph "Domain Models"
            B["Book"]:::model
            C["Customer"]:::model
            O["Order"]:::model
        end
        subgraph "Manager Classes"
            BM["BookManager"]:::model
            CM["CustomerManager"]:::model
            OM["OrderManager"]:::model
            OB["OrderBook"]:::model
        end
        subgraph "Central System Logic"
            MS["MainSystem"]:::model
            M["Model"]:::model
            IM["IModel"]:::model
        end
    end

    %% Utility Components & File I/O
    subgraph "Utility Components"
        AD["AnalyzeDate"]:::utility
        TP["TextPrompt"]:::utility
        TRA["ToolRandomAccount"]:::utility
        FL["FileLoader"]:::data
        FW["FileWriter"]:::data
    end

    %% Data Layer
    subgraph "Data Layer"
        CA["Customer Account Data"]:::data
        LB["Book List Data"]:::data
    end

    %% Presentation interactions
    MF -->|"contains"| BMP
    MF -->|"contains"| BSMP
    MF -->|"contains"| CMP
    MF -->|"contains"| OMP
    MF -->|"coordinates"| MS
    BMP -->|"triggers"| BM
    BSMP -->|"triggers"| BM
    CMP -->|"triggers"| CM
    OMP -->|"triggers"| OM

    %% Business Logic interactions
    BM -->|"manages"| B
    CM -->|"manages"| C
    OM -->|"manages"| O
    OB -->|"associates"| O
    OB -->|"associates"| B
    MS -->|"coordinates"| BM
    MS -->|"coordinates"| CM
    MS -->|"coordinates"| OM
    MS -->|"coordinates"| OB
    MS --> M
    M --> IM

    %% Manager usage of File I/O utilities
    BM -->|"uses"| FL
    BM -->|"uses"| FW
    CM -->|"uses"| FL
    CM -->|"uses"| FW
    OM -->|"uses"| FL
    OM -->|"uses"| FW
    OB -->|"uses"| FL
    OB -->|"uses"| FW

    %% File I/O utilities interaction with Data Files
    FL -->|"reads"| CA
    FL -->|"reads"| LB
    FW -->|"writes"| CA
    FW -->|"writes"| LB

    %% Utility support interactions
    OM -->|"validatesDate"| AD
    MF -->|"prompts"| TP
    CM -->|"generates"| TRA

    %% Styles
    classDef view fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef model fill:#ABEBC6,stroke:#229954,stroke-width:2px;
    classDef utility fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef data fill:#F5B7B1,stroke:#922B21,stroke-width:2px;

    %% Click Events for Presentation Layer
    click MF "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/view/MainFrame.java"
    click BMP "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/view/BookManagerPanel.java"
    click BSMP "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/view/BookStoreManagerPanel.java"
    click CMP "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/view/CustomerManagerPanel.java"
    click OMP "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/view/OrderManagerPanel.java"

    %% Click Events for Business Logic Layer
    click B "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/model/Book.java"
    click C "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/model/Customer.java"
    click O "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/model/Order.java"
    click BM "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/model/BookManager.java"
    click CM "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/model/CustomerManager.java"
    click OM "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/model/OrderManager.java"
    click OB "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/model/OrderBook.java"
    click MS "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/model/MainSystem.java"
    click M "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/model/Model.java"
    click IM "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/model/IModel.java"

    %% Click Events for Utility Components & File I/O
    click AD "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/util/AnalyzeDate.java"
    click TP "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/util/TextPrompt.java"
    click TRA "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/util/ToolRandomAccount.js"
    click FL "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/util/FileLoader.java"
    click FW "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/util/FileWriter.java"

    %% Click Events for Data Layer
    click CA "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/data/customer_account.txt"
    click LB "https://github.com/jukisyuri/bookstore_projectctdl/blob/main/src/data/listbook.txt"
```
