# savagedirane/pos-system architecture

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

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

## Overview

This is a PHP/MySQL point-of-sale web application. Its documented workflow is staff-facing: users enter through the web router, access POS and management pages or API endpoints, and conduct retail operations backed by application data. The checked-in runtime supports routing, views, product/user models, database access, and shared security, logging, and response helpers. The README describes broader sales, inventory, CRM, purchasing, reporting, returns, and chatbot capabilities, but their implementation files are absent from the supplied tree; those branches are shown as documented subsystems, not asserted call chains.

Main entry points: [`index.php`](https://github.com/savagedirane/pos-system/blob/main/index.php) (Request router), [`database/database_schema.sql`](https://github.com/savagedirane/pos-system/blob/main/database/database_schema.sql) (MySQL POS data), [`utils/helpers/LoggerHelper.php`](https://github.com/savagedirane/pos-system/blob/main/utils/helpers/LoggerHelper.php) (Audit logging), [`public/js/main.js`](https://github.com/savagedirane/pos-system/blob/main/public/js/main.js) (Browser utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Web entry"]
  node_router["Request router<br/>[index.php]"]
  node_page_views["Page views"]
  node_browser_ui["Browser utilities<br/>[main.js]"]
  node_api["API endpoints"]
end

subgraph group_operations["Retail operations"]
  node_sales["POS transactions"]
  node_inventory["Inventory control"]
  node_products["Product catalog<br/>[Product.php]"]
  node_customers["Customer loyalty"]
  node_purchasing["Supplier purchasing"]
  node_returns["Returns and refunds"]
  node_reports["Reports analytics"]
end

subgraph group_foundation["Application foundation"]
  node_access["User access<br/>[User.php]"]
  node_security["Security helpers<br/>[SecurityHelper.php]"]
  node_responses["API responses<br/>[ResponseHelper.php]"]
  node_logging["Audit logging<br/>[LoggerHelper.php]"]
  node_database_config["Database connection<br/>[database.php]"]
  node_model_base["Model CRUD<br/>[BaseModel.php]"]
  node_store[("MySQL POS data")]
end

subgraph group_integrations["Documented capabilities"]
  node_chatbot["AI chatbot"]
  node_crm["CRM loyalty programs"]
  node_analytics["Business insights"]
  node_compliance["Compliance tracking"]
end

node_staff(("Staff user"))
node_external_ai(("AI provider"))

node_staff -->|"sends requests"| node_router
node_router -->|"opens connection"| node_database_config
node_router -->|"loads page"| node_page_views
node_router -->|"dispatches API"| node_api
node_router -->|"uses security"| node_security
node_router -->|"logs errors"| node_logging
node_router -->|"sends errors"| node_responses
node_browser_ui -->|"fetches API"| node_api
node_model_base -->|"queries data"| node_store
node_products -->|"queries products"| node_store
node_access -->|"queries users"| node_store
node_logging -.->|"writes audit logs"| node_store
node_sales -.->|"updates stock"| node_inventory
node_sales -.->|"records sales"| node_store
node_purchasing -.->|"replenishes stock"| node_inventory
node_chatbot -.->|"requests responses"| node_external_ai

click node_router "https://github.com/savagedirane/pos-system/blob/main/index.php"
click node_page_views "https://github.com/savagedirane/pos-system/tree/main/app/views"
click node_browser_ui "https://github.com/savagedirane/pos-system/blob/main/public/js/main.js"
click node_products "https://github.com/savagedirane/pos-system/blob/main/app/models/Product.php"
click node_access "https://github.com/savagedirane/pos-system/blob/main/app/models/User.php"
click node_security "https://github.com/savagedirane/pos-system/blob/main/utils/helpers/SecurityHelper.php"
click node_responses "https://github.com/savagedirane/pos-system/blob/main/utils/helpers/ResponseHelper.php"
click node_logging "https://github.com/savagedirane/pos-system/blob/main/utils/helpers/LoggerHelper.php"
click node_database_config "https://github.com/savagedirane/pos-system/blob/main/config/database.php"
click node_model_base "https://github.com/savagedirane/pos-system/blob/main/app/models/BaseModel.php"
click node_store "https://github.com/savagedirane/pos-system/blob/main/database/database_schema.sql"

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_router,node_page_views,node_browser_ui,node_api,node_staff toneBlue
class node_sales,node_inventory,node_products,node_customers,node_purchasing,node_returns,node_reports toneAmber
class node_access,node_security,node_responses,node_logging,node_database_config,node_model_base,node_store toneMint
class node_chatbot,node_crm,node_analytics,node_compliance toneRose
class node_external_ai toneIndigo
```

## Components

### Web entry

- [Request router](https://github.com/savagedirane/pos-system/blob/main/index.php): `index.php`
- [Page views](https://github.com/savagedirane/pos-system/tree/main/app/views): `app/views`
- [Browser utilities](https://github.com/savagedirane/pos-system/blob/main/public/js/main.js): `public/js/main.js`
- **API endpoints**

### Retail operations

- **POS transactions**
- **Inventory control**
- [Product catalog](https://github.com/savagedirane/pos-system/blob/main/app/models/Product.php): `app/models/Product.php`
- **Customer loyalty**
- **Supplier purchasing**
- **Returns and refunds**
- **Reports analytics**

### Application foundation

- [User access](https://github.com/savagedirane/pos-system/blob/main/app/models/User.php): `app/models/User.php`
- [Security helpers](https://github.com/savagedirane/pos-system/blob/main/utils/helpers/SecurityHelper.php): `utils/helpers/SecurityHelper.php`
- [API responses](https://github.com/savagedirane/pos-system/blob/main/utils/helpers/ResponseHelper.php): `utils/helpers/ResponseHelper.php`
- [Audit logging](https://github.com/savagedirane/pos-system/blob/main/utils/helpers/LoggerHelper.php): `utils/helpers/LoggerHelper.php`
- [Database connection](https://github.com/savagedirane/pos-system/blob/main/config/database.php): `config/database.php`
- [Model CRUD](https://github.com/savagedirane/pos-system/blob/main/app/models/BaseModel.php): `app/models/BaseModel.php`
- [MySQL POS data](https://github.com/savagedirane/pos-system/blob/main/database/database_schema.sql): `database/database_schema.sql`

### Documented capabilities

- **AI chatbot**
- **CRM loyalty programs**
- **Business insights**
- **Compliance tracking**

### Other components

- **Staff user**
- **AI provider**

## Connections

- Staff user → Request router: sends requests
- Request router → Database connection: opens connection
- Request router → Page views: loads page
- Request router → API endpoints: dispatches API
- Request router → Security helpers: uses security
- Request router → Audit logging: logs errors
- Request router → API responses: sends errors
- Browser utilities → API endpoints: fetches API
- Model CRUD → MySQL POS data: queries data
- Product catalog → MySQL POS data: queries products
- User access → MySQL POS data: queries users
- Audit logging → MySQL POS data: writes audit logs
- POS transactions → Inventory control: updates stock
- POS transactions → MySQL POS data: records sales
- Supplier purchasing → Inventory control: replenishes stock
- AI chatbot → AI provider: requests responses
