PHP 8.2 / Laravel 11 TypeScript / Next.js 15

AI-First Platform Migration

Full rewrite strategy for diagnostic.ly — leveraging AI-assisted development at 10–50x speed

80K
LOC to Migrate
106
DB Tables
530
UI Mockups
~8 wk
To Parity
206
Feature Dev-Weeks
▼ Scroll to explore

Why Migrate Now?

AI-first development fundamentally changes the rewrite calculus

0%
Migration Risk (old model)
Low
Migration Risk (AI-first)
60-100
Rewrite Weeks (Human)
6-8
Rewrite Weeks (AI)

What Changed

Three factors that propped up "stay on Laravel" have collapsed with AI-first development:

FactorBeforeNow
Migration riskHIGH (months)LOW (weeks)
Team language expertiseCriticalIrrelevant
Code reuse value80K LOCRegenerable
Ramp-up timeWeeksZero

Why TypeScript Wins for AI

01
Type safety = fewer AI hallucinations.
Compiler catches errors immediately. PHP's loose typing hides bugs until runtime.
02
Single language, full stack.
No context-switching between PHP, Blade, jQuery, Vue, SQL.
03
Largest AI training corpus.
Modern TypeScript/React patterns dominate AI training data.
04
Native real-time.
WebSockets, SSE, streaming — native to Node.js, bolted-on in Laravel.

Decision Matrix — Rescored for AI-First Development

CriterionWeightA: Stay LaravelB: Laravel+SPAC: Next.jsD: .NETE: Django
Migration risk×154323
Time to first feature×254323
Frontend UX capability×325532
API-first architecture×335554
AI/ML integration×323425
Real-time capabilities×234543
Long-term scalability×234554
AI-assisted dev velocity×334534
Type safety / AI accuracy×223553
Weighted Total 6482 92 7272

Target Architecture

Modern TypeScript stack optimized for AI-assisted development

Stack Comparison

Replacing: PHP 8.2Laravel 11BladejQueryDataTablesBootstrap 5Eloquent ORM
New Stack: TypeScript 5Next.js 15React 19Prisma ORMtRPCTailwind CSSshadcn/uiNextAuth.jsZodTanStack TableReact Query
Keeping: MySQLRedisAWS S3TwilioSendGridGoogle Translate

Frontend Layer

Next.js 15 — App Router, RSC, Server Actions
React 19 — Server Components, Suspense, Transitions
Tailwind CSS + shadcn/ui — Replaces Bootstrap 5
TanStack Table — Replaces jQuery DataTables
React Hook Form + Zod — Type-safe forms

Backend Layer

Next.js API Routes + tRPC — End-to-end type safety
Prisma ORM — Type-safe DB access, replaces Eloquent
NextAuth.js v5 — Auth with RBAC, replaces Sanctum + Spatie
BullMQ — Redis-backed job queues, replaces Laravel Queue
Hashids.js — Same ID obfuscation, direct port

Infrastructure

Vercel or AWS (SST) — Zero-downtime deploys
PlanetScale or RDS MySQL — Keep existing data
Upstash Redis or ElastiCache — Sessions + queues
Vitest + Playwright — Unit + E2E testing from day one
GitHub Actions — CI/CD replaces Jenkins

Architecture Diagram

┌─────────────────────────────────────────────────────────────────┐ │ NEXT.JS 15 (App Router) │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐ │ │ │ React 19 │ │ Server │ │ API Routes │ │ │ │ Components │ │ Components │ │ + tRPC Routers │ │ │ │ (Client) │ │ (RSC) │ │ (Type-safe API) │ │ │ └──────┬───────┘ └──────┬───────┘ └──────────┬───────────┘ │ │ │ │ │ │ │ ┌──────┴──────────────────┴──────────────────────┴───────────┐ │ │ │ MIDDLEWARE LAYER │ │ │ │ NextAuth.js v5 │ RBAC Guards │ Rate Limiting │ Logging │ │ │ └──────────────────────────┬──────────────────────────────────┘ │ └─────────────────────────────┼───────────────────────────────────┘ │ ┌─────────────────────┼─────────────────────┐ │ │ │ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ │ Prisma │ │ BullMQ │ │ External │ │ ORM │ │ Workers │ │ APIs │ │ │ │ │ │ │ │ MySQL │ │ Redis │ │ Twilio │ │ (106 tbl) │ │ Queues │ │ SendGrid │ │ │ │ │ │ AWS S3 │ └────────────┘ └───────────┘ │ Google │ │ Translate │ └────────────┘

