Case study 02Client system · in production2026
YASH MOBILE POS
Point of sale and inventory for a real phone-accessories shop
YASH MOBILE POS is a production system I built for a mobile phone accessories shop. Version 1 had a Node.js / Express backend; version 2 moved the API to Laravel 12 while keeping the same API contract, database tables and React client, so existing data carried over unchanged.
- Stack
- Laravel 12
- PHP 8.2
- React 18
- TypeScript
- Vite
- Tailwind CSS
- TanStack Query
- MySQL / MariaDB
- PWA
- IndexedDB
- PHPUnit
- Vitest

- application screens
- 23application screens
- PHP feature-test suites
- 10PHP feature-test suites
- negative stock, by construction
- 0negative stock, by construction
- yashenterpr.store
- Liveyashenterpr.store
01
Requirements and constraints
- Billing must be fast at the counter: keyboard shortcuts (F2 search, F9 pay) and barcode scanners that type the code and press Enter.
- The owner and cashiers sign in at the same time on different devices; cost and profit fields must not reach users without permission.
- Hosting budget is shared cPanel hosting with PHP and MySQL, with no terminal access.
- The internet connection is not reliable, but a sale must never be lost or duplicated.
02
Architecture
React SPA ── service worker (app shell only) ── IndexedDB
│ ├─ cost-free product catalogue
│ └─ offline sales queue (PENDING / CONFLICT)
▼
Laravel 12 API ── Services/Inventory (the only code that changes stock)
│ ── Services/Sales (sales, voids, returns), PDF invoices
▼
MySQL / MariaDB ── stock_movements ledger, document_sequences, audit log03
Keeping stock and money correct
UPDATE products
SET qtyOnHand = qtyOnHand - :n
WHERE id = :id
AND qtyOnHand - qtyReserved >= :n
-- 0 rows updated → transaction aborts with INSUFFICIENT_STOCK- Increments lock the product row (SELECT … FOR UPDATE) so the moving weighted-average cost is computed from a consistent state.
- A sale, its items, payments, warranty records, stock movements, invoice number and audit entry are written in one transaction.
- Invoice numbers come from a sequence table inside the same transaction, so they are unique and gap-free per year (YM-2026-000001).
- Partial returns use the same conditional-update pattern, so refunds stay exact across repeated partial returns.
04
An offline mode that stays honest
When the device is offline, the sale is stored in IndexedDB as PENDING, with no invoice number, and is clearly labelled as not yet recorded. The local catalogue is reduced so the same device cannot oversell its own stock.
On reconnect, pending sales are posted one by one with their original request ID, so a lost response can never create a duplicate. The server re-checks stock, prices and permissions. If another till already sold the item, the sale becomes CONFLICT and waits for a person to reconcile it. The client never pushes stock quantities to the server.
05
Testing
PHPUnit feature tests run against a real MySQL test database, recreated on each run (the bootstrap refuses to reset any database whose name does not contain “test”). Suites cover auth, inventory, sales, returns and reports, stock alerts, stock undo, setup and a route smoke test. The client uses Vitest with Testing Library and fake-indexeddb for the offline queue.
Next case study
Nottary-Service