# Vault POS Full Platform

Unified multi-tenant SaaS trade-counter POS with:

- Subdomain tenant detection (`screwstop.vaultpos.co.uk` → tenant `screwstop`)
- Staff login/session
- Store/till selector
- Tenant-scoped customers/products/stock/orders
- Customer search + create + walk-in customer
- Fast product search/basket
- Multi-store stock display
- Quote/contract/payment continuation screen
- Receipt print template
- Offline queue placeholder/sync endpoint
- Arkwright-style assisted upsell endpoint

## Quick local run

```bash
cd vaultpos-full-platform
php database/seed.php
php -S 127.0.0.1:8080 -t public
```

Open: `http://127.0.0.1:8080`

Login:

- demo tenant: `admin@demo.local` / any non-empty password
- screwstop tenant: use subdomain/vhost and `admin@screwstop.local`

For real subdomains, set Apache/Nginx wildcard vhost and add DNS wildcard.

## Production notes

1. Put this folder at `/var/www/vaultpos-full-platform`.
2. Point `*.vaultpos.co.uk` to the server.
3. Install wildcard SSL.
4. Set `VAULT_BASE_DOMAIN=vaultpos.co.uk`.
5. Replace SQLite with MySQL by setting `DATABASE_URL` or adapting `Database.php`.
6. Every table includes `tenant_id`; every API query scopes by tenant.

## API endpoints

- `GET /api.php/tenant`
- `POST /api.php/auth/login`
- `GET /api.php/stores`
- `GET /api.php/tills?store_id=1`
- `GET /api.php/customers?q=smith`
- `POST /api.php/customers`
- `GET /api.php/pos/products?q=screw`
- `GET /api.php/pos/stock/{product_id}`
- `POST /api.php/checkout/start`
- `GET /api.php/orders?q=Q...`
- `POST /api.php/offline/sync`
- `POST /api.php/arkwright/upsell`

## Fusion integration

This build includes a working local backend. To route into your existing Fusion API, replace the route handlers in `api/routes.php` with calls into your existing Fusion controllers/services, keeping the tenant enforcement at the top.
