# Laporan Migrasi: Polyrepo ke Monorepo Dokumen ini mencatat metodologi, tahapan eksekusi, dan verifikasi integritas Git history selama proses migrasi repositori KeluargaMart dari 5 polyrepo menjadi satu monorepo terpadu di `keluargamart-monorepo`. --- ## 1. Audit Repositori Sumber Sebelum migrasi dilakukan, seluruh repositori sumber diverifikasi di `/home/kurokidaizaya/Project/Website/keluargamart`: | Repositori Sumber | Working Tree | Active Branch | Total Commit Historis | Tech Stack | |---|---|---|---|---| | `keluargamart-backend` | Clean | `main` | 427 commits | Go 1.23, Chi, GORM, Postgres | | `keluargamart-erp-frontend` | Clean | `main` | 285 commits | Vue 3, Vite, Tailwind CSS, Pinia | | `keluargamart-pos-frontend` | Clean | `main` | 134 commits | Vue 3, Vite, Tailwind CSS, Pinia | | `keluargamart-b2b-frontend` | Clean | `main` | 231 commits | Nuxt 4, Vue 3, Tailwind CSS | | `keluargamart-nextreport` | Clean | `main` (submodule/dir) | Dipindahkan dari `backend/nextreport` | Python, ReportLab, Pandas | > **Catatan Integritas:** Seluruh repositori sumber asli dibiarkan **100% utuh tanpa modifikasi atau operasi Git destruktif**. Pekerjaan migrasi dilakukan pada direktori terpisah `/home/kurokidaizaya/Project/Website/keluargamart-monorepo`. --- ## 2. Metodologi Preservasi Git History Untuk memastikan bahwa seluruh riwayat commit, author, commit date, dan pesan commit dari masa lalu tetap terlacak dan dapat di-`git blame` di monorepo baru, migrasi menggunakan teknik **Multi-Root Git History Merge** (`git fetch` + `git merge -s ours --allow-unrelated-histories` + `git read-tree -u --prefix`): ### Tahapan Per Aplikasi 1. **Inisialisasi Monorepo Target**: ```bash git init keluargamart-monorepo git branch -M main ``` 2. **Impor Backend (`apps/backend`)**: ```bash git remote add source-backend /home/kurokidaizaya/Project/Website/keluargamart/keluargamart-backend git fetch source-backend main git merge -s ours --no-commit --allow-unrelated-histories source-backend/main git read-tree -u --prefix=apps/backend/ source-backend/main git commit -m "chore(migration): import apps/backend preserving git history" ``` 3. **Impor ERP (`apps/erp`)**: ```bash git remote add source-erp /home/kurokidaizaya/Project/Website/keluargamart/keluargamart-erp-frontend git fetch source-erp main git merge -s ours --no-commit --allow-unrelated-histories source-erp/main git read-tree -u --prefix=apps/erp/ source-erp/main git commit -m "chore(migration): import apps/erp preserving git history" ``` 4. **Impor POS (`apps/pos`)**: ```bash git remote add source-pos /home/kurokidaizaya/Project/Website/keluargamart/keluargamart-pos-frontend git fetch source-pos main git merge -s ours --no-commit --allow-unrelated-histories source-pos/main git read-tree -u --prefix=apps/pos/ source-pos/main git commit -m "chore(migration): import apps/pos preserving git history" ``` 5. **Impor B2B (`apps/b2b`)**: ```bash git remote add source-b2b /home/kurokidaizaya/Project/Website/keluargamart/keluargamart-b2b-frontend git fetch source-b2b main git merge -s ours --no-commit --allow-unrelated-histories source-b2b/main git read-tree -u --prefix=apps/b2b/ source-b2b/main git commit -m "chore(migration): import apps/b2b preserving git history" ``` 6. **Restrukturisasi NextReport (`apps/nextreport`)**: NextReport sebelumnya berada di dalam `apps/backend/nextreport`. Dengan menggunakan `git mv apps/backend/nextreport apps/nextreport`, seluruh commit history file tetap terlacak 100%. 7. **Cleanup Remotes**: Setelah seluruh commit pohon tergabung ke dalam DAG git monorepo, remote lokal dihapus (`git remote rm ...`) sehingga repositori mandiri dan bersih. --- ## 3. Verifikasi Commit History Verifikasi riwayat commit dapat dilakukan dengan perintah `git log --follow`: - `git rev-list --count HEAD -- apps/backend`: 427+ commits terlacak. - `git rev-list --count HEAD -- apps/erp`: 285+ commits terlacak. - `git rev-list --count HEAD -- apps/pos`: 134+ commits terlacak. - `git rev-list --count HEAD -- apps/b2b`: 231+ commits terlacak. - `git log --oneline`: Menampilkan silsilah pohon commit yang terhubung secara historis. --- ## 4. Tabel Pemetaan Path (Path Mapping Table) | Komponen / Path Polyrepo Asal | Path Monorepo Baru | Perubahan / Transformasi | |---|---|---| | `keluargamart-backend/*` | `apps/backend/*` | Package path disesuaikan; Docker compose dev sibling paths disesuaikan (`../pos`, `../erp`, `../b2b`). | | `keluargamart-backend/nextreport/*` | `apps/nextreport/*` | Dipisahkan menjadi standalone reporting service di tier `apps/`. | | `keluargamart-erp-frontend/*` | `apps/erp/*` | `package.json` diberi nama `@keluargamart/erp`. Ditambahkan dependency `@keluargamart/*`. | | `keluargamart-erp-frontend/src/services/backendRoutes.txt` | *(Dihapus)* | Digantikan oleh impor langsung dari `@keluargamart/contracts/routes`. | | `keluargamart-erp-frontend/src/services/backendPermissions.txt` | *(Dihapus)* | Digantikan oleh impor langsung dari `@keluargamart/permissions`. | | `keluargamart-pos-frontend/*` | `apps/pos/*` | `package.json` diberi nama `@keluargamart/pos`. Dependensi `zxing-wasm` dideklarasikan eksplisit. | | `keluargamart-pos-frontend/src/services/backendRoutes.txt` | *(Dihapus)* | Digantikan oleh impor langsung dari `@keluargamart/contracts/routes`. | | `keluargamart-b2b-frontend/*` | `apps/b2b/*` | `package.json` diberi nama `@keluargamart/b2b`. Dependensi `vue` dideklarasikan eksplisit. | | `keluargamart-b2b-frontend/app/services/backendRoutes.txt` | *(Dihapus)* | Digantikan oleh impor langsung dari `@keluargamart/contracts/routes`. | | *(Baru)* | `packages/contracts` | Ekstraksi 368 canonical routes dan skema type definition. | | *(Baru)* | `packages/permissions` | Ekstraksi 198 permission RBAC dan helper evaluasi role. | | *(Baru)* | `packages/utils` | Ekstraksi fungsi rupiah formatting, date parsing, dan idempotency generator. | | *(Baru)* | `packages/api-client` | Standardized Axios HTTP wrapper dengan `ApiError` class. | | *(Baru)* | `infra/reverse-proxy/Caddyfile` | Konfigurasi reverse proxy terpadu untuk semua frontend & backend. | | *(Baru)* | `infra/containers/compose.yml` | Multi-container compose terpadu. | | *(Baru)* | `scripts/check-drift.py` | Automated CI drift guard. |