# KarobariSuite — Gap Analysis & Phased Roadmap

**Last updated:** 2026-07-21  
**Companion doc:** [`Requirements-Coverage-Checklist.md`](Requirements-Coverage-Checklist.md) (what exists today)  
**Source of truth:** [`Prompt.md`](Prompt.md) (full product vision)

This document lists **everything still missing**, organized by **original phase (0–4)** and **proposed future phases (5–8)** to close gaps. Use it as the implementation backlog after the current codebase.

---

## Executive summary

Phases **0–4 are structurally complete** (migrations, modules, APIs, web shells exist), but many items within each phase are **MVP/stub only**. The product is **not yet sellable as enterprise SaaS** without the gaps below.

| Phase | Declared status | Actual completeness | Critical gaps |
| --- | --- | --- | --- |
| Phase 0 — Foundation | ✅ Shipped | ~65% | Cron/queue, Monolog/Sentry, audit logs, tenant resolver, tests |
| Phase 1 — MVP | ✅ Shipped | ~55% | Billing payments, feature gating, customer portal E2E, POS depth |
| Phase 2 — Growth | ✅ Shipped | ~50% | Integrations live, website builder v2, advanced reports |
| Phase 3 — Scale | ✅ Shipped | ~40% | Full automation, AI suite, marketplace checkout, search index |
| Phase 4 — Enterprise | ✅ Shipped | ~45% | ABAC enforcement, SLA automation, residency provisioning |
| Phase 5+ | ❌ Not started | 0% | White-label completeness, billing lifecycle, customer commerce |
| Phase 6+ | ❌ Not started | 0% | Marketplace vision, advanced AI, mobile apps |
| Phase 7+ | ❌ Not started | 0% | Production ops, scale, compliance |
| Phase 8+ | ❌ Not started | 0% | Industry packs, master design artifacts |

---

## Phase 0 — Foundation gaps

**Goal (Prompt.md):** Multi-tenant core, auth, RBAC, branding basics, audit, cron/queue, OpenAPI, PHPUnit.

### What was delivered

- PSR-4 modular monolith (`src/*`)
- `tenants`, `users`, RBAC tables, JWT + refresh tokens, API keys
- `tenant_id` on business tables, soft deletes, audit columns (partial)
- OpenAPI skeleton, local dev setup, seed script

### Gaps — must complete to call Phase 0 "done"

| # | Gap | Priority | Deliverables |
| --- | --- | --- | --- |
| 0.1 | **Cron + queue workers** not implemented | P0 | `bin/worker.php`, job table, cron schedule doc, email/notification worker |
| 0.2 | **Monolog + Sentry** not wired | P1 | Structured logging, error reporting, log channels per module |
| 0.3 | **Audit log service** missing | P0 | `audit_logs` table, write on mutations, platform viewer API + web |
| 0.4 | **Tenant resolution** incomplete | P0 | Resolve tenant from custom domain/subdomain/header; middleware |
| 0.5 | **Feature-flag system** missing | P0 | `tenant_feature_flags` table, middleware enforcement, admin API |
| 0.6 | **PHPUnit tenant isolation tests** missing | P0 | Tests: cross-tenant read/write must 403/404 |
| 0.7 | **OpenAPI** not synced with all routes | P1 | Regenerate `openapi/openapi.json` from route list |
| 0.8 | **`deleted_by` inconsistent** across tables | P2 | Migration to add missing audit columns |
| 0.9 | **SMTP mail** not integrated | P1 | Mail adapter, password reset, welcome email |
| 0.10 | **Permission enforcement** partial in controllers | P0 | Central `authorize()` checks on every mutating endpoint |
| 0.11 | **API rate limiting** missing | P1 | Per-IP and per-tenant limits |
| 0.12 | **Secrets management** basic (.env only) | P2 | Encrypted tenant secrets store for gateways/SMTP |

### Phase 0 acceptance criteria (remaining)

