# 3. Struktur Modular (Laravel Monolith)

## 📁 Struktur Modul Konseptual

```
/modules
  /Auth
  /User
  /Outlet
  /Menu
  /Order
  /POS
  /Kitchen
  /Inventory
  /Customer
  /Promotion
  /Payment
  /Report
  /System
```

## ✅ Setiap Modul Wajib Memiliki

| Komponen | Path (contoh) | Fungsi |
|----------|----------------|--------|
| **Controller (API)** | `Modules/Order/Http/Controllers/Api/` | Endpoint API (JSON). |
| **Controller (Web)** | `Modules/Order/Http/Controllers/Web/` | Halaman Blade/response web. |
| **Service** | `Modules/Order/Services/` | Business logic (create order, update status). |
| **Repository** | `Modules/Order/Repositories/` | Data access (query, persist). |
| **Model** | `Modules/Order/Models/` | Eloquent entity. |
| **Policy** | `Modules/Order/Policies/` | Authorization (can update, delete). |
| **Event** | `Modules/Order/Events/` | Domain events (OrderCreated, dll). |
| **Listener** | `Modules/Order/Listeners/` | Reaksi terhadap event (notify, sync). |
| **Request (Form)** | `Modules/Order/Http/Requests/` | Validasi input. |
| **Resource (API)** | `Modules/Order/Http/Resources/` | Transform model ke JSON. |
| **Routes** | `Modules/Order/Routes/` | api.php, web.php per modul. |

## Konvensi Naming

- **Model:** singular, PascalCase (e.g. `Order`, `OrderItem`).
- **Service:** suffix `Service` (e.g. `OrderService`, `OrderPaymentService`).
- **Repository:** suffix `Repository` (e.g. `OrderRepository`).
- **Event:** past tense (e.g. `OrderCreated`, `OrderPaid`).
- **Controller:** suffix `Controller`; API di folder `Api/`, Web di `Web/`.

## Dependency Antar Modul

- **Core (digunakan banyak modul):** Auth, User, Outlet, Menu.
- **Order** tergantung: Auth, User, Outlet, Menu (untuk item).
- **POS** tergantung: Order, Payment, User.
- **Kitchen** tergantung: Order.
- **Report** boleh depend on banyak modul (read-only / event).

Modul jangan circular dependency; jika perlu koordinasi, gunakan event.
