# NexStock Roadmap V1.2+ — Advanced Features, Automations & Future Modules

> **Document Version**: 1.1.0 (Future Architecture Blueprint)  
> **Release Target**: NexStock V1.2 – V2.0  
> **Prepared For**: Nexgen Technology Services  
> **Focus**: Automation, Messaging Gateways, Intelligence & Multi-Branch Enterprise Scaling

---

## 1. Automated Messaging & Alerts Engine (WhatsApp & SMS)

### 1.1 Architecture & Gateway Integrations
To deliver real-time operational alerts in the East African market (Tanzania, Kenya, Uganda, Rwanda), NexStock will support a pluggable notification driver architecture:

```
                  ┌────────────────────────────────────────┐
                  │       NexStock Notification Engine     │
                  └──────────────────┬─────────────────────┘
                                     │
         ┌───────────────────────────┼───────────────────────────┐
         ▼                           ▼                           ▼
┌──────────────────┐       ┌──────────────────┐        ┌──────────────────┐
│   Beem Africa    │       │  NextSMS / Local │        │   WhatsApp Cloud │
│   (SMS Gateway)  │       │   Aggregators    │        │   API / Twilio   │
└──────────────────┘       └──────────────────┘        └──────────────────┘
```

### 1.2 Automated Triggers
1. **Critical Low Stock Alert (SMS/WhatsApp)**:
   - *Trigger*: Physical balance $\le$ `reorder_level` after a sale or adjustment.
   - *Message Payload*:
     > ⚠️ *NexStock Alert*: **[Product Name]** is running low! Current stock: **[5 pcs]** (Threshold: [10 pcs]). Preferred Supplier: **[Supplier Name - +255 7XX XXX XXX]**.
   - *Delivery Cadence*: Real-time or daily morning digest (configurable per store).

2. **End-of-Day Store Performance Summary**:
   - *Trigger*: Scheduled at store closing (e.g., 9:30 PM).
   - *Payload*: Gross Sales, Cash vs Mobile breakdown, Net Margin, and Top Cashier.

3. **Trial & Subscription Lifecycle Notifications**:
   - 3 Days before trial expiry: *"Your NexStock 14-day trial ends in 3 days. Upgrade today to keep your POS running seamlessly."*
   - 1 Day before expiry / Day-of expiry with instant M-Pesa / TigoPesa payment link.
   - 7 Days before paid subscription renewal.

---

## 2. Smart Inventory Intelligence (Rule-Based & Predictive)

### 2.1 Slow-Moving & Dead Stock Analyzer
- **Slow-Moving Products**: Items where sales velocity is $< 20\%$ of expected run-rate over the last 30 days.
- **Dead Stock Warning**: Products with positive inventory balance ($> 0$) and zero sales transactions in $60+$ consecutive days.
- **Actionable Insights Engine**:
  - Automatically recommends promotional discount or bundling with top sellers.
  - Computes capital tied up in dormant inventory: $\text{Locked Capital} = \sum (\text{Qty} \times \text{Cost Price})$.

### 2.2 Dynamic Reorder Point (ROP) & Safety Stock Forecasting
- Formula: $\text{ROP} = (\text{Average Daily Unit Sales} \times \text{Supplier Lead Time in Days}) + \text{Safety Stock}$
- Auto-generates draft Purchase Orders (POs) when stock hits calculated ROP.

---

## 3. Multi-Branch Operations & Stock Logistics

### 3.1 Inter-Branch Stock Transfers (IBT)
- Workflow: **Initiate Transfer** (Source Branch) $\rightarrow$ **In Transit** (Deducts from Source) $\rightarrow$ **Receive & Verify** (Destination Branch Adds Stock).
- Audit trail logging user ID, timestamps, dispatch notes, and discrepancy resolution.

### 3.2 Centralized Warehouse & Regional Hub Distribution
- HQ Warehouse supplying satellite retail retail branches with consolidated purchase ordering.

---

## 4. Hardware & Peripherals Integration Suite

### 4.1 Thermal Receipt Printing (ESC/POS)
- Native WebUSB, WebBluetooth, and Network IP printing for 58mm and 80mm thermal receipt printers (Epson, Xprinter, Sunmi POS terminals).
- Customizable receipt templates: Store Logo, Tax PIN, Cashier Name, Itemized List with VAT breakdown, Custom Footer Message (*"Asante kwa Kujipatia Mahitaji Yako!"*), and QR Code for e-receipts.

### 4.2 Barcode & Scale Integration
- Seamless keyboard-wedge and camera-based barcode scanning (EAN-13, UPC, Code-128).
- Price-embedded barcode support for digital weighing scales (butchery, deli, and fresh produce).

---

## 5. Customer CRM, Loyalty & Digital Credit Ledger

### 5.1 Customer Profiles & Purchase History
- Store customer phone number at POS checkout.
- Track lifetime value (LTV), total visits, and average transaction size.

### 5.2 Loyalty Points & Store Credit
- Earn 1 point per TZS 1,000 spent; redeem points for discounts during checkout.
- Store Credit / Debt Ledger (*Daftari la Madeni*) for trusted customers with SMS reminder balances.

---

## 6. Self-Service Payment Automation & Gateways

### 6.1 Direct In-App Mobile Money Checkout
- Direct integration with Tanzania Mobile Money APIs (M-Pesa USSD Push / STK Push, TigoPesa, Airtel Money via PawaPay or Selcom).
- 1-click subscription renewal for store owners directly from the tenant dashboard without waiting for manual admin approval.

---

## 7. Offline-First POS Architecture (PWA)

- **IndexedDB Local Storage**: Allows cashiers to ring up sales, calculate totals, and print receipts even during internet outages.
- **Background Sync**: Queues offline sales locally and syncs atomically with the Laravel backend when connectivity resumes.
- **Conflict Resolution**: Idempotency keys (`sale_uuid`) to prevent duplicate transactions upon reconnection.

---

## 8. Release Milestone Timeline

| Phase | Milestone Name | Key Deliverables |
|---|---|---|
| **V1.2** | *Hardware & Core Enhancements* | Thermal Receipt Printer (ESC/POS), Barcode Scanner Engine, Customer Directory & Debt Ledger. |
| **V1.3** | *Messaging & Stock Intelligence* | WhatsApp/SMS Low Stock Alerts, Slow/Dead Stock Insights, Automated Trial/Renewal Reminders. |
| **V1.4** | *Multi-Branch Logistics* | Inter-Branch Stock Transfers, Regional Warehouse Management, Role-Based Shift Registers. |
| **V2.0** | *Automated SaaS & Offline PWA* | M-Pesa/TigoPesa USSD Push Subscription Gateway, Offline PWA with Background Sync. |
