<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Warren Boswell — Laravel, MySQL & AI Architecture]]></title><description><![CDATA[Principal Laravel 13, Livewire 4 & MySQL Architect (20+ years). Practical engineering teardowns on 1M DAU scaling, deterministic AI workflows, payment rails, an]]></description><link>https://warrenboswell.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6afca745976df3069776511c/158cc808-489b-41a5-99d5-5d34572d2121.png</url><title>Warren Boswell — Laravel, MySQL &amp; AI Architecture</title><link>https://warrenboswell.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 21 Nov 2026 19:46:04 GMT</lastBuildDate><atom:link href="https://warrenboswell.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Replacing 15-Field Quote Forms & Keyword Search with PHP-Guarded AI in Laravel 13 & Livewire 4]]></title><description><![CDATA[Replace 15-field quote forms & key search with Laravel 13 & Livewire 4 AI workflows where LLMs parse intent and PHP enforces pricing stock and math]]></description><link>https://warrenboswell.hashnode.dev/replacing-15-field-quote-forms-keyword-search-with-php-guarded-ai-in-laravel-13-livewire-4</link><guid isPermaLink="true">https://warrenboswell.hashnode.dev/replacing-15-field-quote-forms-keyword-search-with-php-guarded-ai-in-laravel-13-livewire-4</guid><category><![CDATA[Laravel]]></category><category><![CDATA[PHP]]></category><category><![CDATA[AI]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Warren Boswell]]></dc:creator><pubDate>Tue, 17 Nov 2026 19:28:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6afca745976df3069776511c/bcbf4f3b-18be-458b-9134-0dbef8e9f623.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Two of the highest-friction bottlenecks on almost every service and eCommerce website are:</p>
<ol>
<li><strong>Multi-step quote &amp; intake forms:</strong> Asking a busy buyer to click through 15 dropdowns, checkboxes, and date pickers before they even know if your pricing fits their budget.</li>
<li><strong>Brittle keyword catalog search:</strong> Forcing buyers to guess exact category filters instead of typing what they actually need (<em>"Waterproof wide-fit hiking boots under £130, must be in stock for next-day UK delivery"</em>).</li>
</ol>
<p>Yet when teams try to fix these with a generic LLM chatbot, they hit an immediate wall: <strong>language models invent prices, promise impossible SLAs, and recommend out-of-stock products.</strong></p>
<p>To demonstrate a safer production architecture, I built an interactive 5-workflow sandbox in <strong>Laravel 13</strong>, <strong>Livewire 4</strong>, and <strong>PHP 8.4</strong> where the LLM is strictly limited to <strong>parsing human intent</strong>, while <strong>deterministic PHP enforces every price, budget cap, and inventory check</strong>:</p>
<p>👉 <strong><a href="https://boswell.dev/ai-demo">Test the Live 5-Workflow AI Sandbox (boswell.dev/ai-demo)</a></strong></p>
<p>Here is how the <strong>Smart Quote &amp; Intake</strong> and <strong>Smart Catalog Search</strong> pipelines work under the hood.</p>
<hr />
<h2>Pattern 1: One Textarea Instead of 15 Form Fields (Smart Quote &amp; Intake)</h2>
<p>Instead of a long intake form, imagine letting a prospect paste a normal two-sentence enquiry:</p>
<blockquote>
<p><em>"Hi there, I'm Tom from Northbridge Events in Manchester. We need corporate buffet catering and barista coffee service for 85 attendees at our Q1 product summit next Thursday. Must include vegan &amp; gluten-free options and full setup by 8am. Need priority confirmation today if possible."</em></p>
</blockquote>
<p>If you ask an LLM to quote that job directly, you are handing your margins to a random number generator.</p>
<p>Instead, we split the pipeline in two:</p>
<ol>
<li><strong>Gemini (Structured JSON Extraction):</strong> Extracts <code>service_category</code> (<code>catering_event</code>), <code>unit_count</code> (<code>85</code>), <code>urgency</code> (<code>priority</code>), <code>extracted_requirements</code>, and <code>missing_details_to_clarify</code> (e.g., <em>exact Manchester venue address</em>, <em>dietary headcount split</em>).</li>
<li><strong>Deterministic PHP Rate-Card Engine:</strong> Locks the pricing calculation to a fixed server-side rate card—so the AI never invents a price:</li>
</ol>
<pre><code class="language-php">public static function calculateDeterministicQuote(array $extracted): array
{
   $rateCard = [
      'catering_event' =&gt; [
         'label' =&gt; 'Corporate Event Catering',
         'base_gbp' =&gt; 180,
         'per_unit_gbp' =&gt; 28,
         'unit_label' =&gt; 'attendee(s)',
         'default_units' =&gt; 60,
      ],
      'trades_onsite' =&gt; [
         'label' =&gt; 'Commercial Onsite Electrical',
         'base_gbp' =&gt; 240,
         'per_unit_gbp' =&gt; 115,
         'unit_label' =&gt; 'circuit/zone(s)',
         'default_units' =&gt; 4,
      ],
      'clinic_corporate' =&gt; [
         'label' =&gt; 'Corporate Health Screening',
         'base_gbp' =&gt; 350,
         'per_unit_gbp' =&gt; 65,
         'unit_label' =&gt; 'staff member(s)',
         'default_units' =&gt; 20,
      ],
      'other' =&gt; [
         'label' =&gt; 'Advisory &amp; Scoping Sprint',
         'base_gbp' =&gt; 450,
         'per_unit_gbp' =&gt; 350,
         'unit_label' =&gt; 'scope block(s)',
         'default_units' =&gt; 2,
      ],
   ];

   $category = (string) ($extracted['service_category'] ?? 'other');

   if (! isset($rateCard[$category])) {
      $category = 'other';
   }

   $tier = $rateCard[$category];
   $rawUnits = is_numeric($extracted['unit_count'] ?? null) ? (int) $extracted['unit_count'] : $tier['default_units'];
   $units = max(1, min(500, $rawUnits));

   $urgency = strtolower((string) ($extracted['urgency'] ?? 'standard'));
   $multiplier = match ($urgency) {
      'emergency' =&gt; 1.45,
      'priority' =&gt; 1.20,
      default =&gt; 1.00,
   };
   $sla = match ($urgency) {
      'emergency' =&gt; 'Same-Day Callback (&lt; 2 hrs)',
      'priority' =&gt; 'Next-Business-Day Scoping',
      default =&gt; '48-Hour Proposal Turnaround',
   };

   $midpoint = (int) round(($tier['base_gbp'] + ($tier['per_unit_gbp'] * $units)) * $multiplier);
   $minGbp = (int) (floor(($midpoint * 0.90) / 10) * 10);
   $maxGbp = (int) (ceil(($midpoint * 1.15) / 10) * 10);
   $formulaBreakdown = sprintf(
      '£%s base + (%d %s × £%s) × %.2fx %s SLA',
      number_format($tier['base_gbp']),
      $units,
      $tier['unit_label'],
      number_format($tier['per_unit_gbp']),
      $multiplier,
      $urgency,
   );

   return [
      'category_label' =&gt; $tier['label'],
      'unit_label' =&gt; $tier['unit_label'],
      'unit_count' =&gt; $units,
      'urgency' =&gt; $urgency,
      'min_gbp' =&gt; $minGbp,
      'max_gbp' =&gt; $maxGbp,
      'target_sla' =&gt; $sla,
      'formula_breakdown' =&gt; $formulaBreakdown,
      'headline' =&gt; 'PHP Rate-Card Estimate Locked',
      'detail' =&gt; sprintf(
         'Calculated from fixed %s rate card (%s) — LLM never sets prices.',
         $tier['label'],
         $formulaBreakdown,
      ),
   ];
}
</code></pre>
<p>In Tab 4 (<strong>Smart Quote &amp; Intake</strong>) on <a href="https://boswell.dev/ai-demo">boswell.dev/ai-demo</a>, the customer gets an instant, transparent estimate (<code>£2,760 – £3,540</code> with the exact formula <code>£180 base + (85 attendee(s) × £28) × 1.20x priority SLA</code>), and your sales team gets a pre-qualified CRM payload plus the missing follow-up questions.</p>
<hr />
<h2>Pattern 2: Natural-Language Catalog Search Without Hallucinated SKUs</h2>
<p>When a buyer searches a catalog in plain English:</p>
<blockquote>
<p><em>"Waterproof hiking boots, wide fit, under £130, must be in stock for next-day UK delivery"</em></p>
</blockquote>
<p>A naive RAG pipeline often returns an item that costs <code>£145</code> or is currently out of stock because its vector embedding looks semantically similar.</p>
<p>To make natural-language search safe for eCommerce and B2B catalogs, the LLM returns <strong>interpreted filter constraints</strong> (<code>max_budget_gbp: 130</code>, <code>require_in_stock: true</code>, <code>required_tags</code>) alongside candidate item IDs. Then <strong>PHP re-hydrates every candidate from the canonical catalog and strips any item that violates a hard constraint</strong>:</p>
<pre><code class="language-php">public static function groundCatalogMatches(array $aiResult): array
{
   $catalogById = [];

   foreach (self::catalogItems() as $item) {
      $catalogById[$item['id']] = $item;
   }

   $rawFilters = is_array($aiResult['applied_filters'] ?? null) ? $aiResult['applied_filters'] : [];
   $maxBudget = self::toFloat($rawFilters['max_budget_gbp'] ?? null);
   $requireInStock = (bool) ($rawFilters['require_in_stock'] ?? false);

   $rawMatches = is_array($aiResult['matched_items'] ?? null) ? $aiResult['matched_items'] : [];
   $verified = [];
   $seenIds = [];
   $blockedCount = 0;

   foreach ($rawMatches as $match) {
      if (! is_array($match)) {
         continue;
      }

      $itemId = (string) ($match['item_id'] ?? '');

      if ($itemId === '' || isset($seenIds[$itemId])) {
         continue;
      }

      $seenIds[$itemId] = true;

      if (! isset($catalogById[$itemId])) {
         $blockedCount++;

         continue;
      }

      $canonical = $catalogById[$itemId];

      // Hard PHP budget &amp; stock enforcement — never trust LLM price/stock claims
      if ($maxBudget !== null &amp;&amp; $canonical['price_gbp'] &gt; $maxBudget) {
         $blockedCount++;

         continue;
      }

      if ($requireInStock &amp;&amp; ! $canonical['in_stock']) {
         $blockedCount++;

         continue;
      }

      $verified[] = [
         'id' =&gt; $canonical['id'],
         'name' =&gt; $canonical['name'],
         'provider' =&gt; $canonical['provider'],
         'price_gbp' =&gt; $canonical['price_gbp'],
         'in_stock' =&gt; $canonical['in_stock'],
         'tags' =&gt; $canonical['tags'],
         'match_reason' =&gt; (string) ($match['match_reason'] ?? 'Matched canonical catalog attributes.'),
      ];
   }

   return [
      'verified_items' =&gt; $verified,
      'blocked_count' =&gt; $blockedCount,
   ];
}
</code></pre>
<p>Even if the model tries to sneak in an out-of-stock boot or a <code>£155</code> item, the PHP guard blocks it before rendering and shows the user exactly why constraint-failing items were excluded.</p>
<hr />
<h2>Three More Workflows in the Same Sandbox</h2>
<p>Alongside <strong>Smart Quote &amp; Intake</strong> and <strong>Smart Catalog Search</strong>, the <a href="https://boswell.dev/ai-demo">live sandbox</a> includes three operational workflows built on the same principle:</p>
<ol>
<li><strong>Document Extraction + Math Audit:</strong> Paste a vendor invoice, lead email, or CSV. Gemini extracts typed JSON, and PHP checks both <code>subtotal + tax == total</code> and the sum of line items. <em>(Change a single line item price in the demo to watch PHP flag <code>Line-Item Drift Caught by PHP</code> in real time.)</em></li>
<li><strong>Customer Data Query:</strong> Ask plain-English retention and upsell questions across a canonical account dataset—where matched IDs are re-hydrated from authoritative database rows and paired with tailored executive outreach drafts.</li>
<li><strong>Auto Incident Triage:</strong> Feed raw Stripe 3DS webhook failures, MySQL <code>1213 Deadlock</code> stack traces, or SAML SSO errors into an autonomous triage agent backed by deterministic P1/P2/P3 escalation rules.</li>
</ol>
<hr />
<h2>Try the Sandbox &amp; Explore the Architecture</h2>
<p>Everything runs in <strong>Laravel 13</strong> and <strong>Livewire 4</strong> with strict server-side API key isolation, ordered multi-model failover, and full-page Cloudflare edge caching:</p>
<ul>
<li><strong>Live 5-Workflow Sandbox (No Signup):</strong> <a href="https://boswell.dev/ai-demo">https://boswell.dev/ai-demo</a></li>
<li><strong>Full Technical Case Study &amp; Sequence Diagrams:</strong> <a href="https://boswell.dev/projects/enterprise-generative-ai-laravel-workflows">Enterprise Generative AI Workflows in Laravel</a></li>
<li><strong>Scaling Laravel &amp; MySQL to 1M DAU (&lt;50ms p95):</strong> <a href="https://boswell.dev/projects/1m-dau-laravel-mysql-architecture">1M DAU Architecture Case Study</a></li>
<li><strong>For SaaS Founders &amp; MVP Sprints:</strong> <a href="https://boswell.dev/founders">boswell.dev/founders</a> | Main Portfolio: <a href="https://boswell.dev/">boswell.dev</a></li>
</ul>
]]></content:encoded></item></channel></rss>