- Given Tenant A user, when calling Tenant B resource by ID, then 403/404 and audit entry logged.
- Given custom domain mapped to tenant, when hitting storefront, then correct tenant branding resolves.
- Given feature flag `pos` disabled on plan, when vendor opens POS API, then 403 with upgrade hint.

---

## Phase 1 — MVP gaps

**Goal (Prompt.md):** Sellable Retail + Salon/Service product — register, subscribe, sell via Web POS/online, manage stock/appointments, brand portal.

### What was delivered

- Products, services, inventory, orders, appointments, staff, customers, dashboard, reports
- Web: vendor admin, POS, basic portal, storefront, login/register
- Billing plans list (read-only)

### Gaps — must complete to call Phase 1 "done"

| # | Gap | Priority | Deliverables |
| --- | --- | --- | --- |
| 1.1 | **Subscription payment capture** missing | P0 | Stripe/Razorpay checkout, webhooks, `subscriptions` + `invoices` tables |
| 1.2 | **Feature gating** not enforced | P0 | Plan `features_json` enforced in middleware + UI nav hide |
| 1.3 | **Vendor onboarding wizard** missing | P1 | Steps: plan → branding → first product → go live |
| 1.4 | **Customer portal E2E** incomplete | P0 | Browse, cart, checkout, appointments, order tracking, invoices |
| 1.5 | **POS depth** limited | P0 | Tax breakdown, discounts, partial pay, refunds, receipt print |
| 1.6 | **Order lifecycle** shallow | P0 | States: draft → paid → fulfilled → completed → returned; fulfillment |
| 1.7 | **Appointments depth** limited | P0 | Staff slots, duration, buffer, no-show, reschedule, deposits |
| 1.8 | **Inventory reservations** missing | P1 | Reserve on cart/checkout; release on cancel/timeout |
| 1.9 | **Product variants / bundles** missing | P2 | SKU variants, options, combo products |
| 1.10 | **Roles & permissions UI** missing | P1 | Vendor admin: create roles, assign permissions to staff |
| 1.11 | **Platform Super Admin gaps** | P1 | Tenant approval queue, suspend with reason, impersonation (audit) |
| 1.12 | **Default white-label theme** basic | P1 | Theme tokens applied to portal + storefront from tenant colors |
| 1.13 | **Notifications** stub only | P1 | Real email for order confirm, appointment reminder |
| 1.14 | **Trial period** not implemented | P1 | `trial_ends_at` on tenant, grace messaging |
| 1.15 | **Usage limits** not enforced | P1 | Max products, stores, staff per plan |
| 1.16 | **Customer self-registration** weak | P1 | Customer signup on storefront, linked to tenant |
| 1.17 | **Module PHPUnit coverage** missing | P0 | Tests per Phase 1 module (products, orders, inventory, appointments) |

### Phase 1 acceptance criteria (remaining)

- Given new vendor, when completing register + plan payment, then tenant active and POS usable within 15 minutes.
- Given retail vendor, when POS checkout completes, then inventory decrements, order created, customer notified.
- Given salon vendor, when customer books appointment on portal, then slot blocked and staff assigned.

---

## Phase 2 — Growth gaps

**Goal (Prompt.md):** Purchase, accounting lite, loyalty, marketing, multi-store, help desk, integrations, website builder v2, advanced reports.

### What was delivered

- Suppliers, POs, ledger/journals, loyalty, campaigns, stores, tickets, integration endpoints, website pages

### Gaps — must complete to call Phase 2 "done"

