# kleitusoleny/bookstore_projectctdl architecture

> Architecture diagram of the GitHub repository kleitusoleny/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/kleitusoleny/bookstore_projectctdl
- Repository: https://github.com/kleitusoleny/bookstore_projectctdl

## Overview

##### Project Type and Purpose
- This is a desktop (Java Swing-based) application for managing a book sales system. It’s a mid-term project for a Data Structures course and is titled “Ứng Dụng Quản Lí Bán Sách.”
- Its purpose is to manage book inventories, customer records, and orders, providing a graphical user interface to perform these operations.

##### Analyzing the File Structure
- The top-level directories are structured as follows:
- src/data: Contains data files (such as acc.txt and listbook.txt) used for persistent storage.
- src/model: Contains domain models and business logic. Key classes include Book, Customer, Order, and their corresponding manager classes (e.g., BookManager, CustomerManager, OrderManager), as well as an interface (IModel) and central system classes (Model, MainSystem).
- src/util: Provides utility classes for file operations (FileLoader and FileWriter) to read and write external data.
- src/view: Contains GUI components (e.g., panels for book management, customer management, order management, and a MainFrame for launching the application).
- Notice the separation of concerns (data, model/business logic, utilities, and view), which is an important architectural principle.

##### Elements
- MainFrame (Entry point in src/view)
- BookManagerPanel, CustomerManagerPanel, OrderManagerPanel (GUI Components)
- BookManager, CustomerManager, OrderManager, MainSystem (Business Logic)
- FileLoader, FileWriter (Utility Layer)
- Data Files (acc.txt, listbook.txt in src/data)
- From MainFrame to various panels.
- From panels to their corresponding manager classes.
- From manager classes to utility classes and data files.
- UI elements (rectangles with rounded edges for views),
- Business logic components,
- Utility classes,

## Diagram (Mermaid)

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

    %% Business Logic (Model)
    subgraph "Business Logic (Model)"
        BM["BookManager"]:::model
        CM["CustomerManager"]:::model
        OM["OrderManager"]:::model
        MS["MainSystem"]:::model
        IM["IModel"]:::model
        M["Model"]:::model
    end

    %% Utilities for File I/O
    subgraph "Utilities"
        FL["FileLoader"]:::util
        FW["FileWriter"]:::util
    end

    %% Data Storage
    subgraph "Data Storage"
        DS["Data Files (acc.txt, listbook.txt)"]:::data
    end

    %% Presentation to Business Logic Connections
    MF -->|"orchestrates"| BMP
    MF -->|"orchestrates"| CMP
    MF -->|"orchestrates"| OMP
    MF -->|"orchestrates"| BSMP

    BMP -->|"calls"| BM
    CMP -->|"calls"| CM
    OMP -->|"calls"| OM
    BSMP -->|"calls"| MS

    %% Internal Business Logic Relationships
    MS -->|"uses"| M
    M  -->|"implements"| IM

    %% Business Logic to Utilities Connections
    BM -->|"calls_IO"| FL
    BM -->|"calls_IO"| FW

    CM -->|"calls_IO"| FL
    CM -->|"calls_IO"| FW

    OM -->|"calls_IO"| FL
    OM -->|"calls_IO"| FW

    MS -->|"calls_IO"| FL
    MS -->|"calls_IO"| FW

    %% Utilities to Data Storage Connections
    FL -->|"reads/writes_to"| DS
    FW -->|"reads/writes_to"| DS

    %% Click Events
    click MF "https://github.com/kleitusoleny/bookstore_projectctdl/blob/main/src/view/MainFrame.java"
    click BMP "https://github.com/kleitusoleny/bookstore_projectctdl/blob/main/src/view/BookManagerPanel.java"
    click CMP "https://github.com/kleitusoleny/bookstore_projectctdl/blob/main/src/view/CustomerManagerPanel.java"
    click OMP "https://github.com/kleitusoleny/bookstore_projectctdl/blob/main/src/view/OrderManagerPanel.java"
    click BSMP "https://github.com/kleitusoleny/bookstore_projectctdl/blob/main/src/view/BookStoreManagerPanel.java"
    click BM "https://github.com/kleitusoleny/bookstore_projectctdl/blob/main/src/model/BookManager.java"
    click CM "https://github.com/kleitusoleny/bookstore_projectctdl/blob/main/src/model/CustomerManager.java"
    click OM "https://github.com/kleitusoleny/bookstore_projectctdl/blob/main/src/model/OrderManager.java"
    click MS "https://github.com/kleitusoleny/bookstore_projectctdl/blob/main/src/model/MainSystem.java"
    click IM "https://github.com/kleitusoleny/bookstore_projectctdl/blob/main/src/model/IModel.java"
    click M "https://github.com/kleitusoleny/bookstore_projectctdl/blob/main/src/model/Model.java"
    click FL "https://github.com/kleitusoleny/bookstore_projectctdl/blob/main/src/util/FileLoader.java"
    click FW "https://github.com/kleitusoleny/bookstore_projectctdl/blob/main/src/util/FileWriter.java"
    click DS "https://github.com/kleitusoleny/bookstore_projectctdl/tree/main/src/data"

    %% Styles
    classDef view fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef model fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef util fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef data fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
```