Database Schema Migration

106 MySQL tables mapped to Prisma schema — zero data loss

Migration Strategy

1
Introspect existing MySQL
Run prisma db pull to auto-generate Prisma schema from live database
2
Clean up generated schema
Add relations, rename models (e.g., accountsAccount), add Zod validators
3
Generate Prisma Client
Full type-safe ORM from schema — replaces Eloquent models + repositories
4
Run parallel
Both Laravel and Next.js connect to same MySQL during transition period
5
Cut over
Retire Laravel app once all routes migrated and tested

Table Groups (106 tables)

DomainTablesComplexity
Geographic hierarchyregions, sub_regions, countries, states, citiesSeed data
Accounts & Usersaccounts, users, account_users, roles, permissionsCore
Messagingmessaging_options, messaging_templates, messaging_sets, comm_logsCore
Documentsdocument_manager_ui_representations, shared_documents, permissionsComplex
Productsproducts, bundles, bundle_items, mediaCore
Settingsglobal_settings, application_settings, account_settings, ecommerceKey-value
Educationeducation_flows, purpose_flows, screen_configsSimple
Direct mailtriggers_by_account, postage_types, send_mail_timingsSimple
Field mappingsfield_mapping_categories, mapping_types, networksCore
Support & miscsupport_entities, case_notes, telemedicine, activity_logSimple

Before & After: Data Access Pattern

Laravel / Eloquent
// 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
Next.js / Prisma + tRPC
// 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

Migration Phases

8-week migration to feature parity, then 206 dev-weeks of new features at AI speed

M0: Project Foundation & Schema

Scaffold the Next.js project, generate Prisma schema, set up CI/CD

DayTaskAI SpeedupOutput
1Next.js 15 project scaffold with TypeScript, Tailwind, shadcn/ui100xWorking project shell
1prisma db pull from existing MySQL → Prisma schema50x106-table schema.prisma
2Clean up Prisma schema: relations, enums, Zod validators20xType-safe data layer
2-3NextAuth.js setup with credentials provider (match existing auth)20xAuth system with RBAC
3GitHub Actions CI: lint, type-check, test, build, deploy to Vercel50xFull CI/CD pipeline
3-4Hashids utility, audit logging middleware, base layout components30xShared utilities
4-5Admin layout shell: sidebar, navigation, breadcrumbs from mockups20xAdmin UI chrome
Week 2 checkpoint: Login works, admin shell renders, Prisma queries return data from production MySQL, CI/CD deploys to staging.

M1: Core Entity Migration

Migrate the 6 most-used CRUD sections with full tRPC routers

SectionRoutesAI DaysNotes
Accountslist, add, edit, status2-3Core entity. 530 mockup references. DataTable → TanStack Table
Users & RolesCRUD + permissions2Spatie RBAC → NextAuth role guards
Products & BundlesCRUD + media upload2-3S3 upload, image processing
Messaging SetsCRUD + templates2Nested CRUD (sets → templates)
Global SettingsAll settings tabs2-3Largest repo (45KB). 20+ settings categories
Geographic DataRegions, countries, states, cities1Simple CRUD, seed data
Week 4 checkpoint: All existing admin CRUD functional. 26 controllers migrated to tRPC routers. Global search working.

M2: Feature Migration

Migrate integrations, Document module SPA, and remaining features

FeatureAI DaysNotes
Document Management SPA3-4Vue 3 → React. S3 upload, folder tree, permissions, OTP sharing
Twilio Integration1-2Port SMS sending. Node Twilio SDK has same API surface
SendGrid Integration1-2Port email sending + queue jobs to BullMQ
Google Translate1Translation sync command → scheduled BullMQ job
Education Flows1-2Screen configs, purpose flows. Simple CRUD
Direct Mail / Postalytics1-2Triggers, timing, postage types. API integration
Case Notes & Telemedicine1Simple CRUD entities
Field Mappings1-2Categories, types, networks
Week 6 checkpoint: All Laravel features functional in Next.js. External integrations verified. Document SPA rebuilt in React.

M3: Testing, Polish & Cutover

Comprehensive testing, data verification, and production cutover

