# Module Roadmap — Legacy → New System

  Status legend: ✅ done · 🚧 in progress · ⬜ planned

  ## Phase 0 — Foundations (done)

  | Legacy module | New module | API | Frontend |
  |---|---|---|---|
  | Auth (Sanctum) | `auth` | ✅ | ✅ |
  | Tenant (stancl) | `tenants` | ✅ | ✅ login picker |
  | Users | `users` | ✅ | ✅ |
  | Roles + Permissions (spatie) | `roles` | ✅ | ✅ |
  | Offices | `offices` | ✅ | ✅ |

  ## Phase 1 — Foundation primitives + Members

  | Legacy module | New module | Status |
  |---|---|---|
  | — | `PageHeader`, `DataTable`, `AppShell` v2, `FormField` | 🚧 |
  | Address (Province/District/LocalGovt) | `address` master + AddressPicker primitive | ⬜ |
  | — | NepaliDatePicker, BS↔AD util | ⬜ |
  | Member (members) | `members` (CRUD + KYC + photo) | ⬜ |
  | MemberRelation, MemberFiles | `members.relations`, `members.attachments` | ⬜ |

  ## Phase 2 — Loan applications + office records

  | Legacy module | New module |
  |---|---|
  | Applicant + ApplicantSaving + ApplicantIncome + ApplicantBusinessIncome + ApplicantChargeDetails | `applications` |
  | GuarantorDetails + GuarantorSanchi + ApplicantGuarantorNetworth | `applications.guarantors` |
  | ApplicationDocument + ApplicantAttachments | `applications.documents` |
  | Collateral* (Home, Vehicle, Microfinance, Salary, Periodic, General, Other) | `collaterals` (polymorphic) |
  | DartaChalani | `darta-chalani` |
  | Master/* (LoanPurpose, LoanTitle, Insurance, Saving, etc.) | `master` |

  ## Phase 3 — Credit workflow, files, reports

  | Legacy module | New module |
  |---|---|
  | ApplicationForward + Recommendation + FinalApprovalStatus | `applications.workflow` |
  | NewCreditAnalysis + OldCreditAnalysis | `credit-analysis` |
  | FileManager (File, FileSharing, FileTag, FileTrash) | `file-manager` |
  | Template (LetterAutomation, Template, etc.) | `letters` |
  | Report (50+ report types) | `reports` |
  | Minute (board meetings) | `minutes` |
  | CRM (Lead, Task, DocumentExpiry) | `crm` |
  | TaskManagement | `tasks` |

  ## Phase 4 — Specialized modules

  | Legacy module | New module |
  |---|---|
  | Auction* (10 models) | `auctions` |
  | Blacklist | `blacklist` |
  | MortageAppraisal* (8 models) | `mortgage-appraisal` |
  | TaketaPatra | `taketa-patra` |
  | LetterAutomation | `letter-automation` |
  | OnlyOffice document editor | `document-editor` |

  ## Phase 5 — Member-facing portal + mobile

  | Legacy module | New module |
  |---|---|
  | Online/Member/* (member self-service) | `portal` (Expo + web) |

  ## Modules deliberately consolidated

  The legacy system has **183 models**. Many are 1-row sub-tables that can be inlined or normalized. We will document each consolidation in `docs/MIGRATION_NOTES.md` as the corresponding module is ported, e.g.:

  - **60+ "lookup" endpoints** in `HomeController` → single `/api/lookups/:type` endpoint with cached responses.
  - **Per-collateral controllers** (Home, Vehicle, Microfinance, Salary, Periodic, General, Other = 7 controllers) → one polymorphic `collaterals` module.
  - **AuctionLetter / AuctionPresenceLetter / AuctionNoticeLetterPublish** (3 near-identical letter models) → unified `auction-letters` table with a `type` discriminator.
  - **OldCreditAnalysis vs NewCreditAnalysis** → single `credit-analysis` table with `schema_version` column.
  