Hybrid SSR + SPA, single bundle.
resources/js/appss.jsx mounts on #motoshare-app (SPA shell) and / on chrome nodes — same JS file, mode chosen by which DOM IDs the page contains. Auth state, API base, and current path flow from PHP → data-* attributes → window._MOTOSHARE* globals.
Repository pattern is strictly enforced.
I grepped — zero DB:: calls in any controller. Discipline that most Laravel projects don't keep.
Database power features are leveraged.
Complex reads go through MySQL views (vw_vehicle_catalog, vw_booking_details) and stored procs (sp_list_booking_details_by_actor) — significantly faster than equivalent Eloquent + N+1.
Unified API surface.
routes/api_shared.php is loaded under both /api (token / mobile-future) and /web-api (session-cookie auth for the React SPA). Add an endpoint once, both clients get it.
Clean centralized exception →
JSON conversion for api/* and web-api/* in bootstrap/app.php. HTTP exceptions, validation errors, and unexpected throwables all return consistent { message } shape.
Minimal, focused middleware.
Just EnsureSessionUser.php — one job, 15 lines, no surprises.
Standardized response envelope via ApiResponder.php — { message, data } everywhere, so the React api.js client has one parse path.
The pattern that ties them together
Advantages of this architecture (general)
SEO + speed of SSR with the interactivity of SPA, without paying the cost of Next.js / Inertia / Vue SSR runtimes.
Performance ceiling is high — hand-tuned SQL plus DB-side views/SPs.
Mobile-future ready — api_shared.php already serves token-style auth and JSON; you can add a React Native client without controller rewrites.
Repository pattern → testability — services can mock repos in PHPUnit without DB roundtrips.
Single deploy artifact — one Laravel app + one Vite bundle. No Node server, no separate SSR worker process.
Top comments (0)