Migrating 10 property sites to Next.js
Nine WordPress portals and a city map now run from one codebase.
- Problem
- Every new building launch started as a cloned WordPress folder. By portal number nine, schemas, redirect chains, and 3D viewers had drifted across 13 separate directories.
- My role
- I built the PHP AST audit pipeline, the compiler-gated AI synthesis workflow, and the unified Next.js 16 monorepo runtime at VisEngine.
- Solution
- Scan 13 legacy folders into deterministic AST manifests, reconcile nine drifted PHP schemas into one 69-field Zod contract and shared S3D runtime, and verify every route with Playwright gates.
- Outcome
- 84% of AI-generated routes passed strict compiler and Playwright checks on the first run. Masterplan wire transfer fell 57.8% (1,053 KiB to 444 KiB, 100/100 Lighthouse), 3D portal TTFB dropped from 549 ms to 134 ms, getFlats XHR from 798 ms to 140 ms, and 5,544-unit genplan Desktop LCP from 6.0 s to 1.1 s.
At VisEngine (client names anonymized as Theme A through Theme I), every new 3D building launch started the same way: copy-paste the previous WordPress folder, rename a few constants, and ship. Fast for launch number two. A maintenance tax by launch number nine.
Before long, one development was split across 13 separate folders: a central masterplan map, nine 3D building portals, and three static promo sites. Fixing a single camera bug meant patching nine repositories. Worse, every mobile visitor paid a 1,250 ms penalty in redirect hops (`301` to `/3d/` to `/en/3d/`) before a single byte of HTML arrived.
I consolidated all 13 legacy folders into one Next.js 16 and React 19 monorepo. By pairing deterministic PHP AST scanners with a compiler-gated AI migration pipeline, the entire port shipped in three and a half weeks.
One masterplan map to connect nine buildings
Previously, clicking a district on the masterplan map kicked the buyer into a completely separate WordPress install with its own scripts, its own cache quirks, and its own copy of the 3D engine. Now, the root masterplan map (`/`) acts as the hub for the entire estate.
From that single map, buyers explore SVG parcel overlays, check road routes between amenities, and see live unit availability across districts. Clicking a parcel steps straight into one of the nine parameterized 3D building portals (`/[theme]/3d`), which connect directly to the floor-stack slicer, the 2D apartment explorer, the 360-degree show-home tours, and the five static editorial routes. All nine buildings now run on one shared S3D spatial engine and one server-side data layer.
Why “paste PHP into ChatGPT” fails by folder number four
Here is the trap with AI code migrations: if you paste raw `ajax.php` files into a prompt one folder at a time, you just get nine incompatible TypeScript apps that recreate the old mess in a newer syntax.
So before generating a single React component, I wrote small PHP AST scanners to inventory every CRM field and config flag across all 13 folders. The scan showed why manual ports had stalled: only 26 apartment fields matched everywhere. Another 42 varied by site (including a currency object immortally spelled `carrency`), and multi-story villa floor plans vanished whenever a portal fell back from its cron cache to live CRM data.
Feeding all nine AST manifests into the model at once let us synthesize one canonical 69-field Zod contract (`FlatSchema`) and a single `formatFlat()` normalizer that reconciles every site quirk and strips unused CRM bloat.
Let the model write the boilerplate. Let the compiler be the bad cop.
Once the data contract was locked, the AI pipeline generated the route handlers, per-building configs, and React 3D wrappers. Trusting generated code blindly is reckless; making a compiler verify it is fast. Every generated route had to clear three automated gates:
- Replay real production apartment payloads from all nine portals through TypeScript strict mode and the 69-field Zod contract.
- Open each 3D building in Playwright, scrub the camera, click apartment polygons across angles, and verify that the drawer opens with the right price and floor plan.
- If anything failed, pipe the compiler error or Playwright diff straight back to the model to fix its own code.
84% of generated modules passed on the first run. The remaining 16% either fixed themselves on the retry loop or took a quick manual patch.
Stop rewriting JSON files during the buyer's request
In the legacy PHP portals, a cold `getFlats` request called the CRM, wrote JSON files to disk in the middle of the buyer's HTTP request, and sent back 375 KB of raw data. Moving `getFlats` behind a 300-second ISR cache boundary and trimming the payload through `formatFlat()` down to 156.6 KB raw (4.5 KB gzip) dropped endpoint TTFB from 798 ms to 140 ms.
Trim the wire, and be honest about 40 MiB of JPEGs
The legacy masterplan (`/`) inlined a 248 KB SVG and a 798 KB base64 JPEG straight into uncached PHP HTML. Splitting the map into a preloaded 243 KB WebP and an async SVG overlay with ISR cut root HTML weight by 89.7% (64.3 KB to 6.6 KB) and total page transfer by 57.8% (1,053 KiB to 444 KiB), hitting 100/100 across all four Lighthouse categories.
On the 3D portals, we made a pragmatic call: keep the battle-tested S3D canvas engine and its 120 JPEG flyby frames (~40 MiB per building) untouched so thousands of hand-drawn apartment polygons stayed pixel-accurate, and optimize everything around them. Killing the redirect chain and preloading S3D scripts cut Tower Portal (Theme A) document TTFB from 549 ms to 134 ms. On the 5,544-unit Community Genplan (Theme B), Desktop LCP fell from 6.0 s to 1.1 s and Mobile Total Blocking Time dropped by 1,070 ms.
Before and after the migration
| Metric | Before | After | Change |
|---|---|---|---|
| Document TTFB (Tower Portal) | 549 ms | 134 ms | 4.1× faster + 0 redirects |
| Inventory XHR (getFlats) | 798 ms | 140 ms | 5.6× faster TTFB |
| Masterplan wire size (/) | 1,053 KiB | 444 KiB | 57.8% lighter |
| 3D genplan Desktop LCP | 6.0 s | 1.1 s | 5.5× faster (5,544-unit portal) |
| Masterplan (/) Lighthouse Performance | 100 / 100 (1.2 s Mobile LCP) | 100 / 100 (1.0 s Mobile LCP) | -0.2 s Mobile LCP & FCP |
| Tower Portal 3D viewer Speed Index (Mobile / Desktop) | 7.3 s / 2.6 s | 4.7 s / 1.4 s | -2.6 s Mobile / -1.2 s Desktop |
| 5,544-unit Community Genplan TBT (Mobile / Desktop) | 3,050 ms / 610 ms | 1,980 ms / 420 ms | -1,070 ms Mobile / -190 ms Desktop |
| Lighthouse SEO & Accessibility across routes | 50–80 SEO / 65–85 A11y | 92–100 SEO / 83–100 A11y | +20 to +46 pts SEO |