Full rewrite strategy for diagnostic.ly — leveraging AI-assisted development at 10–50x speed
AI-first development fundamentally changes the rewrite calculus
Three factors that propped up "stay on Laravel" have collapsed with AI-first development:
| Factor | Before | Now |
|---|---|---|
| Migration risk | HIGH (months) | LOW (weeks) |
| Team language expertise | Critical | Irrelevant |
| Code reuse value | 80K LOC | Regenerable |
| Ramp-up time | Weeks | Zero |
| Criterion | Weight | A: Stay Laravel | B: Laravel+SPA | C: Next.js | D: .NET | E: Django |
|---|---|---|---|---|---|---|
| Migration risk | ×1 | 5 | 4 | 3 | 2 | 3 |
| Time to first feature | ×2 | 5 | 4 | 3 | 2 | 3 |
| Frontend UX capability | ×3 | 2 | 5 | 5 | 3 | 2 |
| API-first architecture | ×3 | 3 | 5 | 5 | 5 | 4 |
| AI/ML integration | ×3 | 2 | 3 | 4 | 2 | 5 |
| Real-time capabilities | ×2 | 3 | 4 | 5 | 4 | 3 |
| Long-term scalability | ×2 | 3 | 4 | 5 | 5 | 4 |
| AI-assisted dev velocity | ×3 | 3 | 4 | 5 | 3 | 4 |
| Type safety / AI accuracy | ×2 | 2 | 3 | 5 | 5 | 3 |
| Weighted Total | 64 | 82 | 92 | 72 | 72 |
Modern TypeScript stack optimized for AI-assisted development
106 MySQL tables mapped to Prisma schema — zero data loss
prisma db pull to auto-generate Prisma schema from live databaseaccounts → Account), add Zod validators| Domain | Tables | Complexity |
|---|---|---|
| Geographic hierarchy | regions, sub_regions, countries, states, cities | Seed data |
| Accounts & Users | accounts, users, account_users, roles, permissions | Core |
| Messaging | messaging_options, messaging_templates, messaging_sets, comm_logs | Core |
| Documents | document_manager_ui_representations, shared_documents, permissions | Complex |
| Products | products, bundles, bundle_items, media | Core |
| Settings | global_settings, application_settings, account_settings, ecommerce | Key-value |
| Education | education_flows, purpose_flows, screen_configs | Simple |
| Direct mail | triggers_by_account, postage_types, send_mail_timings | Simple |
| Field mappings | field_mapping_categories, mapping_types, networks | Core |
| Support & misc | support_entities, case_notes, telemedicine, activity_log | Simple |
// AccountRepository.php (17KB)
$account = Accounts::with(['users', 'languages'])
->where('is_active', 1)
->findOrFail($decoded);
// No type safety on query results
// Hashids encoding in BaseModel
// Activity logging via Spatie trait
// account.router.ts
const account = await prisma.account.findUniqueOrThrow({
where: { id: decodeHashid(input.hashid) },
include: { users: true, languages: true },
});
// Full type inference on result
// Hashids via shared utility
// Audit logging via Prisma middleware
8-week migration to feature parity, then 206 dev-weeks of new features at AI speed
Scaffold the Next.js project, generate Prisma schema, set up CI/CD
| Day | Task | AI Speedup | Output |
|---|---|---|---|
| 1 | Next.js 15 project scaffold with TypeScript, Tailwind, shadcn/ui | 100x | Working project shell |
| 1 | prisma db pull from existing MySQL → Prisma schema | 50x | 106-table schema.prisma |
| 2 | Clean up Prisma schema: relations, enums, Zod validators | 20x | Type-safe data layer |
| 2-3 | NextAuth.js setup with credentials provider (match existing auth) | 20x | Auth system with RBAC |
| 3 | GitHub Actions CI: lint, type-check, test, build, deploy to Vercel | 50x | Full CI/CD pipeline |
| 3-4 | Hashids utility, audit logging middleware, base layout components | 30x | Shared utilities |
| 4-5 | Admin layout shell: sidebar, navigation, breadcrumbs from mockups | 20x | Admin UI chrome |
Migrate the 6 most-used CRUD sections with full tRPC routers
| Section | Routes | AI Days | Notes |
|---|---|---|---|
| Accounts | list, add, edit, status | 2-3 | Core entity. 530 mockup references. DataTable → TanStack Table |
| Users & Roles | CRUD + permissions | 2 | Spatie RBAC → NextAuth role guards |
| Products & Bundles | CRUD + media upload | 2-3 | S3 upload, image processing |
| Messaging Sets | CRUD + templates | 2 | Nested CRUD (sets → templates) |
| Global Settings | All settings tabs | 2-3 | Largest repo (45KB). 20+ settings categories |
| Geographic Data | Regions, countries, states, cities | 1 | Simple CRUD, seed data |
Migrate integrations, Document module SPA, and remaining features
| Feature | AI Days | Notes |
|---|---|---|
| Document Management SPA | 3-4 | Vue 3 → React. S3 upload, folder tree, permissions, OTP sharing |
| Twilio Integration | 1-2 | Port SMS sending. Node Twilio SDK has same API surface |
| SendGrid Integration | 1-2 | Port email sending + queue jobs to BullMQ |
| Google Translate | 1 | Translation sync command → scheduled BullMQ job |
| Education Flows | 1-2 | Screen configs, purpose flows. Simple CRUD |
| Direct Mail / Postalytics | 1-2 | Triggers, timing, postage types. API integration |
| Case Notes & Telemedicine | 1 | Simple CRUD entities |
| Field Mappings | 1-2 | Categories, types, networks |
Comprehensive testing, data verification, and production cutover
| Task | AI Days | Notes |
|---|---|---|
| E2E test suite (Playwright) | 3-4 | AI generates tests for all critical flows. Target: 80%+ coverage |
| Unit tests (Vitest) | 2-3 | tRPC routers, Prisma queries, utility functions |
| Data verification | 2 | Compare Eloquent vs Prisma query results across all entities |
| Performance testing | 1 | Lighthouse scores, query performance, bundle size |
| Staging deployment | 1 | Full environment with production data copy |
| DNS cutover | 0.5 | Switch DNS, keep Laravel as fallback for 1 week |
With migration complete, all roadmap features built on clean Next.js foundation
| Phase | Features | Human Weeks | AI Weeks (est.) |
|---|---|---|---|
| P1 Revenue-Critical | Finance, ACH, Bulk Uploader, Channel Partners, Ordering Portal | 38 | 4-6 |
| P2 Communication | Email queue, WhatsApp, AI calling, SSO, Inbound handler | 34 | 4-5 |
| P3 Lab Aggregation | RFP tool, AI pricing, Analytics, Inventory, Test results | 52 | 6-8 |
| P4 Self-Service | API docs, EHR integrations, SFTP, ID verification | 40 | 4-6 |
| P5 Norvana | RPM/AI provisioning, Events, Mobile phlebotomy | 34 | 4-5 |
| Total new feature development | 206 weeks | ~25-35 weeks | |
Realistic speed multipliers by task category
TypeScript errors caught instantly. PHP errors surface at runtime — after deploy.
Prisma schema → types → tRPC router → React form. One source of truth.
530 mockups → shadcn/ui components. AI knows these patterns extremely well.
Type-safe code = AI generates accurate tests. Laravel's <1% coverage starts at 80%+ on Day 1.
AI-first Next.js migration vs. staying on Laravel
| Scenario | Migration | Feature Dev | Total Weeks | Time to All Features | Quality at End |
|---|---|---|---|---|---|
| Option A: Stay Laravel (human team) | 0 wk | 206 wk | 206 wk | ~13 months (4 devs) | Low (no tests, jQuery) |
| Option A: Stay Laravel (AI-assisted) | 0 wk | ~30-40 wk | ~30-40 wk | ~8-10 months | Medium (still jQuery/Blade) |
| Option C: Next.js (AI-first) | 8 wk | ~25-35 wk | ~33-43 wk | ~8-10 months | HIGH (typed, tested, modern) |
Identified risks and mitigations for the migration
| Risk | Likelihood | Impact | Mitigation |
|---|---|---|---|
| Business logic lost in translation Subtle behavior differences between Laravel and Next.js implementations |
Medium | High | Run both apps against same DB during M3. Automated comparison tests. Keep Laravel as fallback for 2 weeks post-cutover. |
| Integration SDK differences Twilio/SendGrid Node SDKs may behave differently from PHP SDKs |
Low | Medium | Official Node SDKs exist for all integrations. Verify in M2 with real API calls in staging. |
| Prisma schema drift Generated schema may not perfectly represent all Eloquent relationships |
Medium | Medium | Manual review of all model relationships. Cross-reference with existing Eloquent models. Test all joins. |
| AI-generated code quality AI may generate working but suboptimal code patterns |
Medium | Low | TypeScript compiler catches structural issues. ESLint + Prettier enforce patterns. Code review on critical paths. |
| Production downtime during cutover DNS switch may cause brief unavailability |
Low | High | Blue-green deployment. Both apps running simultaneously. DNS TTL reduced to 60s before cutover. Instant rollback capability. |
| Scope creep during migration Temptation to add new features during migration phases |
High | Medium | Strict parity-only rule during M0-M3. No new features until M4. Feature requests go to backlog. |
Gantt overview: migration + feature development
Every external service mapped from PHP SDK to Node.js SDK
| Integration | Current (PHP) | Target (Node.js) | Effort | Risk |
|---|---|---|---|---|
| Twilio SMS | twilio/sdk ^8.3 |
twilio (npm) |
1-2 days | Low — Same API |
| SendGrid Email | sendgrid/sendgrid ^8.1 |
@sendgrid/mail (npm) |
1-2 days | Low — Same API |
| AWS S3 Storage | league/flysystem-aws-s3-v3 |
@aws-sdk/client-s3 (npm) |
1 day | Low — Same buckets |
| Google Translate | google/cloud-translate ^1.19 |
@google-cloud/translate (npm) |
0.5 day | Low — Same API |
| Postalytics (Direct Mail) | HTTP via Guzzle | HTTP via fetch / axios |
1 day | Low — REST API |
| Redis (Cache + Queue) | predis/predis ^2.2 + Laravel Queue |
ioredis + bullmq |
1-2 days | Medium — Queue semantics differ |
| Hashids | hashids/hashids ^5.0 (per-model salt) |
hashids (npm) with same salts |
0.5 day | Low — Same algorithm |