# 4. Blueprint Modul (Detail Per Modul)

## 🔹 1. Auth & User Module

**Fungsi:** Login, session, role & permission, multi-outlet access.

**Entitas:** `User`, `Role`, `Permission`, `UserOutlet`.

**API (konsep):** `POST /login`, `POST /logout`, `GET /me`, `GET /permissions`, `GET /outlets`.

**Event:** `UserLoggedIn`, `UserLoggedOut`. **Catatan:** Role-based dari awal; siap SSO nanti.

---

## 🔹 2. Outlet & Branch Module

**Fungsi:** Master outlet, jam operasional, pajak & service charge, printer & device.

**Entitas:** `Outlet`, `OutletSetting`, `OutletDevice`.

**API:** CRUD outlet, update setting, list devices. **Catatan:** Timezone & currency per outlet.

---

## 🔹 3. Menu & Product Module

**Fungsi:** Kategori, produk, modifier/add-on, harga dinamis, recipe mapping.

**Entitas:** `Category`, `Product`, `Modifier`, `Recipe`, `Ingredient`.

**API:** CRUD category/product/modifier, list by outlet, price list. **Event:** `ProductUpdated` (untuk cache/clear).

---

## 🔹 4. Order Module (CORE)

**Fungsi:** Dine-in / Takeaway / Delivery, QR Order, status lifecycle, split & merge.

**Lifecycle:** `CREATED → CONFIRMED → COOKING → READY → COMPLETED` (plus `CANCELLED`, `REFUNDED`).

**Entitas:** `Order`, `OrderItem`, `OrderPayment`, `OrderStatusLog`.

**API:** Create order, list by outlet/date/status, update status, split/merge. **Event:** `OrderCreated`, `OrderStatusChanged`, `OrderPaid`, `OrderCompleted`.

**Catatan:** Modul ini “jantung sistem”; dependency minimal ke modul lain (User, Outlet, Menu).

---

## 🔹 5. POS Module

**Fungsi:** Kasir, offline-first, split payment, shift kasir.

**Entitas:** `POSSession`, `CashDrawer`, `PaymentMethod`, `Transaction`.

**API:** Open/close session, add payment, list transactions. **Event:** `POSSessionOpened`, `POSSessionClosed`, `PaymentCompleted`.

---

## 🔹 6. Kitchen Module (KDS)

**Fungsi:** Display order dapur, station-based, timer & SLA, re-fire.

**Entitas:** `KitchenStation`, `KitchenOrder`, `CookingLog`.

**API:** List orders by station/status, start cooking, mark ready, re-fire. **Event:** `OrderSentToKitchen`, `OrderItemCooking`, `OrderItemReady`.

---

## 🔹 7. Inventory Module

**Fungsi:** Stok bahan, auto deduction, waste, supplier & PO.

**Entitas:** `Ingredient`, `Stock`, `StockMovement`, `Supplier`, `PurchaseOrder`.

**API:** CRUD ingredient/stock/supplier/PO, movement log. **Event:** `StockReduced`, `StockAdjusted`, `PurchaseOrderCreated`.

---

## 🔹 8. Customer & Loyalty Module

**Fungsi:** Database pelanggan, point & tier, riwayat, feedback.

**Entitas:** `Customer`, `LoyaltyPoint`, `LoyaltyTier`, `CustomerFeedback`.

**API:** CRUD customer, points/tier, history, feedback. **Event:** `CustomerRegistered`, `PointsEarned`, `FeedbackSubmitted`.

---

## 🔹 9. Promotion Module

**Fungsi:** Voucher, diskon, bundling, scheduler promo.

**Entitas:** `Promotion`, `Voucher`, `PromotionRule`.

**API:** CRUD promotion/voucher, validate voucher, list active. **Event:** `PromotionApplied`, `VoucherRedeemed`.

---

## 🔹 10. Payment Module

**Fungsi:** Gateway, settlement, refund, payment log.

**Entitas:** `Payment`, `PaymentLog`, `Refund`.

**API:** Create payment, refund, list by order/outlet. **Event:** `PaymentCompleted`, `RefundRequested`, `RefundCompleted`.

---

## 🔹 11. Report & Analytics Module

**Fungsi:** Laporan penjualan, profit & margin, staff, perbandingan outlet.

**Entitas:** `ReportSnapshot`, `SalesSummary`, `CostSummary`.

**API:** Report by date range, outlet, format (JSON/export). **Catatan:** Calon microservice pertama (heavy read, bisa async).

---

## 🔹 12. System & Config Module

**Fungsi:** Global config, audit log, activity log, feature toggle.

**Entitas:** `SystemConfig`, `AuditLog`, `ActivityLog`, `FeatureToggle`.

**API:** Config (admin only), audit/activity list, toggle. **Event:** `ConfigUpdated`, `AuditLogged`.
