Rebuilding CodeWithHaroon With Laravel 13 and React: Architecture Decisions
This site is a Laravel 13 application with a React front end, and it has two jobs that pull in different directions: it has to teach, so content needs structure, and it has to sell services, so the commercial pages must stay separate from the teaching ones. This is a build log of how the pieces fit together, what the structure looks like today, which bugs showed up while it was being reshaped, and what I would change next. Everything below comes from the repository and its history. I have not included traffic or ranking figures, because there are none to report yet.
What this article is, and is not
It describes the code as it stood when this was written, including counts taken from the database at that moment. The foundation (the content model, the flat category URLs, the admin and the React templates) was already in the project before the current rebuild. The rebuild changed the category tree, added series, services, a contact form and the content plan, and rewrote the site's positioning. Where I say "the rebuild", I mean that work. I have not deployed this version to a public server yet, so nothing here describes production behaviour.
The stack
- Back end: Laravel 13 on PHP 8.3, with Fortify for authentication (two-factor columns and a passkeys table are in the migrations).
- Front end: Inertia 3 with React 19 and TypeScript, Tailwind CSS 4, built with Vite 8. Rich text in the admin uses TipTap.
- Database: MySQL, 29 tables including Laravel's own.
- Pages: 13 admin controllers (12 admin sections plus a dashboard), 11 public controllers, and two selectable front-end templates (a default one and an alternative styled one), chosen from a setting.
The content model
The model separates content that teaches from content that sells, which was the main design goal:
| Model | Role | Notes |
|---|
| Category | The topic tree | Two levels (parent and child). Status active or inactive. SEO title, SEO description, a short description and a longer introduction. |
| Series | An ordered group of posts | Belongs to a category. Inactive series are hidden. This is how a post becomes reachable. |
| Post | An article | Belongs to a category and a series. A guide type and a difficulty level. Draft or published. SEO fields and a full-text index. |
| Project | A portfolio or case-study page | Separate from posts. Draft or published. |
| Service | A commercial page | Draft or published. Linked to posts and projects through pivot tables, so a service page lists its related guides and case studies automatically. |
| Tool, Page, Tag, Menu, Advertisement | Supporting content | Static pages, tags, navigation, ad slots, and a small tools section. |
| ContactMessage | Enquiries | Stored from the contact form and read in the admin. |
The rule that makes the whole thing hang together: a post is only public if it is published, belongs to a series, and sits in a category whose whole ancestor chain is active. Drafts, inactive series and disabled categories all return a 404. That one rule lets me prepare content in the database without exposing it.
URL design
Public guide URLs have three levels, and the category segment is resolved by slug alone:
Route::get('/guides/{category:slug}', FrontendCategoryController::class)->name('frontend.category');
Route::get('/guides/{category:slug}/{series:slug}', FrontendSeriesController::class)->name('frontend.series');
Route::get('/guides/{category:slug}/{series:slug}/{post:slug}', FrontendPostController::class)->name('frontend.post');
That means a subcategory is addressed as /guides/n8n, not /guides/ai-automation/n8n. The advantage is short, stable URLs that do not change if a subcategory moves. The cost is that every category slug must be unique across the whole tree, and a name like php can only be used once. When the new tree needed that slug, the old category that held it had to be renamed to php-archived first. I would take that trade again for a site this size, but it is worth knowing before you copy the approach.
Visibility is computed, not assumed
Disabling a parent category should hide everything under it, even if the children are still marked active. The model computes the set of effectively active categories once per request:
public static function effectivelyActiveIds(): array
{
$categories = static::query()->get(['id', 'parent_id', 'status'])->keyBy('id');
$resolved = [];
$isActive = function (int $id) use (&$isActive, &$resolved, $categories): bool {
if (array_key_exists($id, $resolved)) {
return $resolved[$id];
}
$category = $categories->get($id);
if (! $category || $category->status !== 'active') {
return $resolved[$id] = false;
}
return $resolved[$id] = $category->parent_id ? $isActive($category->parent_id) : true;
};
return $categories->keys()->filter($isActive)->values()->all();
}
Every public controller filters by this set, so there is one definition of "visible" rather than a dozen copies of it. Combined with draft statuses and inactive series, it is what let me create 35 series and more than a dozen draft posts without showing any of them.
Structure changes are repeatable seeders
The category tree, series, service pages, site settings and the first batches of draft posts were created by named seeders, each safe to run again. They update by slug, never change the status or text of something already published, and keep new items hidden until I switch them on. The rule I follow is never to run a bare php artisan db:seed, which would also run the demo-data seeder. Naming the seeder makes every change small and reviewable. Alongside the code, a content-plan folder in the repository holds the roadmap, the proposals and the test results, so decisions are written down where the project lives.
SEO decisions
- One component for the head tags. A shared component outputs the title, meta description, canonical link, Open Graph and Twitter tags, and JSON-LD, including a breadcrumb trail on every public page.
- Fields at every level. Categories, series, posts, services and projects each have their own SEO title and description, so nothing falls back to a generic string.
- A generated sitemap that includes only content that is actually visible, so a draft does not leak into it.
- Server-rendered HTML in development. The server response for a post page contains the title, description, canonical link, structured data and the article text. That comes from Inertia's server-side rendering, which is switched on in the configuration and runs through the Vite dev server. I have not yet set up or verified server-side rendering in production, which is the first item under "next".
What went wrong while it was being reshaped
These were real problems, found by running things:
| Problem | How it showed up | Fix |
|---|
| Published service pages and project pages returned a 500 error | Only when the pages were actually loaded after publishing. A type declaration on a closure expected one class while Laravel passed a relation object | Removed the declaration in both controllers, and I now load every page after publishing it |
| Every call-to-action button pointed to a contact page that did not exist | Found in a review of the routes before launch, then confirmed with a link crawl | Built the contact form, with messages stored in the database and a notice in the admin until email is configured |
| The site still called itself a generic tutorial site | Review of the site settings | Rewrote the name, description and key page copy |
| Placeholder demo content and accounts | Review of the database | Renamed the author account to the real author and deleted the five placeholder posts. Demo accounts still exist and must be removed before launch |
| The automated test suite could not run on my machine | "Could not find driver": the tests assume SQLite, and this PHP has no SQLite extension | Open: tests need to run against MySQL. I verified new code in a separate lab application instead |
What I would change next
- Verify server-side rendering in production. The configuration enables it and the development server renders it, but production needs the build and a running Node process. Until I have checked that, I would not claim it works.
- Stop publishing empty category pages. At the time of writing, 32 of the 38 active subcategories have no published post. Each still has a page and a place in navigation and the sitemap. Hiding or marking empty categories
noindex until they have content would be cleaner.
- Wire up the redirects table. The table exists, and I stored redirects for moved URLs in it, but nothing reads it yet.
- Fix the test setup, then add feature tests for the visibility rules above, because they are the most important behaviour in the system.
- Images. Posts have fields for a featured image and a social image, and the content does not use them yet.
What I would copy, and what I would not
Copy: one definition of "visible", drafts and inactive series that hide work in progress, structure changes as named repeatable seeders, and plans and results kept in the repository. Do not copy blindly: flat category slugs, if you expect a large tree or many near-duplicate names.
Frequently asked questions
Why Inertia and React instead of a CMS?
The site mixes teaching content, commercial pages and a contact workflow, and I wanted one codebase with real application logic: visibility rules, pivot-linked pages, a stored contact form. A general CMS would have meant bending it around those rules. The trade-off is that I maintain the admin myself.
Is the site live?
Not at the time of writing. It runs locally, and everything in this article describes that version.
Can I see the code?
There is no public repository at the moment. The article quotes the parts that matter.
How are drafts kept out of search results?
They return a 404, and the sitemap only lists content that is visible, so there is nothing for a crawler to find.
Where this fits
If you need a content-driven site or a business application built on Laravel and React, see Full-Stack Web Development, and Laravel & PHP Development for rescuing or extending an existing application. To discuss a project, describe it here. More project breakdowns are collected under Laravel Projects.