Skip to content

Modul (Frontend)

Ringkasan

Modul fitur frontend berlokasi di resources/js/modules/. Setiap modul punya component, store, services, API layer, dan types sendiri — mengikuti pattern stores→services→api.


Struktur Folder

modules/landing/
├── setup/          → Wizard setup
├── schools/        → Profil sekolah
├── recruitment/    → Portal karir
├── articles/       → Berita & artikel
└── commons/        → Pattern bersama (dropdown, language, chatbot)

Struktur Internal Modul

module/
├── Index.svelte        # Entry point
├── api/                # Fetch functions
├── parts/              # Sub-komponen
├── services/           # Business logic
├── stores/             # State management
│   └── entry/          # Store groups + barrel index.ts
├── types/              # TypeScript interfaces
└── __tests__/          # Vitest tests

Pattern stores→services→api

Component → Store → Service → API → Backend
LayerTanggung jawab
ComponentRender UI, panggil store action, subscribe
StoreKelola StateContainer, expose getters/actions
ServiceOrchestrasi API, transform data
APIHTTP fetch, typed responses

Aturan Ketat

  • Component → Store (BUKAN langsung Service/API)
  • Store → Service (BUKAN langsung API)
  • Service → API (BUKAN fetch langsung)

Store Pattern

Semua store pakai StateContainer<TData> dari @/types/state:

typescript
interface StateContainer<TData> {
    meta: StateMeta;     // loading, initialized, updatedAt, errorAt
    data: TData;         // domain data
    errors: StateErrors; // validation errors
}

Nama File

<aksi>-<modul>.stores.ts — contoh: fetch-bulletin.stores.ts


File Penting

FileTujuan
resources/js/lib/state.tsDefinisi StateContainer<TData>
resources/js/lib/i18n.svelte.tsFungsi t() untuk translasi
resources/js/modules/Semua modul fitur