# 7. Roadmap Teknis Pengembangan & Implementasi

## Tech Stack (Rekomendasi)

| Layer | Pilihan |
|-------|---------|
| Backend | Laravel 11+ (PHP 8.2+), MySQL 8 / PostgreSQL 15 |
| Frontend (Admin/POS) | Blade + Alpine.js atau Vue 3 / React; Tailwind CSS 4 |
| API | REST, JSON; optional GraphQL fase lanjut |
| Queue/Cache | Redis |
| Auth | Laravel Sanctum (SPA/API) + session (web) |
| Testing | PHPUnit, Pest; front-end: Vitest/Playwright jika pakai SPA |

---

## 🟢 PHASE 1 – FOUNDATION (0–3 BULAN)

**Target:** Sistem bisa jual & dipakai operasional dasar.

### Milestone 1.1 – Setup & Auth (Minggu 1–3)

| Deliverable | Detail |
|-------------|--------|
| Struktur modul | Folder `modules/`, autoload PSR-4, route service provider per modul |
| Auth & User | Login/logout, session; tabel `users`, `roles`, `permissions`, `user_outlets` |
| RBAC dasar | Middleware permission, policy untuk akses outlet |
| Landing & Login UI | Halaman login modern (design system); redirect role-based |

### Milestone 1.2 – Outlet & Menu (Minggu 4–6)

| Deliverable | Detail |
|-------------|--------|
| Outlet CRUD | Master outlet, setting (jam, pajak, currency) |
| Menu CRUD | Category, Product, Modifier; per outlet |
| Harga & availability | Harga dasar, optional schedule price; flag is_available |
| UI Admin | List/create/edit outlet & menu (tabel + form) |

### Milestone 1.3 – Order & POS (Minggu 7–11)

| Deliverable | Detail |
|-------------|--------|
| Order lifecycle | Create order (dine-in/takeaway), status flow, OrderItem, OrderPayment |
| POS session | Open/close shift, cash drawer, link order ke session |
| Payment | Cash + satu metode non-cash (transfer/EDC); simpan payment log |
| API Order | Create, list, update status (untuk POS & nanti KDS) |
| UI POS | Halaman POS: pilih meja/item, cart, payment, receipt (print optional) |

### Milestone 1.4 – Basic Report (Minggu 12)

| Deliverable | Detail |
|-------------|--------|
| Sales summary | Per hari/outlet: revenue, jumlah order, payment method |
| Export | CSV/Excel dasar untuk sales |
| UI Report | Halaman report dengan filter date & outlet |

**Exit criteria Phase 1:** Satu outlet bisa dipakai full: login → buka shift → order → bayar → tutup shift → lihat laporan.

---

## 🟡 PHASE 2 – OPERATIONAL POWER (3–6 BULAN)

### Milestone 2.1 – Kitchen (KDS)

- KitchenStation, KitchenOrder; tampilkan order by station, timer, status cooking/ready.
- UI: Kitchen Display (fullscreen/touch); update real-time (polling atau WebSocket).

### Milestone 2.2 – Inventory (Dasar)

- Ingredient, Stock, StockMovement; auto deduction dari recipe (optional) atau manual.
- Alert stok minimum; UI stok & movement log.

### Milestone 2.3 – Promotion

- Voucher (kode, nominal/percent), valid date; apply di order.
- Promotion rule (min order, buy X get Y); scheduler promo.

### Milestone 2.4 – Customer & Loyalty (Dasar)

- Customer profile (nama, phone, email); link ke order.
- Points earn/redeem; tier sederhana (optional).

### Milestone 2.5 – Delivery Integration

- Order type delivery; alamat, ongkir (manual atau integrasi eksternal).
- Status delivery (preparing, on the way, delivered).

**Exit criteria Phase 2:** Operasional lengkap: KDS, stok, promo, pelanggan, delivery dasar.

---

## 🔵 PHASE 3 – SCALE & SAAS (6–12 BULAN)

### Fokus

- **Multi-outlet:** Filter & assignment user-outlet; report per outlet & consolidated.
- **Performance:** Index DB, cache menu/config, queue report berat.
- **API public:** Dokumentasi (OpenAPI), rate limit, API key per client.
- **Subscription & billing:** Paket (Starter/Pro/Enterprise); feature toggle per paket; billing cycle.
- **UX polish:** Onboarding, help, notifikasi in-app.

### Prioritas Awal (saat mulai Phase 3)

| No | Item | Keterangan singkat |
|----|------|--------------------|
| 1 | **API documentation (OpenAPI)** | Dokumentasi endpoint Order & Menu (Swagger/OpenAPI); memudahkan integrasi & onboarding developer. |
| 2 | **Rate limit & API key** | Rate limit per IP/endpoint; API key per client (tabel `api_clients`); middleware auth API key. |
| 3 | **Cache menu/config** | ✅ Cache categories & products per outlet (TTL 5 menit); invalidate saat CRUD Category/Product; `App\Services\MenuCache`. |
| 4 | **Queue report berat** | ✅ Export Penjualan/Pembelian/Staf via antrian (ExportReportJob); tabel report_exports; halaman Daftar Export & unduh. |
| 5 | **Report consolidated multi-outlet** | ✅ Laporan Ringkasan (GET /reports/consolidated): revenue & order count per outlet + total gabungan; filter periode; hanya outlet user. |
| 6 | **Feature toggle (per outlet / global)** | ✅ config/features.php + Feature::enabled($key, $outlet); override per outlet via outlet_settings (feature_*); POS respect loyalty, voucher, delivery. |
| 7 | **Subscription & billing** | ✅ Fondasi: tabel `plans`, `outlets.plan_id`, assign plan di edit outlet. **Billing dasar:** tabel `subscription_invoices`, buat invoice (outlet, periode, jumlah), daftar + filter, detail + tandai lunas; permission billing.manage. Gateway pembayaran (Stripe/Midtrans) lanjut. |
| 8 | **Gateway Pembayaran (Midtrans/QRIS)** | ✅ Integrasi Midtrans Snap untuk QRIS di POS. MidtransService + MidtransController; webhook callback; feature toggle `midtrans` per outlet. Docs: `18-PAYMENT-GATEWAY-INTEGRATION.md` |

---

## 🔴 PHASE 4 – ENTERPRISE & AI (12+ BULAN)

### Fokus

- **Reporting microservice:** Extract report ke service terpisah; aggregate dari event/DB copy.
- **AI forecasting:** Demand prediction, reorder suggestion (bahan).
- **Franchise module:** Multi-tenant kuat, franchisee vs franchisor role, royalty report.
- **Third-party marketplace:** Integrasi order dari marketplace (Gojek, Grab, dll).

---

## Checklist Per Sprint (Contoh Phase 1)

- [ ] Task breakdown per modul (Auth, Outlet, Menu, Order, POS).
- [ ] Migrasi + seeder untuk dev.
- [ ] API endpoint + test (feature test).
- [ ] Policy untuk aksi sensitif.
- [ ] UI mengikuti design system (warna, spacing, komponen).
- [ ] Dokumentasi endpoint (Postman/OpenAPI) update.
