# Architecture ## Clean Architecture Presentation, Application, Domain, Infrastructure. ## Pola Wajib - Repository Pattern - Service Layer - DTO - Event Driven - Queue Based Processing ## Larangan - Business Logic di Controller - Query Database di Controller - Hardcoded Secret --- ## Status Implementasi (geonet-console vs cursor-exsisting) Referensi audit: `cursor-exsisting/00-global.mdc`, struktur `geonet-console/app/`, tanggal 2026-06-12. ### Clean Architecture | Lapisan | Status | Catatan | Dapat diimplementasi | |---------|--------|---------|----------------------| | Presentation | ✅ Sudah | Controllers, Blade views, middleware, JS shell (`layouts/app`, `app-shell`). | Sudah ada | | Application | ⚠️ Partial | 15+ Service classes menangani use case. Tidak ada use-case class terpisah / command handler formal. | Ya — refactor ke Actions/UseCases | | Domain | ❌ Belum | Tidak ada folder Domain, entity rich, atau domain event. Model Eloquent = anemic data holder. | Ya — ekstrak domain rules dari service | | Infrastructure | ✅ Sudah | LDAP (`LdapConnection`), PostgreSQL, SQL Server/MySQL driver, mail SMTP, Passport OAuth. | Sudah ada | **Kesimpulan Clean Architecture:** struktur praktis Laravel service-oriented, **bukan** clean architecture penuh 4 lapisan. ### Pola Wajib | Pola | Status | Catatan | Dapat diimplementasi | |------|--------|---------|----------------------| | Repository Pattern | ❌ Belum | Eloquent `::query()` langsung di Service & Controller. Hanya `ClientRepository` (Passport). Ada `Contracts/DatabaseListerInterface` sebagai strategy, bukan repository CRUD. | Ya — buat repository per aggregate (Audit, DatabaseConnection, LdapMeta) | | Service Layer | ✅ Sudah | `AuditLogService`, `LdapUserService`, `DatabaseConnectionManager`, `ApiAuthService`, dll. Controller mayoritas delegasi ke service. | Sudah ada | | DTO | ❌ Belum | Tidak ada kelas DTO formal. `ApiActor` (support class) dan array associative dipakai antar layer. | Ya — Spatie Data / readonly DTO per request-response | | Event Driven | ❌ Belum | Tidak ada `Event::`, listener, atau domain event aplikasi. Hanya dependency Symfony di vendor. | Ya — event untuk audit, mail, LDAP changes | | Queue Based Processing | ❌ Belum | Tidak ada job queue, worker, atau `ShouldQueue`. Semua proses sinkron (LDAP, mail, audit). | Ya — queue mail, audit batch, LDAP sync | ### Larangan | Larangan | Status | Catatan | Dapat diimplementasi | |----------|--------|---------|----------------------| | Business Logic di Controller | ⚠️ Partial | Mayoritas tipis & delegasi service. **Pelanggaran:** `LdapUserController` (merge/sort hasil search+meta), `LdapGroupController` (merge meta search). Validasi/sort param masih di controller (acceptable). | Ya — pindah merge/sort ke service | | Query Database di Controller | ⚠️ Partial | **Pelanggaran langsung:** `DatabaseConnectionController` → `DatabaseConnection::query()`, `LdapGroupController` → `LdapGroupMeta::query()`. Service lain juga pakai Eloquent langsung (bukan di controller). | Ya — pindah ke repository/service | | Hardcoded Secret | ⚠️ Partial | Secret operasional dari `.env` / `Crypt`. **Risiko:** default password di `compose.yaml` & `.env.example` (`audit_secret_change_me`), preview URL di `EmailTemplateService`. Tidak ada secret di source code produksi. | Ya — wajib ganti default di deploy; hapus placeholder sensitif | ### Kaitan dengan cursor-exsisting (UI/UX) | Aspek arsitektur | Dampak UI | Status | |------------------|-----------|--------| | Tanpa maker-checker | Tidak ada approval queue UI | ❌ (`cursor-exsisting/12-gaps-rekomendasi.mdc`) | | Tanpa event/queue | Loading overlay sinkron saja, tidak ada job progress | ⚠️ | | Service layer kuat | Pola halaman konsisten (list panel, form card) | ✅ | | Turbo SPA | Presentation layer modern tanpa SPA framework berat | ✅ (`cursor-exsisting/09-spa-navigation.mdc`) | ### Ringkasan 01-architecture - **Sudah (2):** Service Layer, Presentation + Infrastructure layer praktis - **Partial (3):** Clean Architecture (Application), larangan logic/query di Controller, Hardcoded Secret - **Belum (4):** Domain layer, Repository Pattern, DTO, Event Driven, Queue Based Processing