| # | Gap | Priority | Deliverables |
| --- | --- | --- | --- |
| 2.1 | **Purchase → GRN → bill flow** incomplete | P1 | Goods receipt, supplier bill, 3-way match |
| 2.2 | **Accounting lite → full tax reports** | P1 | GST/VAT report, payment allocation, AR/AP aging |
| 2.3 | **Marketing campaigns** stub send | P1 | Segment customers, real SMTP/SMS send, open tracking |
| 2.4 | **Loyalty rules engine** missing | P2 | Earn on order, redeem at POS, tiers |
| 2.5 | **Multi-store transfers** missing | P1 | Stock transfer between stores, inter-store reports |
| 2.6 | **Help desk** vendor-only | P1 | Customer portal ticket creation, SLA link |
| 2.7 | **Integrations live** | P0 | Razorpay/Stripe webhooks, Twilio SMS, outbound webhooks |
| 2.8 | **WhatsApp** not built | P2 | Meta Cloud API adapter for notifications |
| 2.9 | **Website Builder v2** missing | P1 | Sections/blocks, drag-order, preview, publish |
| 2.10 | **SEO manager** missing | P1 | Meta title/description, OG tags, sitemap per tenant |
| 2.11 | **Advanced reports** missing | P1 | Product performance, staff sales, inventory valuation |
| 2.12 | **Policy pages** missing | P1 | Terms, privacy, refund policy templates per tenant |
| 2.13 | **Blog module** missing | P2 | Posts, categories, RSS |
| 2.14 | **Delivery module** missing | P2 | Delivery zones, assignment, tracking status |
| 2.15 | **CRM pipeline** missing | P2 | Leads, stages, follow-ups, tags, notes |
| 2.16 | **Shipping integrations** missing | P2 | Shiprocket/EasyPost adapter stub |

### Phase 2 acceptance criteria (remaining)

- Given vendor connects Stripe, when customer pays on storefront, then order marked paid via webhook.
- Given marketing campaign to segment, when sent, then notifications delivered and campaign stats updated.
- Given multi-store vendor, when transferring stock Store A → B, then both ledgers and quantities correct.

---

## Phase 3 — Scale gaps

**Goal (Prompt.md):** Full accounting, automation, AI, marketplace, mobile apps, advanced search, per-tenant DB, fraud/monitoring.

### What was delivered

- Accounting invoices, P&L, balance sheet; automation rules; AI insights/forecast; marketplace listings; search API; monitoring alerts; dedicated-db settings stub

### Gaps — must complete to call Phase 3 "done"

