# hanlinag/point-of-sale-system architecture

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

- Interactive diagram: https://gitdiagram.com/hanlinag/point-of-sale-system
- Repository: https://github.com/hanlinag/point-of-sale-system

## Overview

##### Project type and purpose
- This is a standalone desktop Point-of-Sale (PoS) application implemented in Java using the MVC pattern.
- It serves two user roles: Admin (inventory, reporting, user management) and Cashier (selling items, card payments).
- It uses JavaFX (with JFoenix) for UI, MySQL for persistence, JasperReports for report generation, and supports barcode/QR scanning via a TCP-based Android scanner.

##### File structure
Top-level artifacts
- JAR libraries (JavaFX, JFoenix, JDBC, JasperReports, Apache Commons, POI libraries, XML Beans)
- UCSMPOS.sql (schema)
- enduserguide.pdf, README.md, LICENSE

src/ directory (MVC + utilities)
- /common – shared helpers (Common.java)
- /controller – JavaFX controllers (one per FXML view)
- /database – DAO/connection utilities (ConnectionUtils, MySQLConnUtils, DBInitialize)
- /functs – business utilities and helpers (QRReceiveData, ReportGenerator, EditingCell, SearchBarcode)
- /model – domain objects (ProductItem, Sale, CardUser, etc.)
- /ui – FXML view files (Admin_panel.fxml, Page_login.fxml, cashier_main.fxml, etc.)
- /jaspertemplate – .jrxml/.jasper report definitions
- /major – application entry points (Login.java, MainAdmin.java, MainCashier.java)

##### README for additional insights
- Confirms MVC design.
- Highlights core modules: Admin panel (inventory, categories, customers, suppliers, promotions, charts/reports) vs. Cashier panel (sales, card redemption/creation).
- External Android scanner pushes barcode/QR over TCP.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Application Entry Points
    subgraph "Application Entry"
        LoginEP["Login.java"]:::entry
        click LoginEP "https://github.com/hanlinag/point-of-sale-system/blob/master/src/major/Login.java"
        MainAdminEP["MainAdmin.java"]:::entry
        click MainAdminEP "https://github.com/hanlinag/point-of-sale-system/blob/master/src/major/MainAdmin.java"
        MainCashierEP["MainCashier.java"]:::entry
        click MainCashierEP "https://github.com/hanlinag/point-of-sale-system/blob/master/src/major/MainCashier.java"
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["JavaFX UI\n(src/ui/*.fxml)"]:::presentation
    end
    click UI "https://github.com/hanlinag/point-of-sale-system/tree/master/src/ui/"

    %% Controller Layer
    subgraph "Controller Layer"
        LoginCtrl["LoginController.java"]:::controller
        click LoginCtrl "https://github.com/hanlinag/point-of-sale-system/blob/master/src/controller/LoginController.java"
        AdminCtrl["MainAdminController.java"]:::controller
        click AdminCtrl "https://github.com/hanlinag/point-of-sale-system/blob/master/src/controller/MainAdminController.java"
        CashierCtrl["MainCashierController.java"]:::controller
        click CashierCtrl "https://github.com/hanlinag/point-of-sale-system/blob/master/src/controller/MainCashierController.java"
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        ReportGen["ReportGenerator.java"]:::business
        click ReportGen "https://github.com/hanlinag/point-of-sale-system/blob/master/src/functs/ReportGenerator.java"
        QRRecv["QRReceiveData.java"]:::business
        click QRRecv "https://github.com/hanlinag/point-of-sale-system/blob/master/src/functs/QRReceiveData.java"
        SearchBC["SearchBarcode.java"]:::business
        click SearchBC "https://github.com/hanlinag/point-of-sale-system/blob/master/src/functs/SearchBarcode.java"
        EditCell["EditingCell.java"]:::business
        click EditCell "https://github.com/hanlinag/point-of-sale-system/blob/master/src/functs/EditingCell.java"
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        ConnUtil["ConnectionUtils.java"]:::data
        click ConnUtil "https://github.com/hanlinag/point-of-sale-system/blob/master/src/database/ConnectionUtils.java"
        MySQLUtil["MySQLConnUtils.java"]:::data
        click MySQLUtil "https://github.com/hanlinag/point-of-sale-system/blob/master/src/database/MySQLConnUtils.java"
        DBInit["DBInitialize.java"]:::data
        click DBInit "https://github.com/hanlinag/point-of-sale-system/blob/master/src/database/DBInitialize.java"
    end

    %% Domain Model
    subgraph "Domain Model"
        Model["Model Objects\n(src/model/*.java)"]:::model
    end
    click Model "https://github.com/hanlinag/point-of-sale-system/tree/master/src/model/"

    %% Reporting Engine
    subgraph "Reporting Engine"
        Templates["Jasper Templates\n(src/jaspertemplate/*.jrxml/.jasper)"]:::report
        click Templates "https://github.com/hanlinag/point-of-sale-system/tree/master/src/jaspertemplate/"
    end

    %% External Systems
    ExternalScanner["Android Scanner (TCP)"]:::external
    Database["MySQL UCSMPOS\n(schema)"]:::external
    click Database "https://github.com/hanlinag/point-of-sale-system/blob/master/UCSMPOS.sql"

    %% Flows and Interactions
    LoginEP --> UI
    UI --> LoginCtrl
    LoginCtrl -->|"authenticate"| DBInit
    LoginCtrl --> Model
    LoginCtrl --> MainAdminEP
    LoginCtrl --> MainCashierEP

    MainAdminEP --> AdminCtrl
    MainCashierEP --> CashierCtrl

    AdminCtrl --> UI
    CashierCtrl --> UI

    AdminCtrl --> Model
    CashierCtrl --> Model

    AdminCtrl --> SearchBC
    AdminCtrl --> ReportGen
    CashierCtrl --> SearchBC
    CashierCtrl --> QRRecv

    SearchBC --> ConnUtil
    QRRecv --> ConnUtil
    ReportGen --> ConnUtil
    EditCell --> ConnUtil

    ConnUtil --> MySQLUtil
    MySQLUtil --> DBInit
    DBInit --> Database

    ReportGen --> Templates

    ExternalScanner --> QRRecv

    %% Styling
    classDef presentation fill:#D0E8FF,stroke:#0288D1,color:#000;
    classDef controller fill:#D0FFD8,stroke:#2E7D32,color:#000;
    classDef business fill:#FFE0B2,stroke:#FB8C00,color:#000;
    classDef data fill:#FFF9C4,stroke:#FBC02D,color:#000;
    classDef model fill:#E1BEE7,stroke:#8E24AA,color:#000;
    classDef report fill:#FFCCBC,stroke:#E64A19,color:#000;
    classDef entry fill:#C5CAE9,stroke:#3949AB,color:#000;
    classDef external fill:#ECEFF1,stroke:#607D8B,color:#000;
```
