# justin-bonete/pos-system architecture

> Architecture diagram of the GitHub repository justin-bonete/pos-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/justin-bonete/pos-system
- Repository: https://github.com/justin-bonete/pos-system

## Overview

This is a PHP/MySQL point-of-sale application. Staff authenticate, enter the dashboard, manage products and stock, and create sales; sales and inventory activity are then available through history and reporting views. The README also documents categories, QR generation and scanning, low-stock alerts, and a REST API. Several API and dashboard routes are listed but unsampled, so links involving them are omitted unless supported by the README or source index.

Main entry points: [`classes/Product.php`](https://github.com/justin-bonete/pos-system/blob/main/classes/Product.php) (Product catalog), [`classes/Sale.php`](https://github.com/justin-bonete/pos-system/blob/main/classes/Sale.php) (Sales records), [`classes/SalesManager.php`](https://github.com/justin-bonete/pos-system/blob/main/classes/SalesManager.php) (Sales operations), [`views/dashboard/index.php`](https://github.com/justin-bonete/pos-system/blob/main/views/dashboard/index.php) (Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and dashboard"]
  node_login["Sign-in<br/>[login.php]"]
  node_dashboard["Dashboard<br/>[index.php]"]
  node_auth["Session access<br/>[auth.php]"]
  node_layout["Page layout<br/>[header.php]"]
end

subgraph group_inventory["Catalog and inventory"]
  node_product_ui["Product management<br/>[add.php]"]
  node_categories_ui["Category management<br/>[list.php]"]
  node_products["Product catalog<br/>[Product.php]"]
  node_categories["Categories<br/>[Category.php]"]
  node_product_history["Stock history<br/>[ProductHistory.php]"]
  node_qr["QR generation<br/>[QRGenerator.php]"]
  node_barcode["Barcode lookup<br/>[search_barcode.php]"]
end

subgraph group_sales["Sales and reporting"]
  node_sales_ui["Point of sale<br/>[new.php]"]
  node_sales_history["Sales history<br/>[history.php]"]
  node_reporting["Reports<br/>[index.php]"]
  node_sale_model["Sales records<br/>[Sale.php]"]
  node_sales_manager["Sales operations<br/>[SalesManager.php]"]
  node_sale_api["Order completion API<br/>[complete-order.php]"]
  node_api["REST API"]
end

subgraph group_foundation["Shared services"]
  node_validator["Validation<br/>[Validator.php]"]
  node_discounts["Sale discounts<br/>[sale_discount.php]"]
  node_db[("Database access<br/>[database.php]")]
  node_db_config[("MySQL connection<br/>[database.php]")]
end

node_staff(("Staff"))

node_staff -->|"signs in"| node_login
node_staff -->|"uses"| node_dashboard
node_login -->|"checks session"| node_auth
node_dashboard -->|"checks access"| node_auth
node_dashboard -->|"opens sale"| node_sales_ui
node_dashboard -->|"opens history"| node_sales_history
node_product_ui -->|"manages"| node_products
node_product_ui -->|"loads categories"| node_categories
node_categories_ui -->|"manages"| node_categories
node_products -->|"logs changes"| node_product_history
node_barcode -->|"looks up"| node_products
node_sales_ui -->|"uses catalog"| node_products
node_sales_ui -->|"records sale"| node_sale_model
node_sales_ui -->|"tracks stock"| node_product_history
node_sales_history -->|"reads history"| node_sale_model
node_reporting -->|"reads sales"| node_sale_model
node_sales_manager -->|"checks stock"| node_products
node_sales_manager -->|"records sales"| node_sale_model
node_sales_manager -->|"validates reports"| node_validator
node_sale_api -->|"updates stock"| node_products
node_sale_api -->|"logs stock"| node_product_history
node_sale_api -->|"completes order"| node_sale_model
node_api -->|"serves operations"| node_staff
node_sale_model -->|"uses rules"| node_discounts
node_categories -->|"uses connection"| node_db
node_sales_manager -->|"uses connection"| node_db
node_db -->|"gets PDO"| node_db_config
node_qr -.->|"generates codes"| node_products

click node_login "https://github.com/justin-bonete/pos-system/blob/main/views/auth/login.php"
click node_dashboard "https://github.com/justin-bonete/pos-system/blob/main/views/dashboard/index.php"
click node_auth "https://github.com/justin-bonete/pos-system/blob/main/includes/auth.php"
click node_layout "https://github.com/justin-bonete/pos-system/blob/main/views/layouts/header.php"
click node_product_ui "https://github.com/justin-bonete/pos-system/blob/main/views/products/add.php"
click node_categories_ui "https://github.com/justin-bonete/pos-system/blob/main/views/categories/list.php"
click node_products "https://github.com/justin-bonete/pos-system/blob/main/classes/Product.php"
click node_categories "https://github.com/justin-bonete/pos-system/blob/main/classes/Category.php"
click node_product_history "https://github.com/justin-bonete/pos-system/blob/main/classes/ProductHistory.php"
click node_qr "https://github.com/justin-bonete/pos-system/blob/main/classes/QRGenerator.php"
click node_barcode "https://github.com/justin-bonete/pos-system/blob/main/views/school/search_barcode.php"
click node_sales_ui "https://github.com/justin-bonete/pos-system/blob/main/views/sales/new.php"
click node_sales_history "https://github.com/justin-bonete/pos-system/blob/main/views/sales/history.php"
click node_reporting "https://github.com/justin-bonete/pos-system/blob/main/views/reports/index.php"
click node_sale_model "https://github.com/justin-bonete/pos-system/blob/main/classes/Sale.php"
click node_sales_manager "https://github.com/justin-bonete/pos-system/blob/main/classes/SalesManager.php"
click node_sale_api "https://github.com/justin-bonete/pos-system/blob/main/api/sales/complete-order.php"
click node_api "https://github.com/justin-bonete/pos-system/tree/main/api"
click node_validator "https://github.com/justin-bonete/pos-system/blob/main/classes/Validator.php"
click node_discounts "https://github.com/justin-bonete/pos-system/blob/main/includes/sale_discount.php"
click node_db "https://github.com/justin-bonete/pos-system/blob/main/classes/database.php"
click node_db_config "https://github.com/justin-bonete/pos-system/blob/main/config/database.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_login,node_dashboard,node_auth,node_layout toneBlue
class node_product_ui,node_categories_ui,node_products,node_categories,node_product_history,node_qr,node_barcode toneAmber
class node_sales_ui,node_sales_history,node_reporting,node_sale_model,node_sales_manager,node_sale_api,node_api toneMint
class node_validator,node_discounts,node_db,node_db_config toneRose
class node_staff toneIndigo
```

## Components

### Access and dashboard

- [Sign-in](https://github.com/justin-bonete/pos-system/blob/main/views/auth/login.php): `views/auth/login.php`
- [Dashboard](https://github.com/justin-bonete/pos-system/blob/main/views/dashboard/index.php): `views/dashboard/index.php`
- [Session access](https://github.com/justin-bonete/pos-system/blob/main/includes/auth.php): `includes/auth.php`
- [Page layout](https://github.com/justin-bonete/pos-system/blob/main/views/layouts/header.php): `views/layouts/header.php`

### Catalog and inventory

- [Product management](https://github.com/justin-bonete/pos-system/blob/main/views/products/add.php): `views/products/add.php`
- [Category management](https://github.com/justin-bonete/pos-system/blob/main/views/categories/list.php): `views/categories/list.php`
- [Product catalog](https://github.com/justin-bonete/pos-system/blob/main/classes/Product.php): `classes/Product.php`
- [Categories](https://github.com/justin-bonete/pos-system/blob/main/classes/Category.php): `classes/Category.php`
- [Stock history](https://github.com/justin-bonete/pos-system/blob/main/classes/ProductHistory.php): `classes/ProductHistory.php`
- [QR generation](https://github.com/justin-bonete/pos-system/blob/main/classes/QRGenerator.php): `classes/QRGenerator.php`
- [Barcode lookup](https://github.com/justin-bonete/pos-system/blob/main/views/school/search_barcode.php): `views/school/search_barcode.php`

### Sales and reporting

- [Point of sale](https://github.com/justin-bonete/pos-system/blob/main/views/sales/new.php): `views/sales/new.php`
- [Sales history](https://github.com/justin-bonete/pos-system/blob/main/views/sales/history.php): `views/sales/history.php`
- [Reports](https://github.com/justin-bonete/pos-system/blob/main/views/reports/index.php): `views/reports/index.php`
- [Sales records](https://github.com/justin-bonete/pos-system/blob/main/classes/Sale.php): `classes/Sale.php`
- [Sales operations](https://github.com/justin-bonete/pos-system/blob/main/classes/SalesManager.php): `classes/SalesManager.php`
- [Order completion API](https://github.com/justin-bonete/pos-system/blob/main/api/sales/complete-order.php): `api/sales/complete-order.php`
- [REST API](https://github.com/justin-bonete/pos-system/tree/main/api): `api`

### Shared services

- [Validation](https://github.com/justin-bonete/pos-system/blob/main/classes/Validator.php): `classes/Validator.php`
- [Sale discounts](https://github.com/justin-bonete/pos-system/blob/main/includes/sale_discount.php): `includes/sale_discount.php`
- [Database access](https://github.com/justin-bonete/pos-system/blob/main/classes/database.php): `classes/database.php`
- [MySQL connection](https://github.com/justin-bonete/pos-system/blob/main/config/database.php): `config/database.php`

### Other components

- **Staff**

## Connections

- Staff → Sign-in: signs in
- Staff → Dashboard: uses
- Sign-in → Session access: checks session
- Dashboard → Session access: checks access (evidence: `views/dashboard/index.php`)
- Dashboard → Point of sale: opens sale (evidence: `views/dashboard/index.php`)
- Dashboard → Sales history: opens history (evidence: `views/dashboard/index.php`)
- Product management → Product catalog: manages (evidence: `views/products/add.php`)
- Product management → Categories: loads categories (evidence: `views/products/add.php`)
- Category management → Categories: manages (evidence: `views/categories/list.php`)
- Product catalog → Stock history: logs changes (evidence: `classes/Product.php`)
- Barcode lookup → Product catalog: looks up (evidence: `views/school/search_barcode.php`)
- Point of sale → Product catalog: uses catalog (evidence: `views/sales/new.php`)
- Point of sale → Sales records: records sale (evidence: `views/sales/new.php`)
- Point of sale → Stock history: tracks stock (evidence: `views/sales/new.php`)
- Sales history → Sales records: reads history (evidence: `views/sales/history.php`)
- Reports → Sales records: reads sales (evidence: `views/reports/index.php`)
- Sales operations → Product catalog: checks stock (evidence: `classes/SalesManager.php`)
- Sales operations → Sales records: records sales (evidence: `classes/SalesManager.php`)
- Sales operations → Validation: validates reports (evidence: `classes/SalesManager.php`)
- Order completion API → Product catalog: updates stock (evidence: `api/sales/complete-order.php`)
- Order completion API → Stock history: logs stock (evidence: `api/sales/complete-order.php`)
- Order completion API → Sales records: completes order (evidence: `api/sales/complete-order.php`)
- REST API → Staff: serves operations
- Sales records → Sale discounts: uses rules (evidence: `classes/Sale.php`)
- Categories → Database access: uses connection (evidence: `classes/Category.php`)
- Sales operations → Database access: uses connection (evidence: `classes/SalesManager.php`)
- Database access → MySQL connection: gets PDO (evidence: `classes/database.php`)
- QR generation → Product catalog: generates codes