| # | Gap | Priority | Deliverables |
| --- | --- | --- | --- |
| 3.1 | **Automation engine** manual trigger only | P1 | Event-driven triggers (order.created, stock.low), scheduler |
| 3.2 | **AI suite** 2/16 features only | P2 | See [AI gaps section](#ai-strategy-gaps) |
| 3.3 | **Marketplace** listing only | P1 | See [Marketplace gaps section](#marketplace-vision-gaps) |
| 3.4 | **Advanced search** LIKE-only | P1 | Meilisearch index, facets, relevance |
| 3.5 | **Per-tenant DB** stub only | P2 | Provision script, connection router, migration runner |
| 3.6 | **Fraud detection** missing | P2 | Velocity rules, large order alerts (extend monitoring) |
| 3.7 | **White-label mobile apps** deferred | P3 | API freeze doc; Flutter/React Native shell (post Phase 5) |
| 3.8 | **Caching layer** missing | P1 | Redis for sessions, catalog, plan features |
| 3.9 | **Read replicas** not configured | P3 | DB routing for reports/search |
| 3.10 | **Accounting period close** missing | P2 | Lock periods, year-end |
| 3.11 | **Automation UI** no visual builder | P2 | Condition/action builder |
| 3.12 | **Platform analytics** missing | P1 | MRR, churn, active tenants, usage dashboards |

### Phase 3 acceptance criteria (remaining)

- Given automation rule "low stock → create PO draft", when stock hits threshold, then PO draft created without manual run.
- Given marketplace customer, when searching city + category, then ranked vendors returned in &lt; 300ms p95.
- Given enterprise tenant, when dedicated DB enabled, then all queries route to tenant DB with isolation test pass.

---

## Phase 4 — Enterprise gaps

**Goal (Prompt.md):** SLA tooling, advanced ABAC, data residency, ERP workflows, partner/reseller program.

### What was delivered

- SLA policies/incidents, ABAC policies/evaluate, residency profiles, workflow definitions/instances, partners/commissions

### Gaps — must complete to call Phase 4 "done"

| # | Gap | Priority | Deliverables |
| --- | --- | --- | --- |
| 4.1 | **ABAC not enforced** on requests | P1 | Middleware evaluates policies before controller |
| 4.2 | **SLA auto-tracking** missing | P1 | Timer on tickets/orders; breach alerts |
| 4.3 | **Data residency provisioning** stub | P2 | Region-specific storage routing, compliance export |
| 4.4 | **Workflow engine** basic | P2 | Visual designer, approvals, escalations |
| 4.5 | **Partner portal** missing | P2 | Partner login, tenant list, commission statements |
| 4.6 | **GDPR tools** missing | P2 | Data export, right to erasure, consent log |
| 4.7 | **SSO / OAuth** missing | P2 | Google/Microsoft OAuth for vendor staff |
| 4.8 | **MFA** missing | P1 | TOTP for platform admin and vendor owners |
| 4.9 | **Compliance audit pack** missing | P3 | SOC2-ready logging, access reviews |
| 4.10 | **Custom SLA per enterprise tenant** | P3 | Override response/resolution per contract |

### Phase 4 acceptance criteria (remaining)

- Given ABAC policy "accountant cannot delete products", when DELETE /products, then 403 even if RBAC allows.
- Given SLA 4h response on critical ticket, when no response in 3h, then alert escalates to manager.
- Given partner refers tenant, when tenant pays subscription, then commission accrues automatically.

---

## Proposed Phase 5 — SaaS Billing & White-Label Core

**Objective:** Make the platform **commercially sellable** — vendors pay, get branded experience, customers pay vendors.

### Scope

| Workstream | Items |
| --- | --- |
| **Platform billing** | Stripe/Razorpay/PayPal, subscriptions, invoices, proration, dunning, trials, coupons, tax |
| **Feature gating** | Enforce plan limits (modules, seats, stores, API calls) |
| **Tenant branding UI** | Logo, colors, fonts, theme picker, custom domain DNS wizard |
| **Legal & trust** | Terms, privacy, cookie banner, contact page per tenant |
| **Vendor payments** | Tenant-owned gateway for customer checkout (separate from platform billing) |
| **Notification providers** | Per-tenant SMTP, SMS, push config |
| **Business hours & locale** | Hours, holidays, multi-currency display rules |

### Database additions (proposed)

- `subscriptions`, `subscription_invoices`, `payment_methods`, `billing_events`
- `tenant_branding`, `tenant_domains`, `tenant_notification_providers`
- `coupons`, `coupon_redemptions`
- `tenant_business_hours`

### APIs (proposed)

- `POST /api/v1/billing/checkout`, `POST /api/v1/billing/webhooks/{provider}`
- `GET/PUT /api/v1/settings/branding`, `POST /api/v1/settings/domain/verify`
- `GET/PUT /api/v1/settings/notifications`
- `POST /api/v1/commerce/checkout` (customer → vendor payment)

### Web UI (proposed)

- Vendor: Settings → Branding, Domain, Billing, Notifications
- Platform: Billing dashboard, dunning queue, coupon admin
- Storefront: Branded checkout with tenant gateway

### Exit criteria

- Vendor can upgrade Starter → Growth with prorated charge.
- Failed payment triggers dunning email and grace-period suspend.
- Storefront shows vendor brand only (no KarobariSuite on customer-facing pages).

---

## Proposed Phase 6 — Customer Commerce & Portal

**Objective:** Full **B2C experience** per vendor — not marketplace yet.

### Scope

| Workstream | Items |
| --- | --- |
| **Customer auth** | Register, login, password reset on storefront |
| **E-commerce** | Cart, wishlist, checkout, order tracking, returns |
| **Services** | Service catalog, book appointment, pay deposit |
| **Engagement** | Reviews, ratings, loyalty wallet, referrals, membership tiers |
| **Support** | Customer tickets, chat (async), notifications (email/SMS/push) |
| **Customer portal** | Orders, appointments, invoices, loyalty, profile |

### Database additions (proposed)

- `carts`, `cart_items`, `wishlists`, `reviews`, `referrals`
- `customer_wallets`, `memberships`, `chat_threads`, `chat_messages`
- `return_requests`, `delivery_tracking`

### Exit criteria

- Customer completes browse → cart → pay → track without vendor admin intervention.
- Customer leaves review; vendor sees it on product page.
- Loyalty points earned on order and redeemable at next checkout.

---

## Proposed Phase 7 — Marketplace & Advanced AI

**Objective:** Cross-vendor discovery and intelligent platform (Prompt.md long-term vision).

### Marketplace scope

| Feature | Notes |
| --- | --- |
| Discover / compare vendors | Search, filters, categories |
| Compare products & services | Side-by-side, price, ratings |
| Multi-vendor cart | Single checkout split payouts |
| Marketplace checkout | Platform or split payment model |
| Vendor ranking & verification | Badges, KYC, reviews aggregate |
| Geo search | Maps API, nearby vendors |
| AI recommendations | Personalized vendor/product feed |
| Delivery & service tracking | Unified tracking UI |
| Commission model | Tie to Phase 4 partners + billing |

### AI scope (remaining 14 features)

| Feature | Phase |
| --- | --- |
| Dynamic pricing | 7 |
| AI reports (NL queries) | 7 |
| Smart CRM (next-best-action) | 7 |
| Marketing copy generator | 7 |
| Invoice / receipt OCR | 7 |
| Voice ordering / search | 8 |
| Product recommendations | 7 |
| Fraud detection (ML) | 7 |
| Customer segmentation | 7 |
| Demand forecasting (ML) | 7 |
| Business advisor (LLM) | 7 |
| AI assistant (chat) | 7 |
| Inventory forecasting (ML) | 7 |

### Exit criteria

- Customer adds items from 2 vendors, pays once, orders split correctly.
- AI assistant answers "What were my top products last month?" with chart link.

---

## Proposed Phase 8 — Production Ops, Scale & Industry

**Objective:** Operate at **thousands of tenants** with reliability, compliance, and industry packs.

### Scope

| Workstream | Items |
| --- | --- |
| **CI/CD** | GitHub Actions, staging, blue/green deploy |
| **Backups & DR** | Daily full, binlog PITR, restore runbook, RPO/RTO targets |
| **CDN & R2** | Media, exports, static assets per tenant |
| **Caching & queues** | Redis, Horizon-style worker monitoring |
| **Sharding path** | Shard key design, tenant migration tool |
| **Monitoring** | APM, uptime, SLO dashboards, on-call alerts |
| **Security hardening** | WAF, DDoS, penetration test fixes, OWASP checklist |
| **Industry modules** | Retail, Salon, Clinic, Restaurant packs — module toggles per `industry_profile` |
| **Mobile apps** | White-label iOS/Android consuming `/api/v1` |
| **Master design artifacts** | ERD diagrams, flow diagrams, permission matrix PDF, runbooks |

### Exit criteria

- 99.9% uptime month; p95 API &lt; 300ms on catalog read.
- Restore from backup verified quarterly.
- Salon industry profile hides Purchase module, shows Appointments first.

---

## Cross-cutting gap registers

### Multi-tenant SaaS gaps (not phase-specific)

| Requirement | Status | Target phase |
| --- | --- | --- |
| Custom themes | ❌ | 5 |
| Custom fonts | ❌ | 5 |
| Tenant tax rules engine | ❌ | 5 |
| Tenant payment gateways | ❌ | 5 |
| Tenant feature flags | ❌ | 0 (finish) |
| Tenant business hours | ❌ | 5 |
| Tenant storage (R2) | ❌ | 8 |
| Tenant analytics | ❌ | 3 (finish) |
| Tenant AI config | ❌ | 7 |
| Independent databases | 🟡 | 3 (finish) |

### White-label gaps

| Requirement | Target phase |
| --- | --- |
| Own emails | 5 |
| Own SMS / WhatsApp | 5 |
| Own payment gateway | 5 |
| Own SEO | 2 (finish) |
| Own analytics (GA/Pixel) | 6 |
| Own theme | 5 |
| Blog | 2 |
| Policies / terms / privacy / cookie | 5 |
| Remove platform branding on customer surfaces | 5 |

### Platform Super Admin gaps

| Capability | Target phase |
| --- | --- |
| Manage payments | 5 |
| Manage feature flags | 0 |
| Manage themes/templates | 5 |
| Manage backups | 8 |
| Manage fraud detection | 7 |
| View audit logs | 0 |
| Manage announcements | 6 |
| Manage onboarding | 1 (finish) |
| Manage emails/SMS/push globally | 5 |
| Manage CDN/storage/jobs/queues | 8 |

### Security gaps

| Requirement | Target phase |
| --- | --- |
| OAuth / SSO | 4 (finish) |
| MFA | 4 (finish) |
| Audit logs | 0 |
| Rate limiting | 0 |
| Field-level encryption | 8 |
| GDPR export/delete | 4 (finish) |
| PCI (via gateway only) | 5 |

### Database design gaps

| Requirement | Target phase |
| --- | --- |
| Row versioning | 8 |
| History tables (orders, prices) | 6 |
| Consistent `deleted_by` | 0 |
| Billion-row partitioning strategy | 8 |
| Full FK coverage | 0 |

### Testing & documentation gaps

| Item | Target phase |
| --- | --- |
| Tenant isolation test suite | 0 |
| Per-module API tests | 1 |
| Integration tests (webhooks) | 2 |
| E2E web flows (Playwright/manual) | 1 |
| OpenAPI complete & accurate | 0 |
| ERD diagram document | 8 |
| User/vendor/customer/admin flow docs | 8 |
| Deployment runbook | 8 |
| Disaster recovery runbook | 8 |

### Non-functional requirements gaps (Prompt.md targets)

| Target | Current | Gap | Phase |
| --- | --- | --- | --- |
| API p95 &lt; 300ms | Slow (remote DB) | Local DB, caching, indexes | 0, 3, 8 |
| 99.5% availability | Unknown | Monitoring, HA deploy | 8 |
| Daily backup + PITR | ❌ | Backup automation | 8 |
| RPO ≤ 1h / RTO ≤ 4h | ❌ | DR plan | 8 |
| 20+ concurrent POS/tenant | Untested | Load test | 1 |
| Tenant isolation hard fail | 🟡 | Tests + middleware | 0 |

---

## AI strategy gaps

| # | Feature | Current | Phase | Effort |
| --- | --- | --- | --- | --- |
| AI.1 | Inventory forecasting (ML) | Rule-based low stock | 7 | M |
| AI.2 | Sales prediction | Basic forecast | 7 | M |
| AI.3 | Dynamic pricing | ❌ | 7 | L |
| AI.4 | AI reports (NL) | ❌ | 7 | L |
| AI.5 | Smart CRM | ❌ | 7 | M |
| AI.6 | Marketing generator | ❌ | 7 | S |
| AI.7 | Invoice OCR | ❌ | 7 | M |
| AI.8 | Receipt OCR | ❌ | 7 | M |
| AI.9 | Voice ordering | ❌ | 8 | L |
| AI.10 | Voice search | ❌ | 8 | L |
| AI.11 | Product recommendations | ❌ | 7 | M |
| AI.12 | Fraud detection | ❌ | 7 | M |
| AI.13 | Customer segmentation | ❌ | 7 | M |
| AI.14 | Demand forecasting | Partial | 7 | M |
| AI.15 | Business advisor | Rule tips | 7 | M |
| AI.16 | AI assistant (chat) | ❌ | 7 | L |

*Effort: S = small, M = medium, L = large*

---

## Marketplace vision gaps

| # | Feature | Current | Phase |
| --- | --- | --- | --- |
| M.1 | Discover vendors | Listing API | 7 |
| M.2 | Compare vendors | Static marketing only | 7 |
| M.3 | Compare products/services | ❌ | 7 |
| M.4 | Book services (cross-vendor) | Per-vendor only | 7 |
| M.5 | Purchase products (cross-vendor) | Per-vendor only | 7 |
| M.6 | Track delivery/service | ❌ | 6, 7 |
| M.7 | Leave reviews | ❌ | 6 |
| M.8 | Pay online | ❌ | 5, 7 |
| M.9 | Multi-vendor cart | ❌ | 7 |
| M.10 | Marketplace checkout | ❌ | 7 |
| M.11 | Vendor ranking | ❌ | 7 |
| M.12 | Vendor verification | ❌ | 7 |
| M.13 | Nearby vendors | City field only | 7 |
| M.14 | Location-based search | ❌ | 7 |
| M.15 | AI recommendations | ❌ | 7 |

---

## Module-level depth gaps (all 31 modules)

Each module needs the **Prompt.md depth**: workflows, validations, notifications, reports, KPIs. Below: **highest-impact missing depth** per module.

| Module | Missing depth | Phase |
| --- | --- | --- |
| Dashboard | Custom widgets, date ranges, export | 2 |
| Products | Variants, bundles, images (R2), categories | 1–2 |
| Inventory | Transfers, reservations, batch/serial, valuation | 1–2 |
| Sales | Quotes, returns, credit notes | 1 |
| POS | Offline strategy, cash drawer, hold/recall, barcode | 1 |
| Services | Packages, resources, buffers | 1 |
| CRM | Leads, pipeline, tags, notes, merge | 2 |
| Supplier | Vendor rating, payment terms | 2 |
| Purchase | GRN, bill match, returns to supplier | 2 |
| Staff | Shifts, attendance, commission | 2 |
| Roles & Permissions | UI + custom roles per tenant | 1 |
| Appointments | Recurring, waitlist, reminders | 1 |
| Orders | Fulfillment, shipping labels, partial ship | 1–2 |
| Accounting | Bank rec, recurring journals, tax filing | 2–3 |
| Reports | Scheduled reports, PDF export | 2 |
| Marketing | Segments, A/B, templates | 2 |
| Customer Portal | Full self-service (see Phase 6) | 6 |
| Website Builder | Visual builder, sections, forms | 2 |
| E-commerce | Cart persistence, coupons, shipping | 6 |
| Notifications | Provider adapters, templates, preferences | 5 |
| Loyalty | Rules, tiers, expiry | 2 |
| Help Desk | SLA link, CSAT, knowledge base | 2–4 |
| Multi-store | Price lists per store, stock per store reports | 2 |
| SaaS Billing | Full lifecycle (see Phase 5) | 5 |
| Integrations | OAuth for apps, Zapier-style | 2 |
| AI | Full suite (see AI section) | 7 |
| Mobile Apps | iOS/Android shells | 8 |
| Security | MFA, audit, rate limit (see Security) | 0–4 |
| Automation | Event triggers, visual builder | 3 |
| Industry Modules | Profiles + gating | 8 |
| Marketplace | Full vision (see Marketplace) | 7 |

---

## Deliverables master document gaps

`Prompt.md` defines these deliverables. Separate **design docs** still needed:

| Deliverable | Status | Action |
| --- | --- | --- |
| Vision / Product Strategy | ✅ In Prompt.md | — |
| SaaS / White-label / Multi-tenant architecture | 🟡 Partial | `docs/architecture/` diagrams in Phase 8 |
| User Roles | 🟡 In code + Prompt | Permission matrix spreadsheet |
| Complete feature breakdown | 🟡 Prompt + checklist | Keep checklist updated |
| Module hierarchy | ✅ `src/` | — |
| User / vendor / customer / admin flows | ❌ | `docs/flows/*.md` with Mermaid |
| Database design (ERD) | ❌ | `docs/database/erd.md` + dbdiagram |
| API design | 🟡 OpenAPI partial | Complete OpenAPI + examples |
| Security architecture | ❌ | `docs/security.md` |
| AI architecture | ❌ | `docs/ai-architecture.md` |
| Marketplace architecture | ❌ | `docs/marketplace-architecture.md` |
| Mobile strategy | ✅ Deferred in Prompt | `docs/mobile-strategy.md` when Phase 8 |
| Deployment architecture | 🟡 README only | `docs/deployment.md` |
| Scaling strategy | ❌ | `docs/scaling.md` |
| Disaster recovery | ❌ | `docs/disaster-recovery.md` |
| Monitoring / logging | ❌ | `docs/observability.md` |
| Analytics | ❌ | `docs/analytics.md` |
| Billing system design | ❌ | `docs/billing.md` |
| Roadmap | ✅ This doc + Prompt | — |
| Risks & mitigations | ❌ | `docs/risks.md` |

---

## Recommended execution order

Work in this order to maximize revenue readiness:

```
Phase 0 gaps (foundation hardening)
    ↓
Phase 1 gaps (sellable MVP)
    ↓
Phase 5 (billing + white-label)  ← can overlap with Phase 1 tail
    ↓
Phase 2 gaps (growth integrations)
    ↓
Phase 6 (customer commerce)
    ↓
Phase 3 gaps (scale: search, automation events)
    ↓
Phase 4 gaps (enterprise enforcement)
    ↓
Phase 7 (marketplace + AI)
    ↓
Phase 8 (ops, industry, mobile)
```

### Sprint-sized next 10 tasks (suggested)

1. Tenant isolation PHPUnit suite  
2. Permission enforcement middleware on all APIs  
3. Feature gating from `subscription_plans.features_json`  
4. Stripe subscription checkout + webhook  
5. Tenant branding settings API + web UI  
6. Customer portal: cart + checkout flow  
7. POS: tax, discount, refund  
8. Audit log service + super-admin viewer  
9. SMTP notification send (order confirm)  
10. OpenAPI sync with all routes  

---

## Risk register (gap-related)

| Risk | Impact | Mitigation | Phase |
| --- | --- | --- | --- |
| No billing = no revenue | High | Phase 5 Stripe integration | 5 |
| Weak tenant isolation | Critical | Phase 0 tests + middleware | 0 |
| Remote DB latency | High | Local dev DB; connection pooling | 0, 8 |
| No backups | Critical | Automated backup + restore test | 8 |
| Stub notifications | Medium | Real SMTP/SMS in Phase 2/5 | 2, 5 |
| ABAC not enforced | Medium | Request middleware | 4 |
| No rate limiting | Medium | API gateway middleware | 0 |
| Incomplete customer portal | High | Phase 6 | 6 |
| Marketplace without payments | High | Phase 5 before Phase 7 | 5 → 7 |

---

## How to use this document

1. **Pick a phase** from the execution order.  
2. **Pull gap IDs** (e.g. `0.1`, `1.4`, `5.x`) into your sprint backlog.  
3. **Mark complete** in this file and update [`Requirements-Coverage-Checklist.md`](Requirements-Coverage-Checklist.md).  
4. **Do not skip Phase 0/1 gaps** — they block security and revenue.

---

## Document index

| Document | Purpose |
| --- | --- |
| [`Prompt.md`](Prompt.md) | Full product vision and original phase definitions |
| [`Requirements-Coverage-Checklist.md`](Requirements-Coverage-Checklist.md) | What exists today (✅/🟡/❌) |
| **This file** | What is missing and which phase closes each gap |
| `README.md` | Local setup |

*End of gap analysis.*
