# wuninsu/pos-advanced architecture

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

- Interactive diagram: https://gitdiagram.com/wuninsu/pos-advanced
- Repository: https://github.com/wuninsu/pos-advanced

## Overview

#### Purpose and Entry Points
This is a Laravel-based advanced POS and operations system: inventory, sales/orders, invoices, customers, suppliers, transactions, services, expenditures, reporting, SMS, and administration. HTTP enters through `public/index.php`, Laravel bootstraps via `bootstrap/app.php`, and application routing is defined in `routes/web.php` with auxiliary API, console, and broadcast-channel routes in `routes/api.php`, `routes/console.php`, and `routes/channels.php`.

#### Interactive Application Layer
The primary UI is server-rendered Blade plus Livewire, not a separate SPA. Admin operational screens are stateful Livewire components paired with templates, notably `app/Livewire/Admin/Pos.php`, `app/Livewire/Admin/Orders.php`, and `resources/views/livewire/admin/pos.blade.php`. Shared layouts establish authenticated/admin shell boundaries in `resources/views/layouts/app.blade.php` and `resources/views/layouts/sidebar.blade.php`.

#### Identity, Roles, and Access Boundaries
Authentication includes login, password recovery/reset, and OTP verification through `app/Livewire/Auth/LoginForm.php`, `app/Livewire/Auth/ForgetPasswordForm.php`, and `app/Livewire/Auth/VerifyOTP.php`. Role-specific middleware separates admin, manager, cashier, and general user access: `app/Http/Middleware/AdminMiddleware.php`, `app/Http/Middleware/CashierMiddleware.php`, and `app/Http/Middleware/CheckRoleMiddleware.php`. The user model and role/permission schema anchor authorization at `app/Models/User.php` and `database/migrations/0create_roles_models_table.php`.

#### Sales, POS, and Financial Flow
The central transaction flow is POS/cart → order and order details → transaction/invoice records. Core persistence models are `app/Models/CartItemsModel.php`, `app/Models/OrdersModel.php`, `app/Models/OrderDetailsModel.php`, `app/Models/TransactionsModel.php`, `app/Models/Invoices.php`, and `app/Models/InvoiceDetail.php`. UI/form boundaries for this flow are `app/Livewire/Admin/Pos.php`, `app/Livewire/Forms/OrderForm.php`, and `app/Livewire/Forms/InvoiceForm.php`; dedicated controllers support order actions, POS endpoints, and invoice generation in `app/Http/Controllers/OrdersController.php`, `app/Http/Controllers/PosController.php`, and `app/Http/Controllers/InvoiceGenerator.php`.

#### Inventory and Business Master Data
Products are connected to categories, suppliers, units, customers, and users. The principal model boundary is `app/Models/ProductsModel.php`, with supporting entities in `app/Models/CategoriesModel.php`, `app/Models/SuppliersModel.php`, `app/Models/Unit.php`, and `app/Models/CustomersModel.php`. Product/order-detail relationships described by the README make inventory data a dependency of sale fulfillment. Stock monitoring and alert UI live in `app/Livewire/StockAlerts.php` and `app/Livewire/Admin/Monitor.php`.

#### Operations, Notifications, and Service Work
The system tracks service catalogues and service requests independently of retail orders via `app/Models/Service.php`, `app/Models/ServiceRequest.php`, and `app/Livewire/Admin/ServiceRequests.php`. Domain events represent stock alerts and order-deletion workflow: `app/Events/StockAlertEvent.php`, `app/Events/DeleteOrderRequestReceived.php`, and `app/Events/OrderDeleteEvent.php`. Notifications and SMS are modeled internally through `app/Notifications/OrderDeletionRequest.php`, `app/Models/SMSTemplate.php`, and `app/Models/SMSLog.php`; mail integration is configured through `config/mail.php` and implemented in `app/Mail/ForgotPasswordMail.php`.