TaskAI DaysNotes
E2E test suite (Playwright)3-4AI generates tests for all critical flows. Target: 80%+ coverage
Unit tests (Vitest)2-3tRPC routers, Prisma queries, utility functions
Data verification2Compare Eloquent vs Prisma query results across all entities
Performance testing1Lighthouse scores, query performance, bundle size
Staging deployment1Full environment with production data copy
DNS cutover0.5Switch DNS, keep Laravel as fallback for 1 week
Week 8: Next.js app is live in production. Test coverage >80% (vs <1% on Laravel). Zero-downtime deploys via Vercel/SST. Laravel retired.

M4+: New Feature Development (206 dev-weeks at AI speed)

With migration complete, all roadmap features built on clean Next.js foundation

PhaseFeaturesHuman WeeksAI Weeks (est.)
P1 Revenue-CriticalFinance, ACH, Bulk Uploader, Channel Partners, Ordering Portal384-6
P2 CommunicationEmail queue, WhatsApp, AI calling, SSO, Inbound handler344-5
P3 Lab AggregationRFP tool, AI pricing, Analytics, Inventory, Test results526-8
P4 Self-ServiceAPI docs, EHR integrations, SFTP, ID verification404-6
P5 NorvanaRPM/AI provisioning, Events, Mobile phlebotomy344-5
Total new feature development206 weeks~25-35 weeks
Total project (migration + all features): ~33-43 AI-weeks vs ~266+ human-weeks. 6-8x overall compression.

AI Development Speed

Realistic speed multipliers by task category

Speed Multiplier by Task Type

CRUD / Boilerplate
50-100x
UI from Mockups
20-50x
API Endpoints
20-50x
Test Generation
20-40x
Schema Design
10-20x
Business Logic
3-10x
External Integrations
3-5x
Data Migration
1-2x
Compliance Verification
1x (human)
AI-accelerated
Human-speed (verification required)

Effective Overall Multiplier

Why TypeScript Gets Higher Multipliers

Compiler as copilot.

TypeScript errors caught instantly. PHP errors surface at runtime — after deploy.

Schema-driven generation.

Prisma schema → types → tRPC router → React form. One source of truth.

Component ecosystem.

530 mockups → shadcn/ui components. AI knows these patterns extremely well.

Test generation.

Type-safe code = AI generates accurate tests. Laravel's <1% coverage starts at 80%+ on Day 1.

Cost & Timeline Comparison

AI-first Next.js migration vs. staying on Laravel

Timeline Comparison

What You Get for the Migration Cost

Test coverage<1%>80%
Type safetyNoneFull
CI/CDgit pullAtomic deploys
FrontendjQuery/BladeReact 19
API architectureServer-renderedAPI-first + tRPC
Real-timeNoneNative WebSocket
AI dev velocity5-10x10-50x
ObservabilityNoneBuilt-in

Total Project Cost Comparison

ScenarioMigrationFeature DevTotal WeeksTime to All FeaturesQuality 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)
Key insight: Same delivery timeline, but Option C ends with a typed, tested, modern platform vs. Option A ending with the same legacy debt. The 8-week migration "cost" is really an investment — it pays dividends in every subsequent feature's velocity and quality.

Risk Register

Identified risks and mitigations for the migration

RiskLikelihoodImpactMitigation
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.

Execution Timeline

Gantt overview: migration + feature development

Full Project Timeline (AI-First)

Week: 1 4 8 12 16 20 24 28 32 36 40 |----|----|----|----|----|----|----|----|----|----|----| M0 ████ Foundation + Schema M1 ████ Core Entity Migration M2 ████ Feature Migration M3 ████ Testing + Cutover |----|----|----|----|----|----|----|----|----|----|----| P1 ████████ Revenue-Critical P2 ██████████ Communications P3 ████████████████ Lab Aggregation P4 ██████████ Self-Service P5 ████████████ Norvana + Advanced |----|----|----|----|----|----|----|----|----|----|----| Migration All features complete complete (Week 8) (~Week 40)
Total: ~40 AI-weeks to deliver migration + all 206 dev-weeks of features. Equivalent to ~13+ months with a human team of 4.
Week 8
Migration Complete
Full parity with Laravel app
Week 14
Revenue Features Live
Finance, ACH, Ordering Portal
Week 40
Full Roadmap Delivered
All P1-P5 phases complete

Integration Migration Map

Every external service mapped from PHP SDK to Node.js SDK

IntegrationCurrent (PHP)Target (Node.js)EffortRisk
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
Total integration migration: ~5-7 days. All services have official Node.js SDKs. Same API keys, same accounts, same infrastructure.