#### Persistence, Outputs, and Runtime Services
Laravel Eloquent persists the domain schema through `database/migrations`, including orders, transactions, invoices, inventory, queues, cache, and personal tokens. Environment-selectable DB, cache, session, filesystem, queue, mail, broadcasting, and Reverb real-time services are configured under `config/database.php`, `config/queue.php`, `config/reverb.php`, and related Laravel config. Reports and portable outputs cross into Excel/PDF-style export views through `app/Exports/ExportOrders.php`, `app/Exports/ExportInvoice.php`, and `resources/views/exports/invoice.blade.php`. Operational maintenance includes database backup commands at `app/Console/Commands/DBBackup.php` and `app/Console/Commands/BackupSqlite.php`.

Main entry points: [`database/migrations`](https://github.com/wuninsu/pos-advanced/tree/main/database/migrations) (Database schema), [`app/Models/OrdersModel.php`](https://github.com/wuninsu/pos-advanced/blob/main/app/Models/OrdersModel.php) (Orders & order details), [`app/Http/Controllers/OrdersController.php`](https://github.com/wuninsu/pos-advanced/blob/main/app/Http/Controllers/OrdersController.php) (Sales action controllers), [`app/Http/Middleware/CheckRoleMiddleware.php`](https://github.com/wuninsu/pos-advanced/blob/main/app/Http/Middleware/CheckRoleMiddleware.php) (Authentication & roles)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Laravel Runtime"]
  node_entry["HTTP entry<br/>Laravel entrypoint<br/>[index.php]"]
  node_bootstrap["Application bootstrap<br/>Laravel bootstrap<br/>[app.php]"]
  node_routes["Route boundaries<br/>[web.php]"]
  node_access["Authentication &amp; roles<br/>Livewire auth and middleware"]
  node_users[("Users, roles &amp; permissions<br/>identity model/schema<br/>[User.php]")]
  node_persistence[("Database schema<br/>Laravel migrations")]
end

subgraph group_ui["Interactive UI"]
  node_shell["Authenticated admin shell<br/>Blade layouts<br/>[app.blade.php]"]
  node_pos["POS workspace<br/>Livewire component<br/>[Pos.php]"]
  node_orders_ui["Orders workspace<br/>Livewire component<br/>[Orders.php]"]
end

subgraph group_sales["Sales &amp; Finance"]
  node_sales_forms["Order &amp; invoice forms<br/>Livewire forms<br/>[OrderForm.php]"]
  node_sales_actions["Sales action controllers<br/>HTTP controllers"]
  node_order_records[("Orders &amp; order details<br/>Eloquent sales records<br/>[OrdersModel.php]")]
  node_financial_records[("Transactions &amp; invoices<br/>Eloquent financial records")]
end

subgraph group_domain["Business Operations"]
  node_inventory[("Products &amp; master data<br/>Eloquent inventory domain<br/>[ProductsModel.php]")]
  node_stock_monitoring["Stock monitoring<br/>Livewire alerts<br/>[StockAlerts.php]"]
  node_services[("Service requests<br/>service operations domain<br/>[ServiceRequest.php]")]
  node_events{{"Domain events &amp; notifications<br/>event workflow"}}
end

subgraph group_integration["Outputs &amp; Operations"]
  node_exports["Reports &amp; exports<br/>Excel/PDF output<br/>[ExportOrders.php]"]
  node_maintenance["Database backup<br/>console command<br/>[DBBackup.php]"]
end

node_entry -->|"boots"| node_bootstrap
node_bootstrap -->|"loads routes"| node_routes
node_routes -->|"applies guards"| node_access
node_access -->|"authorizes against"| node_users
node_access -->|"admits authenticated users"| node_shell
node_shell -->|"hosts"| node_pos
node_shell -->|"hosts"| node_orders_ui
node_pos -->|"checkout input"| node_sales_forms
node_orders_ui -->|"order actions"| node_sales_actions
node_sales_forms -->|"submits"| node_sales_actions
node_sales_actions -->|"creates and updates"| node_order_records
node_sales_actions -->|"records payment and invoices"| node_financial_records
node_order_records -->|"fulfills from products"| node_inventory
node_stock_monitoring -->|"monitors stock"| node_inventory
node_stock_monitoring -->|"raises alerts"| node_events
node_events -.->|"notifies deletion workflow"| node_orders_ui
node_services -->|"persists"| node_persistence
node_order_records -->|"persists"| node_persistence
node_financial_records -->|"persists"| node_persistence
node_inventory -->|"persists"| node_persistence
node_financial_records -->|"generates reports"| node_exports
node_order_records -->|"exports orders"| node_exports
node_maintenance -->|"backs up"| node_persistence

click node_entry "https://github.com/wuninsu/pos-advanced/blob/main/public/index.php"
click node_bootstrap "https://github.com/wuninsu/pos-advanced/blob/main/bootstrap/app.php"
click node_routes "https://github.com/wuninsu/pos-advanced/blob/main/routes/web.php"
click node_access "https://github.com/wuninsu/pos-advanced/blob/main/app/Http/Middleware/CheckRoleMiddleware.php"
click node_users "https://github.com/wuninsu/pos-advanced/blob/main/app/Models/User.php"
click node_shell "https://github.com/wuninsu/pos-advanced/blob/main/resources/views/layouts/app.blade.php"
click node_pos "https://github.com/wuninsu/pos-advanced/blob/main/app/Livewire/Admin/Pos.php"
click node_orders_ui "https://github.com/wuninsu/pos-advanced/blob/main/app/Livewire/Admin/Orders.php"
click node_sales_forms "https://github.com/wuninsu/pos-advanced/blob/main/app/Livewire/Forms/OrderForm.php"
click node_sales_actions "https://github.com/wuninsu/pos-advanced/blob/main/app/Http/Controllers/OrdersController.php"
click node_order_records "https://github.com/wuninsu/pos-advanced/blob/main/app/Models/OrdersModel.php"
click node_financial_records "https://github.com/wuninsu/pos-advanced/blob/main/app/Models/TransactionsModel.php"
click node_inventory "https://github.com/wuninsu/pos-advanced/blob/main/app/Models/ProductsModel.php"
click node_stock_monitoring "https://github.com/wuninsu/pos-advanced/blob/main/app/Livewire/StockAlerts.php"
click node_services "https://github.com/wuninsu/pos-advanced/blob/main/app/Models/ServiceRequest.php"
click node_events "https://github.com/wuninsu/pos-advanced/blob/main/app/Events/StockAlertEvent.php"
click node_persistence "https://github.com/wuninsu/pos-advanced/tree/main/database/migrations"
click node_exports "https://github.com/wuninsu/pos-advanced/blob/main/app/Exports/ExportOrders.php"
click node_maintenance "https://github.com/wuninsu/pos-advanced/blob/main/app/Console/Commands/DBBackup.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_entry,node_bootstrap,node_routes,node_access,node_users,node_persistence toneBlue
class node_shell,node_pos,node_orders_ui toneAmber
class node_sales_forms,node_sales_actions,node_order_records,node_financial_records toneMint
class node_inventory,node_stock_monitoring,node_services,node_events toneRose
class node_exports,node_maintenance toneIndigo
```

## Components

### Laravel Runtime

- [HTTP entry](https://github.com/wuninsu/pos-advanced/blob/main/public/index.php): Laravel entrypoint · `public/index.php`
- [Application bootstrap](https://github.com/wuninsu/pos-advanced/blob/main/bootstrap/app.php): Laravel bootstrap · `bootstrap/app.php`
- [Route boundaries](https://github.com/wuninsu/pos-advanced/blob/main/routes/web.php): web, API, console & channels · `routes/web.php`
- [Authentication & roles](https://github.com/wuninsu/pos-advanced/blob/main/app/Http/Middleware/CheckRoleMiddleware.php): Livewire auth and middleware · Role middleware gates admin, cashier, manager, and user routes. · `app/Http/Middleware/CheckRoleMiddleware.php`
- [Users, roles & permissions](https://github.com/wuninsu/pos-advanced/blob/main/app/Models/User.php): identity model/schema · `app/Models/User.php`
- [Database schema](https://github.com/wuninsu/pos-advanced/tree/main/database/migrations): Laravel migrations · Persists inventory, sales, financial, queue, cache, and token data. · `database/migrations`

### Interactive UI

- [Authenticated admin shell](https://github.com/wuninsu/pos-advanced/blob/main/resources/views/layouts/app.blade.php): Blade layouts · `resources/views/layouts/app.blade.php`
- [POS workspace](https://github.com/wuninsu/pos-advanced/blob/main/app/Livewire/Admin/Pos.php): Livewire component · Stateful retail cart and checkout interface. · `app/Livewire/Admin/Pos.php`
- [Orders workspace](https://github.com/wuninsu/pos-advanced/blob/main/app/Livewire/Admin/Orders.php): Livewire component · `app/Livewire/Admin/Orders.php`

### Sales & Finance

- [Order & invoice forms](https://github.com/wuninsu/pos-advanced/blob/main/app/Livewire/Forms/OrderForm.php): Livewire forms · `app/Livewire/Forms/OrderForm.php`
- [Sales action controllers](https://github.com/wuninsu/pos-advanced/blob/main/app/Http/Controllers/OrdersController.php): HTTP controllers · Handles order actions, POS endpoints, and invoice generation. · `app/Http/Controllers/OrdersController.php`
- [Orders & order details](https://github.com/wuninsu/pos-advanced/blob/main/app/Models/OrdersModel.php): Eloquent sales records · `app/Models/OrdersModel.php`
- [Transactions & invoices](https://github.com/wuninsu/pos-advanced/blob/main/app/Models/TransactionsModel.php): Eloquent financial records · `app/Models/TransactionsModel.php`

### Business Operations

- [Products & master data](https://github.com/wuninsu/pos-advanced/blob/main/app/Models/ProductsModel.php): Eloquent inventory domain · Products connect categories, suppliers, units, customers, and users. · `app/Models/ProductsModel.php`
- [Stock monitoring](https://github.com/wuninsu/pos-advanced/blob/main/app/Livewire/StockAlerts.php): Livewire alerts · `app/Livewire/StockAlerts.php`
- [Service requests](https://github.com/wuninsu/pos-advanced/blob/main/app/Models/ServiceRequest.php): service operations domain · Service work is independent of retail orders. · `app/Models/ServiceRequest.php`
- [Domain events & notifications](https://github.com/wuninsu/pos-advanced/blob/main/app/Events/StockAlertEvent.php): event workflow · Carries stock alerts and order-deletion requests. · `app/Events/StockAlertEvent.php`

### Outputs & Operations

- [Reports & exports](https://github.com/wuninsu/pos-advanced/blob/main/app/Exports/ExportOrders.php): Excel/PDF output · `app/Exports/ExportOrders.php`
- [Database backup](https://github.com/wuninsu/pos-advanced/blob/main/app/Console/Commands/DBBackup.php): console command · `app/Console/Commands/DBBackup.php`

## Connections

- HTTP entry → Application bootstrap: boots
- Application bootstrap → Route boundaries: loads routes
- Route boundaries → Authentication & roles: applies guards
- Authentication & roles → Users, roles & permissions: authorizes against
- Authentication & roles → Authenticated admin shell: admits authenticated users
- Authenticated admin shell → POS workspace: hosts
- Authenticated admin shell → Orders workspace: hosts
- POS workspace → Order & invoice forms: checkout input
- Orders workspace → Sales action controllers: order actions
- Order & invoice forms → Sales action controllers: submits
- Sales action controllers → Orders & order details: creates and updates
- Sales action controllers → Transactions & invoices: records payment and invoices
- Orders & order details → Products & master data: fulfills from products
- Stock monitoring → Products & master data: monitors stock
- Stock monitoring → Domain events & notifications: raises alerts
- Domain events & notifications → Orders workspace: notifies deletion workflow
- Service requests → Database schema: persists
- Orders & order details → Database schema: persists
- Transactions & invoices → Database schema: persists
- Products & master data → Database schema: persists
- Transactions & invoices → Reports & exports: generates reports
- Orders & order details → Reports & exports: exports orders
- Database backup → Database schema: backs up
