<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Premodsuraweera on Medium]]></title>
        <description><![CDATA[Stories by Premodsuraweera on Medium]]></description>
        <link>https://medium.com/@premodsuraweera1?source=rss-540f49a34470------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*83Mf3Q635PBc-cla</url>
            <title>Stories by Premodsuraweera on Medium</title>
            <link>https://medium.com/@premodsuraweera1?source=rss-540f49a34470------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 04:39:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@premodsuraweera1/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[WhatsApp Stickers Now Have Sound: How to Create, Download, and Send Them]]></title>
            <link>https://medium.com/@premodsuraweera1/whatsapp-stickers-now-have-sound-how-to-create-download-and-send-them-62c160934bab?source=rss-540f49a34470------2</link>
            <guid isPermaLink="false">https://medium.com/p/62c160934bab</guid>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[whatsapp]]></category>
            <category><![CDATA[tech-tips]]></category>
            <dc:creator><![CDATA[Premodsuraweera]]></dc:creator>
            <pubDate>Tue, 01 Dec 2026 05:56:54 GMT</pubDate>
            <atom:updated>2026-12-01T05:56:54.683Z</atom:updated>
            <content:encoded><![CDATA[<p><em>WhatsApp’s latest messaging upgrade blends animated visuals with short audio clips — here is everything you need to know to start using Sound Stickers.</em></p><figure><img alt="Illustration of a smartphone displaying a chat bubble with a 3D animated sticker and glowing green audio soundwaves representing WhatsApp Sound Stickers" src="https://cdn-images-1.medium.com/max/1024/1*bJ2FxT1Z3a8BJxqq-NU0Pw.jpeg" /></figure><p>Stickers have long been one of the fastest ways to react in a WhatsApp chat when plain text or emojis just don’t cut it. Now, WhatsApp is taking expressive messaging a step further with <strong>Sound Stickers</strong> — stickers that come with built-in audio.</p><p>Whether it is a quick laugh, a meme sound effect, a snippet of music, or a short voice reaction, audio stickers add a whole new layer of personality to everyday conversations without turning your chat into a noisy mess.</p><p>Here is how the feature works, how you can create or download them, and what to keep in mind before you start spamming your group chats.</p><h3>How WhatsApp Sound Stickers Work</h3><p>If you are worried about opening a group chat in public and getting blasted by ten meme sounds at once, WhatsApp thought ahead.</p><ul><li><strong>Muted by default:</strong> Sound stickers do not autoplay loudly when they land in a chat. Instead, they display a small <strong>speaker icon</strong>. Recipients tap the icon whenever they want to hear the audio.</li><li><strong>Short &amp; snappy:</strong> Audio clips are kept brief (typically a few seconds long, up to around 10 seconds depending on the source) and loop a few times before stopping automatically.</li><li><strong>Built-in privacy:</strong> Just like regular messages, voice notes, and standard stickers, Sound Stickers are protected with <strong>end-to-end encryption</strong>.</li></ul><h3>Method 1: How to Create and Send Sound Stickers Directly in WhatsApp</h3><p>WhatsApp has been rolling out native Sound Sticker creation starting with its latest app updates (initially appearing in Android beta builds before expanding wider). If the feature is live on your account, you don’t need any third-party apps:</p><ol><li><strong>Update WhatsApp</strong> to the latest version available on the Google Play Store or Apple App Store.</li><li>Open any <strong>individual or group chat</strong> and tap the <strong>Sticker icon</strong> in the message bar.</li><li>Select <strong>Create</strong> (or <strong>Create Sticker</strong>).</li><li>Pick a <strong>video or image</strong> from your phone’s gallery. Videos are automatically converted into animated stickers.</li><li>Tap the <strong>Audio / Sound Wave icon</strong> at the top of the sticker editor.</li><li>Choose your audio source:</li></ol><ul><li><strong>Keep the original audio</strong> from your video clip.</li><li><strong>Record a voice note</strong> on the spot.</li><li><strong>Import an audio clip</strong> or sound effect from your device.</li><li><strong>Pick a preset sound</strong> from WhatsApp’s built-in library (where available).</li></ul><p>7. Preview your sticker to make sure the timing feels right, then hit <strong>Send</strong>.</p><h3>Method 2: How to Download and Save Pre-Made Audio Stickers</h3><p>Don’t have the native creator tool yet, or just want ready-made meme reactions? You can still collect and send Sound Stickers through community-shared packs:</p><ul><li><strong>Follow dedicated WhatsApp Channels:</strong> Several sticker-creator communities share ready-to-use audio stickers directly inside WhatsApp Channels. Tap a sticker to let it finish downloading, then <strong>add it to your Favorites</strong> or <strong>forward it</strong> to your chats.</li><li><strong>Use trusted web tools:</strong> Browser-based sticker makers compatible with WhatsApp Web allow you to pair a square image with a short MP3/WAV clip and export it for your chats.</li></ul><p><strong>Have you received the Sound Stickers update on your phone yet?</strong> Drop a comment below and let me know what your go-to audio sticker is going to be!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62c160934bab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Eliminating Chrome Print Popups in Web POS: Building a Sub-10ms MQTT Thermal Print Bridge]]></title>
            <link>https://medium.com/@premodsuraweera1/eliminating-chrome-print-popups-in-web-pos-building-a-sub-10ms-mqtt-thermal-print-bridge-2a1c12f62772?source=rss-540f49a34470------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a1c12f62772</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[point-of-sale]]></category>
            <dc:creator><![CDATA[Premodsuraweera]]></dc:creator>
            <pubDate>Sun, 15 Nov 2026 07:59:42 GMT</pubDate>
            <atom:updated>2026-11-15T07:59:42.500Z</atom:updated>
            <content:encoded><![CDATA[<p>How we replaced clunky browser print dialogs and heavy Java runtimes with a lightweight 25MB background daemon for instant ESC/POS receipt printing.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FP3slOj1VNDE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fshorts%2FP3slOj1VNDE%3Ffeature%3Dshare&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FP3slOj1VNDE%2Fhq2.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0bb0e98e69689c1db47f312738899d5b/href">https://medium.com/media/0bb0e98e69689c1db47f312738899d5b/href</a></iframe><h3>The Hidden Bottleneck in Web-Based POS Systems</h3><p>If you have ever built a Point of Sale (POS) web application using React, Vue, Laravel, or PHP, you have inevitably hit the same frustrating wall: <strong>printing a physical receipt.</strong></p><p>In a standard web browser, triggering a print job means calling window.print(). While fine for printing web pages, it is a nightmare for retail checkouts, restaurants, and pharmacies:</p><ol><li><strong>The Modal Interrupt:</strong> Every single sale pops up the Chrome or Edge print preview dialog. Cashiers have to manually click “Print” or hit Enter every single time, adding seconds to every transaction and creating queues.</li><li><strong>Hardware Blindness:</strong> Browsers cannot natively send raw ESC/POS commands to trigger an automatic paper cut or kick open an RJ11 cash drawer.</li><li><strong>Heavy Workarounds:</strong> Traditionally, developers rely on tools like QZ Tray. While functional, it forces you to install a bulky Java Runtime Environment (JRE) on every client terminal, manage self-signed security certificates, and deal with high memory overhead.</li></ol><p>We wanted something simpler, faster, and built for modern web stacks. So, we built <strong>PrintBridge</strong>.</p><h3>How PrintBridge Works Under the Hood</h3><p>Instead of fighting browser sandboxes, PrintBridge decouples the web frontend from the physical hardware using a lightweight (~25MB) Windows background service and an ultra-fast messaging layer.</p><p>Here is the 3-step lifecycle of a receipt print job:</p><h4>1. The Web POS Trigger</h4><p>When a cashier completes a checkout, your frontend fires a clean JSON payload via our lightweight Browser JS SDK, Cloud REST API, or directly to localhost:8080. You pass standard HTML/CSS for the receipt layout alongside hardware flags like width: &quot;80mm&quot;, cutPaper: true, and openDrawer: true.</p><h4>2. Sub-10ms MQTT Messaging</h4><p>Instead of slow HTTP polling, PrintBridge communicates over a dedicated <strong>MQTT 3.1.1</strong> broker. Print commands travel from your cloud app to the local POS terminal in <strong>under 10 milliseconds</strong>.</p><h4>3. Silent Headless Rendering &amp; Raw Spooling</h4><p>The local Node.js daemon listens silently in the background. Upon receiving a payload, it renders pixel-perfect HTML receipts — complete with store logos, QR codes, and barcodes — and injects raw ESC/POS commands straight into the Windows print spooler (winspool.Drv) in under <strong>350ms</strong>.</p><h3>Integrating It in 10 Lines of Code</h3><p>We designed the developer experience so you can integrate silent printing into any existing web app in minutes:</p><pre>&lt;!-- 1. Include the PrintBridge JS SDK --&gt;<br>&lt;script src=&quot;https://printbridge.online/sdk/v1/printbridge.js&quot;&gt;&lt;/script&gt;<br><br>&lt;script&gt;<br>  async function printReceipt(deviceId, receiptHtml) {<br>    // 2. Fetch available thermal printers on the POS terminal<br>    const { printers } = await window.PrintBridge.getPrinters({ deviceId });<br><br>    // 3. Print silently + Auto-Cut + Open Cash Drawer<br>    await window.PrintBridge.print({<br>      deviceId: deviceId,<br>      printerName: printers[0] || &#39;Default&#39;,<br>      width: &#39;80mm&#39;,<br>      cutPaper: true,<br>      openDrawer: true,<br>      html: receiptHtml<br>    });<br>  }<br>&lt;/script&gt;</pre><h3>Built for 24/7 Retail Reliability</h3><p>Retail environments are unforgiving — internet connections drop, computers reboot, and printers run out of paper. PrintBridge v3.12.1 is engineered to handle real-world chaos:</p><ul><li><strong>Offline Print Queue:</strong> If the network or printer temporarily drops, jobs are saved to a local disk-backed queue (offline-queue.json) and automatically retried every 15 seconds.</li><li><strong>Native Windows Boot Service:</strong> Starts automatically when the POS PC boots up — even before a cashier logs into Windows.</li><li><strong>Real-Time Print ACKs &amp; Webhooks:</strong> Bi-directional MQTT acknowledgments and HMAC-SHA256 webhooks notify your backend the exact millisecond a receipt finishes printing.</li><li><strong>Universal Printer Support:</strong> Tested across Xprinter (XP-80C, XP-58), Epson (TM-T20, TM-T88), Rongta, Bixolon, and Star Micronics.</li></ul><h3>Try It on Your Setup</h3><p>If you are building a Web POS, ERP, or WooCommerce checkout system and want to eliminate browser print popups for good, you can test PrintBridge on your own physical thermal printers with a <strong>14-day free trial</strong> (no credit card required).</p><p>👉 <strong>Check out the live demo and documentation at </strong><a href="https://printbridge.online/"><strong>printbridge.online</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a1c12f62772" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We Reduced a Laravel Bulk Delivery Preview from Minutes to Under 800ms]]></title>
            <link>https://medium.com/@premodsuraweera1/how-we-reduced-a-laravel-bulk-delivery-preview-from-minutes-to-under-800ms-9683d90dcdc7?source=rss-540f49a34470------2</link>
            <guid isPermaLink="false">https://medium.com/p/9683d90dcdc7</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[performance-optimization]]></category>
            <dc:creator><![CDATA[Premodsuraweera]]></dc:creator>
            <pubDate>Wed, 14 Oct 2026 05:39:49 GMT</pubDate>
            <atom:updated>2026-10-14T05:39:49.261Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Eliminating hidden HTTP N+1 calls by replacing runtime API requests with local lookups and scheduled data synchronization.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iNgP0TPs2So2Nf5pG2zCNA.png" /></figure><h3>Introduction</h3><p>Performance bottlenecks don’t always come from complex database queries or inefficient algorithms. Sometimes, the real problem is hidden behind a seemingly harmless service method.</p><p>Recently, while working on a bulk courier dispatch workflow in our ERP system, we encountered a critical performance issue. Generating a delivery preview for just 30–50 selected orders could take minutes or even exceed PHP’s max_execution_time.</p><p>The frustrating part? The application wasn’t performing any particularly complex calculations. It was spending most of its time waiting for external API responses.</p><p>Here’s how we identified the bottleneck, redesigned the address resolution process, and reduced the preview generation time to under 800 milliseconds.</p><h3>1. The Problem: Hidden HTTP N+1 Calls</h3><p>Our ERP system integrates with the Koombiyo Delivery API to dispatch orders. Before creating a delivery, we need to resolve customer addresses against the courier’s official district and city identifiers.</p><p>For example, a customer address might contain:</p><ul><li>City: Nugegoda</li><li>District: Missing or incorrectly identified</li><li>Courier City ID: Unknown</li></ul><p>To create a valid delivery request, our application must identify the correct city and district IDs expected by the courier API.</p><p>The initial implementation handled this by attempting to resolve the city across a list of priority districts whenever the customer’s district was missing or mismatched.</p><p>The problem was hidden inside the fallback logic.</p><p>For every district considered during resolution, the service made a synchronous HTTP request to retrieve its cities.</p><p>Conceptually, the code behaved like this:</p><pre>foreach ($orders as $order) {<br>    $city = resolveCity($order-&gt;city, $order-&gt;district);<br>}</pre><p>Inside resolveCity(), the fallback logic could trigger multiple external API calls:</p><pre>foreach ($priorityDistricts as $district) {<br>    $cities = $courierApi-&gt;getCities($district);    // Search for the matching city.<br>}</pre><p>This created an HTTP N+1 problem.</p><p>Unlike a typical database N+1 issue, where an application executes repeated queries, this implementation repeatedly called an external service over the network.</p><h3>Why did this become a serious bottleneck?</h3><p>Consider a batch of 30 orders where several addresses require fallback resolution.</p><p>If each unresolved address triggers requests across multiple districts, the number of outbound requests can grow rapidly.</p><p>With up to 25 requests per unresolved order, the theoretical worst case for 30 orders is:</p><p>[<br>30 \times 25 = 750 \text{ HTTP requests}<br>]</p><p>Even if individual requests have timeouts of only a few seconds, the total execution time can become unacceptable when requests are executed sequentially.</p><p>Network latency, external API response times, connection overhead, and temporary service degradation all contribute to the problem.</p><p><strong>The application was spending more time waiting for network responses than processing the orders themselves.</strong></p><h3>2. The Architectural Mistake: Fetching Reference Data at Runtime</h3><p>The fundamental issue wasn’t simply that cURL was slow.</p><p>It was that we were fetching semi-static reference data repeatedly during a user-facing operation.</p><p>Courier districts and cities are examples of master data. They may change occasionally, but they generally don’t need to be fetched every time a user opens a delivery preview.</p><p>Our original architecture looked like this:</p><pre>User selects 30–50 orders<br>          |<br>          v<br>Generate delivery preview<br>          |<br>          v<br>Resolve each customer address<br>          |<br>          v<br>Call courier API repeatedly<br>          |<br>          v<br>Wait for network responses<br>          |<br>          v<br>Return preview</pre><p>The entire preview depended on the responsiveness of an external logistics provider, even though the preview primarily needed data that could already have been stored locally.</p><p>This introduced unnecessary network overhead into a critical user-facing workflow.</p><p>We needed to separate <strong>reference data synchronization</strong> from <strong>address resolution</strong>.</p><h3>3. The Solution: Synchronize Once, Resolve Locally</h3><p>We redesigned the workflow around a simple principle:</p><p><strong>Fetch external reference data when it needs to be synchronized, not every time it needs to be used.</strong></p><p>The new architecture separates the process into two independent operations.</p><h3>Step 1: Create a dedicated Artisan command</h3><p>We introduced a Laravel Artisan command responsible for synchronizing the courier’s district and city directory.</p><pre>php artisan courier:sync-koombiyo-areas</pre><p>The command retrieves the relevant geographic data from the courier API and stores it in local database tables.</p><p>For example, the data can be organized into two tables.</p><p><strong>courier_districts</strong></p><p>ColumnPurposeidLocal primary keyexternal_idCourier&#39;s district IDnameDistrict namenormalized_nameNormalized district name</p><p><strong>courier_cities</strong></p><p>ColumnPurposeidLocal primary keyexternal_idCourier&#39;s city IDdistrict_idRelated local districtnameCity namenormalized_nameNormalized city name</p><p>The external IDs are important because they allow our ERP to use the identifiers expected by the courier API when creating deliveries.</p><p>We also normalize city and district names during synchronization so that common formatting differences can be handled consistently.</p><p>For example:</p><pre>&quot;Nugegoda&quot;  -&gt; &quot;nugegoda&quot;<br>&quot; Nugegoda &quot; -&gt; &quot;nugegoda&quot;<br>&quot;NUGEGODA&quot;  -&gt; &quot;nugegoda&quot;</pre><p>This eliminates unnecessary differences caused by capitalization and surrounding whitespace.</p><h3>Step 2: Schedule the synchronization</h3><p>The synchronization command can run automatically during off-peak hours using Laravel’s task scheduler.</p><p>For example, in routes/console.php:</p><pre>use Illuminate\Support\Facades\Schedule;</pre><pre>Schedule::command(&#39;courier:sync-koombiyo-areas&#39;)<br>    -&gt;dailyAt(&#39;02:00&#39;)<br>    -&gt;withoutOverlapping();</pre><p>The production server must have Laravel’s scheduler running for scheduled commands to execute.</p><p>For example, a standard cron entry can invoke Laravel’s scheduler every minute:</p><pre>* * * * * cd /path/to/project &amp;&amp; php artisan schedule:run &gt;&gt; /dev/null 2&gt;&amp;1</pre><p>A production-ready synchronization process should also handle API failures, log errors, and avoid replacing valid local data with incomplete responses.</p><p>The goal is to keep the local directory usable even when the courier API is temporarily unavailable.</p><h3>4. Build an In-Memory Lookup Map</h3><p>Persisting the data locally eliminates repeated HTTP requests, but we can also reduce repeated database queries during bulk address resolution.</p><p>For this, we load the relevant city and district data into a cache-backed lookup map.</p><p>Laravel’s Cache::remember() is useful here because it retrieves the cached value when available and executes the supplied callback only when the cache entry is missing or expired.</p><p>For example:</p><pre>use Illuminate\Support\Facades\Cache;<br>use Illuminate\Support\Facades\DB;</pre><pre>$cityMap = Cache::remember(<br>    &#39;koombiyo_city_map&#39;,<br>    now()-&gt;addHours(24),<br>    function () {<br>        return DB::table(&#39;courier_cities&#39;)<br>            -&gt;join(<br>                &#39;courier_districts&#39;,<br>                &#39;courier_cities.district_id&#39;,<br>                &#39;=&#39;,<br>                &#39;courier_districts.id&#39;<br>            )<br>            -&gt;select([<br>                &#39;courier_cities.external_id as city_id&#39;,<br>                &#39;courier_cities.normalized_name as city_name&#39;,<br>                &#39;courier_districts.external_id as district_id&#39;,<br>                &#39;courier_districts.normalized_name as district_name&#39;,<br>            ])<br>            -&gt;get()<br>            -&gt;groupBy(&#39;city_name&#39;)<br>            -&gt;map(fn ($cities) =&gt; $cities-&gt;values()-&gt;all())<br>            -&gt;all();<br>    }<br>);</pre><p>This is an illustrative implementation; the actual schema and lookup structure should match your application’s data model.</p><p>The resulting map allows the application to retrieve candidate cities by normalized city name without querying the database for every order.</p><pre>$normalizedCity = strtolower(trim($customerCity));</pre><pre>$candidates = $cityMap[$normalizedCity] ?? [];</pre><p>Because a city name can exist in more than one district, the lookup should return candidate matches rather than blindly assuming that each city name is globally unique.</p><p>The resolver can then apply the appropriate district, postal address, or business-specific matching rules.</p><p>For a hash-map lookup, the expected lookup complexity is approximately <strong>O(1)</strong>. Searching through all candidates for a particular city still depends on the number of candidates, while broad substring matching across the entire directory can take O(n).</p><p>The important improvement is that these operations happen locally instead of waiting for remote HTTP responses.</p><h3>5. Refactor the Address Resolution Logic</h3><p>With the data available locally, the address resolution process becomes much simpler.</p><p>Instead of calling the courier API from inside the fallback loop, we resolve the city using the cached directory.</p><p>The following example illustrates the approach:</p><pre>function resolveCourierCity(<br>    string $city,<br>    ?string $district,<br>    array $cityMap<br>): ?array {<br>    $normalizedCity = strtolower(trim($city));<br>    $normalizedDistrict = strtolower(trim($district ?? &#39;&#39;));</pre><pre>    $candidates = $cityMap[$normalizedCity] ?? [];</pre><pre>    if ($candidates === []) {<br>        return null;<br>    }</pre><pre>    // Prefer an exact district match when available.<br>    foreach ($candidates as $candidate) {<br>        if (<br>            $normalizedDistrict !== &#39;&#39; &amp;&amp;<br>            $candidate-&gt;district_name === $normalizedDistrict<br>        ) {<br>            return [<br>                &#39;city_id&#39; =&gt; $candidate-&gt;city_id,<br>                &#39;district_id&#39; =&gt; $candidate-&gt;district_id,<br>            ];<br>        }<br>    }</pre><pre>    // Apply an explicit fallback policy when the district is missing<br>    // or does not match any candidate.<br>    if (count($candidates) === 1) {<br>        return [<br>            &#39;city_id&#39; =&gt; $candidates[0]-&gt;city_id,<br>            &#39;district_id&#39; =&gt; $candidates[0]-&gt;district_id,<br>        ];<br>    }</pre><pre>    // Multiple candidates remain ambiguous.<br>    return null;<br>}</pre><p>This example deliberately returns null when multiple candidates remain ambiguous. In a real delivery system, selecting the wrong district can be worse than asking someone to correct the address.</p><p>Depending on the application’s requirements, the fallback policy may include additional normalized matching rules, known district priorities, or manual review.</p><p>The important point is that the resolution process no longer performs external HTTP requests.</p><h3>6. The New Architecture</h3><p>The updated workflow looks like this:</p><pre>Scheduled Artisan Command<br>          |<br>          v<br>Fetch courier reference data<br>          |<br>          v<br>Validate and normalize data<br>          |<br>          v<br>Persist local directory<br>          |<br>          v<br>Refresh lookup cache</pre><p>The user-facing delivery preview now follows a separate path:</p><pre>User selects 30–50 orders<br>          |<br>          v<br>Load cached city directory<br>          |<br>          v<br>Resolve customer addresses locally<br>          |<br>          v<br>Build delivery preview<br>          |<br>          v<br>Return response</pre><p>These two workflows are independent.</p><p>If the courier API becomes temporarily unavailable, the delivery preview can still use the most recently synchronized directory.</p><p>The actual dispatch operation may still require the courier API, but simply preparing the preview no longer depends on the external provider being available.</p><h3>7. Performance Results</h3><p>After the refactoring, the observed performance changed significantly.</p><p>MetricBeforeAfterExternal HTTP calls during previewApproximately 50–200+0Delivery preview generationApproximately 60–120+ secondsUnder 800 msDependence on courier uptime for previewHighSignificantly reduced</p><p>These figures represent the observed results from our workflow, not universal performance guarantees.</p><p>The improvement came primarily from eliminating repeated blocking network calls, not from introducing a more complicated algorithm.</p><p>This is an important distinction.</p><p>Optimizing a local loop might save milliseconds. Removing hundreds of sequential network requests can save tens of seconds or more.</p><h3>8. Important Lessons Learned</h3><h3>1. Don’t confuse API integration with API dependency</h3><p>Integrating with an external service does not mean every operation must call that service in real time.</p><p>Identify which operations genuinely require live responses and which can use synchronized reference data.</p><h3>2. Treat semi-static master data as a local dependency</h3><p>Geographic directories, delivery zones, supported payment methods, product categories, and similar reference data are often good candidates for local persistence and caching.</p><p>The appropriate synchronization frequency depends on how frequently the underlying data changes and how costly stale data would be.</p><h3>3. Never hide network calls inside utility methods</h3><p>A method called resolveCity() sounds like a local computation. If it secretly performs several HTTP requests, its runtime cost becomes difficult to predict.</p><p>Keep network access explicit and separate from pure resolution logic.</p><h3>4. Cache invalidation must be deliberate</h3><p>A cache with a 24-hour TTL is not a complete synchronization strategy.</p><p>After a successful sync, invalidate or refresh the relevant cache key. If synchronization fails, preserve the last known-good dataset instead of replacing it with incomplete data.</p><p>Where multiple application servers are involved, use a shared cache such as Redis rather than relying on process-local memory.</p><h3>5. Optimize the entire request lifecycle</h3><p>Database indexes, efficient Eloquent queries, and optimized algorithms matter. But they won’t solve a bottleneck caused by hundreds of sequential external HTTP requests.</p><p>Measure where time is actually being spent before choosing an optimization strategy.</p><h3>Conclusion</h3><p>This experience reinforced a fundamental backend engineering principle: <strong>not every external dependency belongs in the runtime path of a user-facing request.</strong></p><p>By moving courier reference data synchronization into a scheduled Artisan command, persisting the data locally, and using cache-backed lookups, we removed the hidden HTTP N+1 problem from our bulk delivery preview.</p><p>The result was a workflow that became significantly faster, more predictable, and more resilient to third-party service interruptions.</p><p>Sometimes, the best performance optimization isn’t making the code execute faster.</p><p>It’s eliminating the work that never needed to happen in the first place.</p><p><strong>What about your systems?</strong></p><p>How do you handle semi-static geographic data, delivery zones, or other master data from third-party APIs in your Laravel applications or microservices?</p><p>Do you prefer scheduled synchronization, event-driven updates, or a hybrid approach?</p><p>I’d be interested to hear how other backend engineers solve this problem.</p><p>#Laravel #PHP #BackendDevelopment #SoftwareArchitecture #APIOptimization #PerformanceEngineering</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9683d90dcdc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Koombiyo Delivery API with Laravel: A Pragmatic Guide]]></title>
            <link>https://medium.com/@premodsuraweera1/integrating-koombiyo-delivery-api-with-laravel-a-pragmatic-guide-ea99ccb1a79d?source=rss-540f49a34470------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea99ccb1a79d</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[api-integration]]></category>
            <dc:creator><![CDATA[Premodsuraweera]]></dc:creator>
            <pubDate>Mon, 03 Aug 2026 15:40:28 GMT</pubDate>
            <atom:updated>2026-08-03T15:40:28.979Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wbrYvNUkuyl_DByI9Ahvuw.png" /></figure><p>If you’re building an e-commerce platform or ERP in Sri Lanka, integrating with a local courier service like Koombiyo can save a lot of manual work.</p><p>But courier API integrations are rarely as simple as sending one HTTP request. You have to deal with <strong>pre-allocated waybills, district and city IDs, API-specific error codes, and inconsistent customer data</strong>.</p><p>In this guide, I’ll show a clean, service-oriented approach to integrating the Koombiyo Delivery API with Laravel.</p><h3>1. Keep the Integration Out of Your Controllers</h3><p>A common mistake is putting API calls directly inside controllers.</p><p>Instead, isolate Koombiyo-specific logic inside a service:</p><pre>Controller<br>    │<br>    ▼<br>KoombiyoDeliveryService<br>    │<br>    ├── Waybill allocation<br>    ├── District / City lookup<br>    ├── Order dispatch<br>    └── API error handling<br>    │<br>    ▼<br>Koombiyo API</pre><p>The controller should mainly handle your application’s business logic, while the service handles communication with Koombiyo.</p><p>For example:</p><pre>app/<br>├── Http/Controllers/<br>│   └── DeliveryController.php<br>│<br>└── Services/<br>    └── KoombiyoDeliveryService.php</pre><p>This makes the integration easier to test, maintain, and extend later.</p><h3>2. Load API Credentials Dynamically</h3><p>If your ERP supports multiple courier accounts, don’t hardcode one API key.</p><p>Store courier credentials in your database and load them based on the selected courier:</p><pre>function getCourierAgentAPIConfig($courierId)<br>{<br>    $courier = CourierAgent::findOrFail($courierId);</pre><pre>    return [<br>        &#39;api_key&#39; =&gt; $courier-&gt;api_key,<br>    ];<br>}</pre><p>This allows the same delivery system to work with different courier accounts.</p><h3>3. Finding an Unused Waybill</h3><p>One of the interesting parts of the Koombiyo API is waybill allocation.</p><p>Koombiyo provides a list of waybills allocated to your account. Your application needs to find one that hasn’t already been used locally.</p><pre>public function getUnusedWaybill(string $apiKey): ?string<br>{<br>    $response = Http::asForm()-&gt;post(<br>        &#39;https://application.koombiyodelivery.lk/api/Waybils/users&#39;,<br>        [<br>            &#39;apiKey&#39; =&gt; $apiKey<br>        ]<br>    );<br>    $allocated = $response-&gt;json();<br><br>    $used = Delivery::whereIn(&#39;waybill_no&#39;, $allocated)<br>        -&gt;pluck(&#39;waybill_no&#39;)<br>        -&gt;toArray();<br>    <br>    $available = array_diff($allocated, $used);<br><br>    return reset($available) ?: null;<br>}</pre><p>The basic flow is:</p><pre>Koombiyo Waybills<br>       ↓<br>Get allocated numbers<br>       ↓<br>Compare with local DB<br>       ↓<br>Find unused number<br>       ↓<br>Assign to delivery</pre><p>In production, you should also consider concurrency. Two requests arriving at the same time shouldn’t be able to select the same waybill.</p><h3>4. District and City Mapping</h3><p>Another challenge is that Koombiyo doesn’t simply accept:</p><pre>Colombo<br>Dehiwala</pre><p>Instead, it expects IDs such as:</p><pre>district_id<br>city_id</pre><p>Calling the Koombiyo location API on every checkout would add unnecessary latency.</p><p>So cache the relatively static location data.</p><pre>public function resolveDistrictAndCity(<br>    string $apiKey,<br>    string $targetDistrict,<br>    string $targetCity<br>): array {<br>    $districts = Cache::remember(<br>        &#39;koombiyo_districts&#39;,<br>        86400,<br>        function () use ($apiKey) {<br>            return Http::asForm()<br>                -&gt;post(<br>                    &#39;https://application.koombiyodelivery.lk/api/Districts/users&#39;,<br>                    [&#39;apiKey&#39; =&gt; $apiKey]<br>                )<br>                -&gt;json();<br>        }<br>    );<br><br>    $district = collect($districts)-&gt;first(<br>        fn ($item) =&gt;<br>            strcasecmp($item[&#39;district_name&#39;], $targetDistrict) === 0<br>    );<br><br>    if (!$district) {<br>        throw new Exception(&quot;District not found: {$targetDistrict}&quot;);<br>    }<br>    <br>    $districtId = $district[&#39;district_id&#39;];<br><br>    $cities = Cache::remember(<br>        &quot;koombiyo_cities_{$districtId}&quot;,<br>        86400,<br>        function () use ($apiKey, $districtId) {<br>            return Http::asForm()<br>                -&gt;post(<br>                    &#39;https://application.koombiyodelivery.lk/api/Cities/users&#39;,<br>                    [<br>                        &#39;apiKey&#39; =&gt; $apiKey,<br>                        &#39;district_id&#39; =&gt; $districtId<br>                    ]<br>                )<br>                -&gt;json();<br>        }<br>    );<br><br>    $city = collect($cities)-&gt;first(<br>        fn ($item) =&gt;<br>            strcasecmp($item[&#39;city_name&#39;], $targetCity) === 0<br>    );<br>    if (!$city) {<br>        throw new Exception(&quot;City not found: {$targetCity}&quot;);<br>    }<br>    return [<br>        &#39;district_id&#39; =&gt; $districtId,<br>        &#39;city_id&#39; =&gt; $city[&#39;city_id&#39;],<br>    ];    <br>}</pre><h3>Don’t silently fallback to ID 1</h3><p>It might be tempting to do this:</p><pre>$cityId = 1;</pre><p>when a city isn’t found.</p><p>Don’t.</p><p>A wrong city ID can result in a delivery going to the wrong location. It’s better to stop the request and tell the user that the location needs to be corrected.</p><h3>5. Create the Pickup Request</h3><p>Once you have the waybill and location IDs, you can send the order to Koombiyo.</p><pre>public function sendPickupRequest(<br>    array $orderData,<br>    string $apiKey<br>): array {<br>    $payload = [<br>        &#39;apikey&#39;           =&gt; $apiKey,<br>        &#39;orderWaybillid&#39;   =&gt; $orderData[&#39;waybill_no&#39;],<br>        &#39;orderNo&#39;          =&gt; $orderData[&#39;order_reference&#39;],<br>        &#39;receiverName&#39;     =&gt; $orderData[&#39;customer_name&#39;],<br>        &#39;receiverStreet&#39;   =&gt; $orderData[&#39;address&#39;],<br>        &#39;receiverDistrict&#39; =&gt; $orderData[&#39;district_id&#39;],<br>        &#39;receiverCity&#39;     =&gt; $orderData[&#39;city_id&#39;],<br>        &#39;receiverPhone&#39;    =&gt; $orderData[&#39;phone&#39;],<br>        &#39;spclNote&#39;         =&gt; $orderData[&#39;special_instructions&#39;] ?? &#39;&#39;,<br>        &#39;getCod&#39;           =&gt; $orderData[&#39;is_paid&#39;]<br>            ? 0<br>            : $orderData[&#39;grand_total&#39;],<br>    ];<br><br>$response = Http::asForm()-&gt;post(<br>        &#39;https://application.koombiyodelivery.lk/api/Addorders/users&#39;,<br>        $payload<br>    );<br>    return [<br>        &#39;status&#39;  =&gt; $response-&gt;successful()<br>                    &amp;&amp; $response-&gt;body() === &#39;200&#39;,<br>        &#39;code&#39;    =&gt; $response-&gt;body(),<br>        &#39;payload&#39; =&gt; $payload,<br>    ];<br>}</pre><p>The important thing here is that the request uses:</p><pre>Http::asForm()</pre><p>because the API expects application/x-www-form-urlencoded data.</p><h3>6. Putting Everything Together</h3><p>The controller can now orchestrate the process without knowing the details of the Koombiyo API.</p><pre>public function handleKoombiyo($deliveryId)<br>{<br>    $delivery = Delivery::findOrFail($deliveryId);<br><br>$config = getCourierAgentAPIConfig(<br>        $delivery-&gt;courier_id<br>    );<br>    $waybill = $this-&gt;koombiyoService<br>        -&gt;getUnusedWaybill($config[&#39;api_key&#39;]);<br>    if (!$waybill) {<br>        return back()-&gt;with(<br>            &#39;error&#39;,<br>            &#39;No unused waybills available.&#39;<br>        );<br>    }<br>    $location = $this-&gt;koombiyoService<br>        -&gt;resolveDistrictAndCity(<br>            $config[&#39;api_key&#39;],<br>            $delivery-&gt;shipping_district,<br>            $delivery-&gt;shipping_city<br>        );<br>    $orderData = array_merge(<br>        $delivery-&gt;toArray(),<br>        $location,<br>        [&#39;waybill_no&#39; =&gt; $waybill]<br>    );<br>    $result = $this-&gt;koombiyoService<br>        -&gt;sendPickupRequest(<br>            $orderData,<br>            $config[&#39;api_key&#39;]<br>        );<br>    if ($result[&#39;status&#39;]) {<br>        $delivery-&gt;update([<br>            &#39;is_pickup_request_sent&#39; =&gt; true,<br>            &#39;pickup_request&#39; =&gt; json_encode($result[&#39;payload&#39;]),<br>            &#39;waybill_no&#39; =&gt; $waybill,<br>            &#39;status&#39; =&gt; 4,<br>        ]);<br>        return back()-&gt;with(<br>            &#39;success&#39;,<br>            &quot;Dispatched successfully: {$waybill}&quot;<br>        );<br>    }<br>    return back()-&gt;with(<br>        &#39;error&#39;,<br>        &quot;Koombiyo API Error: {$result[&#39;code&#39;]}&quot;<br>    );<br>}</pre><p>Now the responsibility is clear:</p><p><strong>Controller:</strong> business flow and database state</p><p><strong>Service:</strong> Koombiyo API communication</p><p><strong>Cache:</strong> district and city lookup data</p><p><strong>Database:</strong> delivery and waybill history</p><h3>7. Handling Koombiyo API Errors</h3><p>One thing that makes this integration different from many modern APIs is that Koombiyo can return numeric response codes instead of structured JSON errors.</p><p>Some useful codes to handle:</p><p>CodeMeaning200Success201Account inactive / invalid COD202Invalid API key205–207Missing recipient information208Invalid phone number209 / 218Invalid city220Invalid COD value</p><p>Don’t just show the raw code to the user.</p><p>Instead, convert API responses into meaningful application-level errors:</p><pre>Koombiyo 208<br>     ↓<br>Invalid phone number<br>     ↓<br>&quot;Please enter a valid customer phone number.&quot;</pre><p>This makes the system much easier for warehouse and customer-service staff to use.</p><h3>8. A Few Production Considerations</h3><p>The basic integration works, but there are several things worth improving before using it heavily in production.</p><h3>Cache per API account</h3><p>If multiple courier accounts use different API keys, avoid sharing cached location data blindly across accounts.</p><h3>Validate before requesting a waybill</h3><p>Validate customer name, phone, address, city, COD amount, etc. before consuming a waybill.</p><h3>Store API responses</h3><p>Keep the request and response for debugging and delivery history.</p><h3>Prevent duplicate dispatches</h3><p>Before sending an order, make sure it hasn’t already been successfully dispatched.</p><h3>Handle concurrent waybill selection</h3><p>Two simultaneous requests should not select the same waybill. Use database transactions or locking where appropriate.</p><h3>Use Laravel’s HTTP client</h3><p>Laravel’s Http client is much cleaner than manually managing cURL requests and gives you useful features such as timeouts, retries, and structured responses.</p><h3>Conclusion</h3><p>Integrating Koombiyo into a Laravel application is fairly simple once you understand how the API works. The tricky part is everything around the API — finding an available waybill, matching customer locations, handling invalid data, and dealing with Koombiyo’s response codes.</p><p>Keeping those parts inside a dedicated KoombiyoDeliveryService helped keep the delivery logic separate from the rest of the ERP code. Caching the district and city data also avoids unnecessary API calls every time an order is dispatched.</p><p>There are still more things you can improve depending on your requirements, such as retry handling, better validation, delivery status syncing, and supporting multiple courier services.</p><p>Hopefully, this gives you a practical starting point if you’re working on a Laravel e-commerce or ERP system that needs Koombiyo integration.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea99ccb1a79d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The HTTP QUERY Method: Finally Fixing One of REST’s Biggest Design Problems]]></title>
            <link>https://medium.com/@premodsuraweera1/the-http-query-method-finally-fixing-one-of-rests-biggest-design-problems-091bdb0f04ef?source=rss-540f49a34470------2</link>
            <guid isPermaLink="false">https://medium.com/p/091bdb0f04ef</guid>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[backend-development]]></category>
            <dc:creator><![CDATA[Premodsuraweera]]></dc:creator>
            <pubDate>Sat, 04 Jul 2026 14:19:56 GMT</pubDate>
            <atom:updated>2026-07-04T14:19:56.966Z</atom:updated>
            <content:encoded><![CDATA[<p>For decades, developers have had to choose between two imperfect options when building read-only APIs.</p><p>Need to retrieve data with simple parameters? Use GET.</p><p>Need to send complex filters or large payloads? Use POST, even though you&#39;re not actually creating or modifying anything.</p><p>This has always felt like an architectural compromise.</p><p>The new <strong>HTTP QUERY</strong> method, standardized by the Internet Engineering Task Force (IETF), aims to solve that problem by introducing a request method specifically designed for complex, read-only operations.</p><h3>The Problem with GET</h3><p>GET is the standard method for retrieving resources.</p><p>It has several important properties:</p><ul><li>Safe (it should not modify server state)</li><li>Idempotent (making the same request multiple times has the same effect)</li><li>Cacheable by browsers and intermediaries</li></ul><p>The issue is that GET carries request parameters in the URL.</p><p>For simple searches, that’s perfectly fine.</p><pre>GET /users?status=active&amp;page=2</pre><p>But modern applications often require much more sophisticated queries:</p><ul><li>Nested filters</li><li>Large search criteria</li><li>Arrays of values</li><li>Complex sorting rules</li><li>Field selection</li><li>Advanced reporting options</li></ul><p>Trying to squeeze all of that into a URL quickly becomes difficult.</p><p>Long URLs can exceed practical limits imposed by browsers, servers, or proxies. They are also logged in many places, potentially exposing sensitive query information.</p><p>Although some clients technically allow a body on a GET request, the HTTP specification has never defined clear semantics for it, and many servers, proxies, and client libraries ignore or reject it.</p><h3>Why POST Isn’t the Right Answer</h3><p>To work around GET’s limitations, many APIs use POST for search endpoints.</p><p>For example:</p><pre>POST /users/search</pre><p>with a JSON body:</p><pre>{<br>  &quot;filter&quot;: {<br>    &quot;status&quot;: &quot;active&quot;,<br>    &quot;role&quot;: &quot;admin&quot;<br>  },<br>  &quot;limit&quot;: 100<br>}</pre><p>This works technically.</p><p>But semantically, it isn’t ideal.</p><p>POST is intended for operations that may create resources or produce side effects.</p><p>Because of that, caches, proxies, browsers, and other HTTP infrastructure generally treat POST requests differently from GET requests.</p><p>Even if your POST endpoint is completely read-only, the HTTP ecosystem cannot safely assume that.</p><p>The result is a loss of many benefits that make HTTP efficient.</p><h3>Enter the QUERY Method</h3><p>The new <strong>QUERY</strong> method combines the best aspects of both GET and POST.</p><p>It allows:</p><ul><li>A request body</li><li>Safe semantics</li><li>Idempotent behavior</li><li>Cache-friendly responses</li></ul><p>In other words, it provides a standardized way to perform complex retrieval operations without pretending they’re resource modifications.</p><p>A QUERY request looks like this:</p><pre>QUERY /users HTTP/1.1<br>Host: api.example.com<br>Content-Type: application/json</pre><pre>{<br>  &quot;filter&quot;: {<br>    &quot;status&quot;: &quot;active&quot;,<br>    &quot;role&quot;: &quot;admin&quot;,<br>    &quot;joined_after&quot;: &quot;2026-01-01&quot;<br>  },<br>  &quot;select&quot;: [<br>    &quot;id&quot;,<br>    &quot;name&quot;,<br>    &quot;email&quot;<br>  ],<br>  &quot;limit&quot;: 100<br>}</pre><p>The request body contains structured data, while the method itself clearly communicates that this is still a read-only operation.</p><h3>Why This Matters</h3><p>Many APIs today expose endpoints such as:</p><pre>POST /search<br>POST /filter<br>POST /query<br>POST /report</pre><p>These endpoints are not actually performing write operations.</p><p>They’re simply retrieving data with complex criteria.</p><p>QUERY allows developers to express their intent correctly.</p><p>Instead of overloading POST, the request itself communicates that the operation is safe, repeatable, and suitable for caching.</p><p>That makes APIs easier to understand and enables HTTP infrastructure to make smarter decisions.</p><h3>The Adoption Challenge</h3><p>Like many improvements to core web standards, the biggest hurdle isn’t the specification — it’s adoption.</p><p>The HTTP ecosystem contains decades of infrastructure:</p><ul><li>Reverse proxies</li><li>Load balancers</li><li>Firewalls</li><li>API gateways</li><li>Client SDKs</li><li>Corporate security appliances</li></ul><p>Many of these systems only recognize the traditional HTTP methods.</p><p>An unfamiliar method such as QUERY may be rejected before it ever reaches your application.</p><p>Because of this, adopting QUERY for public internet APIs today may cause compatibility issues unless every component in the request path supports it.</p><h3>Where QUERY Makes Sense Today</h3><p>Despite current limitations, QUERY already has compelling use cases.</p><p>It fits particularly well in environments where you control the entire stack:</p><ul><li>Internal microservices</li><li>Service-to-service communication</li><li>Enterprise APIs</li><li>Private networks</li><li>Modern infrastructure built around updated HTTP tooling</li></ul><p>As support grows across servers, frameworks, proxies, and client libraries, QUERY has the potential to become the standard method for complex read-only operations.</p><h3>Final Thoughts</h3><p>The QUERY method doesn’t introduce a new capability — it introduces a better way to express an existing one.</p><p>Developers have been using POST for read-only searches for years because HTTP lacked a better alternative.</p><p>QUERY finally provides that missing piece.</p><p>Whether it becomes as common as GET or POST depends on ecosystem adoption, but from an architectural perspective, it represents a meaningful improvement to HTTP.</p><p>Sometimes, the best innovations aren’t about adding new features — they’re about giving developers the right tool for a problem they’ve been solving the wrong way for years.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=091bdb0f04ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Real-Time Customer Facing Display in Laravel POS Using the Web Presentation API]]></title>
            <link>https://medium.com/@premodsuraweera1/building-a-real-time-customer-facing-display-in-laravel-pos-using-the-web-presentation-api-5cee5d25016c?source=rss-540f49a34470------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cee5d25016c</guid>
            <category><![CDATA[customer-panel]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[js]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Premodsuraweera]]></dc:creator>
            <pubDate>Mon, 18 May 2026 11:11:55 GMT</pubDate>
            <atom:updated>2026-05-18T11:14:46.851Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FQZfI6vh2qcM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DQZfI6vh2qcM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FQZfI6vh2qcM%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/06a916fcdcf3736871f0b3442ed10706/href">https://medium.com/media/06a916fcdcf3736871f0b3442ed10706/href</a></iframe><p>If you have ever developed a Point of Sale (POS) system, you already know how important a Customer Facing Display (CFD) is. Customers expect to see what is being billed in real time — products, quantities, discounts, totals, and cashier actions — while the transaction is happening.</p><p>Most developers solve this problem using WebSockets, browser extensions, Electron apps, or even custom desktop software. Those solutions work, but they also introduce additional infrastructure, server overhead, and maintenance complexity.</p><p>During a recent Laravel POS project, I wanted something different:</p><ul><li>No WebSocket servers</li><li>No internet dependency</li><li>No polling requests</li><li>No extra backend load</li><li>Fully real-time synchronization</li><li>Works directly between two browser screens</li></ul><p>The result was a lightweight architecture powered by the native JavaScript Presentation API combined with LocalStorage synchronization hooks.</p><p>This article explains the complete engineering approach behind building a real-time customer display system that runs entirely on the client side.</p><h3>The Problem We Needed to Solve</h3><p>The POS system already had a cashier interface running in the browser. The challenge was extending that interface to a second display — typically a monitor facing the customer.</p><p>The requirements were stricter than they initially sounded.</p><p>We needed:</p><h3>1. Real-Time Updates</h3><p>The customer display had to instantly reflect cart changes without refreshing the page.</p><h3>2. Zero Server Dependency</h3><p>Using Laravel broadcasting, Pusher, or Reverb would add unnecessary complexity for a feature that only operates locally inside the store network.</p><h3>3. Clean Secondary Screen</h3><p>The customer should see a polished fullscreen interface, not browser tabs, URLs, or navigation controls.</p><h3>4. Minimal Maintenance</h3><p>The solution needed to remain simple enough for long-term production support.</p><p>Most implementations over-engineer this problem. The real breakthrough came from realizing that the browser itself already provides the communication layer.</p><h3>Using the Web Presentation API</h3><p>The Web Presentation API allows a web application to present content on a secondary display, whether through HDMI, Chromecast, Miracast, or external monitors.</p><p>Instead of opening random popup windows and manually syncing them, the Presentation API creates a proper communication channel between the main POS screen and the customer display.</p><p>The first step was defining a dedicated Laravel route for the customer panel.</p><pre>let presentationConnection = null;<br>let presentationRequest = null;<br><br>const displayUrl = &quot;{{ route(&#39;sales.customerPanel&#39;) }}&quot;;<br>function initPresentation() {<br>    if (window.PresentationRequest) {<br>        presentationRequest = new PresentationRequest([displayUrl]);<br>        if (navigator.presentation &amp;&amp; navigator.presentation.defaultRequest) {<br>            navigator.presentation.defaultRequest = presentationRequest;<br>        }<br>    }<br>}</pre><p>This initializes the communication pipeline between the cashier interface and the secondary display.</p><p>The important design decision here was separation of concerns.</p><p>The customer panel is its own independent Laravel view with its own rendering logic. It does not share UI components with the cashier interface.</p><p>That separation made the system significantly easier to maintain.</p><h3>Launching the Customer Display</h3><p>When the cashier clicks the “Open Customer Panel” button, the browser prompts the user to select the connected display.</p><p>If the Presentation API is unsupported, the system gracefully falls back to a standard popup window.</p><pre>function startCustomerDisplay(e) {<br>    if (e) e.preventDefault();<br>if (window.PresentationRequest) {<br>        if (!presentationRequest) {<br>            presentationRequest = new PresentationRequest([displayUrl]);<br>        }<br>        presentationRequest.start()<br>            .then(connection =&gt; {<br>                presentationConnection = connection;<br>                console.log(<br>                    &#39;Presentation started successfully:&#39;,<br>                    connection.id<br>                );<br>                trackConnection(connection);<br>            })<br>            .catch(error =&gt; {<br>                console.error(error);<br>                if (error.name !== &#39;NotAllowedError&#39;) {<br>                    window.open(displayUrl, &#39;_blank&#39;);<br>                }<br>            });<br>    } else {<br>        window.open(displayUrl, &#39;_blank&#39;);<br>    }<br>}</pre><p>This fallback strategy matters more than most developers think.</p><p>Production systems fail when developers assume perfect browser compatibility. Real-world environments are messy. POS systems often run on outdated Windows machines with legacy browser versions.</p><p>Engineering resilient fallbacks is what separates demos from deployable software.</p><h3>Managing the Connection Lifecycle</h3><p>Once the secondary display is active, the system needs to monitor the connection state continuously.</p><p>If the customer screen disconnects, closes, or terminates unexpectedly, the POS must cleanly release the session.</p><pre>function trackConnection(connection) {<br>connection.onconnect = function() {<br>        console.log(&#39;Presentation connection active.&#39;);<br>        sendUpdateToPresentation();<br>    };<br>    connection.onclose = function() {<br>        presentationConnection = null;<br>    };<br>    connection.onterminate = function() {<br>        presentationConnection = null;<br>    };<br>}</pre><p>This prevents stale connections and avoids memory leaks inside long-running cashier sessions.</p><p>In POS environments, applications often stay open for entire business days. Small resource leaks become serious operational problems over time.</p><h3>Streaming Real-Time Cart Data</h3><p>Instead of querying the Laravel backend every time an item changes, the system directly reads the current cart state from LocalStorage.</p><p>This eliminated unnecessary AJAX requests and completely removed database synchronization overhead.</p><p>Only the customer-facing data is transmitted:</p><ul><li>Cart items</li><li>Customer name</li><li>Discounts</li><li>Warehouse details</li><li>Cashier information</li><li>Receipt metadata</li></ul><pre>function sendUpdateToPresentation() {<br>if (<br>        presentationConnection &amp;&amp;<br>        presentationConnection.state === &#39;connected&#39;<br>    ) {<br>        const keysToSync = [<br>            &#39;tbody-id&#39;,<br>            &#39;localStorageCustomerName&#39;,<br>            &#39;localStorageOrderDiscount&#39;,<br>            &#39;localStorageWarehouse_name&#39;,<br>            &#39;localStorageWarehouse_logo&#39;,<br>            &#39;localStorageWarehouse_address&#39;,<br>            &#39;localStorageWarehouse_phone&#39;,<br>            &#39;localStorageCashierName&#39;,<br>            &#39;localStorageTodayDate&#39;<br>        ];<br>        const data = {};<br>        keysToSync.forEach(key =&gt; {<br>            data[key] = localStorage.getItem(key) || &#39;&#39;;<br>        });<br>        try {<br>            presentationConnection.send(<br>                JSON.stringify({<br>                    type: &#39;update&#39;,<br>                    data: data<br>                })<br>            );<br>            console.log(&#39;Customer display synced.&#39;);<br>        } catch (err) {<br>            console.error(err);<br>        }<br>    }<br>}</pre><p>The performance improvement here was substantial.</p><p>Because the entire synchronization layer operates locally inside the browser, updates feel instantaneous even on low-powered POS hardware.</p><p>No network latency.<br> No backend bottlenecks.<br> No socket reconnection issues.</p><h3>The Real Engineering Trick: Hooking localStorage.setItem()</h3><p>This was the core architectural breakthrough.</p><p>Most developers manually call synchronization functions everywhere inside their application:</p><pre>addToCart();<br>updateCustomerScreen();</pre><p>That approach becomes fragile quickly. Eventually, one developer forgets to trigger the sync method somewhere, and the customer display falls out of sync.</p><p>Instead, I intercepted the browser’s native localStorage.setItem() method itself.</p><pre>const originalSetItem = localStorage.setItem;<br>localStorage.setItem = function(key, value) {<br>    originalSetItem.apply(this, arguments);<br>    const keysToSync = [<br>        &#39;tbody-id&#39;,<br>        &#39;localStorageCustomerName&#39;,<br>        &#39;localStorageOrderDiscount&#39;,<br>        &#39;localStorageWarehouse_name&#39;,<br>        &#39;localStorageWarehouse_logo&#39;,<br>        &#39;localStorageWarehouse_address&#39;,<br>        &#39;localStorageWarehouse_phone&#39;,<br>        &#39;localStorageCashierName&#39;,<br>        &#39;localStorageTodayDate&#39;<br>    ];<br>    if (keysToSync.includes(key)) {<br>        sendUpdateToPresentation();<br>    }<br>};</pre><p>Now every time the POS updates a tracked LocalStorage value, the customer display automatically receives the new state.</p><p>No additional code inside cart logic.<br> No duplicated synchronization handlers.<br> No event spaghetti.</p><p>This transformed synchronization into infrastructure instead of business logic.</p><p>That distinction matters.</p><p>Good architecture removes responsibility from developers whenever possible.</p><h3>Why This Architecture Works So Well</h3><p>After deploying this system, several advantages became obvious immediately.</p><h3>1. Completely Offline Capable</h3><p>The customer display continues functioning even without internet connectivity because communication happens entirely inside the browser environment.</p><p>This is critical for retail systems where internet reliability is unpredictable.</p><h3>2. No WebSocket Infrastructure</h3><p>No Redis.<br> No Laravel Echo.<br> No Pusher.<br> No Reverb.<br> No background socket server.</p><p>That removes an entire operational layer from deployment and maintenance.</p><h3>3. Extremely Fast</h3><p>Because updates are local and memory-based, synchronization feels instant.</p><p>The system performs well even on older POS machines with limited hardware resources.</p><h3>4. Fully Decoupled</h3><p>The cashier screen and customer display remain independent applications.</p><p>The cashier interface only updates LocalStorage.<br> The synchronization layer handles transmission automatically.<br> The customer screen only focuses on rendering UI.</p><p>This separation keeps the codebase cleaner and easier to scale.</p><h3>Limitations You Should Know</h3><p>The Presentation API is powerful, but it is not perfect.</p><p>There are practical considerations developers should understand before using it in production.</p><h3>Browser Support</h3><p>Presentation API support is still inconsistent across browsers.</p><p>Chromium-based browsers generally work best.</p><p>Testing across target hardware is mandatory.</p><h3>Security Restrictions</h3><p>Modern browsers impose restrictions on secondary screen access and fullscreen permissions.</p><p>User interaction is usually required before launching the presentation session.</p><h3>Multi-Terminal Scaling</h3><p>This architecture works exceptionally well for single-terminal POS systems.</p><p>However, if you need centralized multi-terminal synchronization across multiple devices or branches, you will eventually need proper backend event broadcasting.</p><p>This is not a replacement for enterprise real-time infrastructure.</p><p>It is a highly optimized local-display solution.</p><h3>Final Thoughts</h3><p>The biggest mistake developers make with POS systems is overengineering features that only operate locally.</p><p>Not every real-time problem requires WebSockets, Redis, or distributed event systems.</p><p>Sometimes the browser already provides the exact primitives you need.</p><p>By combining:</p><ul><li>The Web Presentation API</li><li>LocalStorage state management</li><li>JavaScript method interception</li></ul><p>we built a production-ready Customer Facing Display that is:</p><ul><li>Real-time</li><li>Offline-first</li><li>Serverless</li><li>Lightweight</li><li>Easy to maintain</li></ul><p>The next step is implementing a receiver listener using navigator.presentation.receiver inside the customer panel view to receive the JSON payload and render the UI dynamically.</p><p>If you are building retail software, kiosk systems, or dual-screen applications, the Presentation API is worth exploring before introducing unnecessary backend complexity.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cee5d25016c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Fixed Intermittent Blank Print Failures in a Node.js Thermal Printing Bridge]]></title>
            <link>https://medium.com/@premodsuraweera1/how-i-fixed-intermittent-blank-print-failures-in-a-node-js-thermal-printing-bridge-e5788b4c8496?source=rss-540f49a34470------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5788b4c8496</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[bugs]]></category>
            <category><![CDATA[print]]></category>
            <category><![CDATA[case-study]]></category>
            <category><![CDATA[business]]></category>
            <dc:creator><![CDATA[Premodsuraweera]]></dc:creator>
            <pubDate>Mon, 18 May 2026 04:35:16 GMT</pubDate>
            <atom:updated>2026-05-18T04:35:16.156Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rpowXp2P3YpL_IeRPh7xdw.png" /></figure><p>As a software engineer, few things are as frustrating as an intermittent production bug. You know the type: it passes local QA with flying colors, works 90% of the time in production, but randomly drops transactions during peak traffic hours.</p><p>Recently, I was tasked with stabilizing a local silent printing bridge built with <strong>Node.js</strong> and <strong>Puppeteer</strong>. The architecture was designed to receive dynamic HTML templates via an Express API, render them into PDFs using a headless browser, and spool them directly to local thermal receipt printers (POS58/POS80).</p><p>While Kitchen Order Tickets (KOT) printed flawlessly, the <strong>Cashier Receipts — which included the store logo — frequently came out completely blank or failed to print at all.</strong> Strangely, hitting “Reprint” resolved the issue immediately.</p><p>Here is a technical teardown of why this happened, how I analyzed the bottleneck, and the steps I took to build a bulletproof local printing queue.</p><h3><strong>The Anatomy of the Failures</strong></h3><p>By analyzing the application behavior and Windows Print Spooler states under simulated loads, I isolated three core architectural flaws.</p><h3>1. The Asynchronous “Fire-and-Forget” Trap</h3><p>Originally, the Express API handler was written with an un-awaited background process:</p><pre>// ❌ The Anti-Pattern<br>const printHtmlHandler = async (req, res) =&gt; {<br>    // ...<br>    printHtmlBuffer(html, printerName).then(() =&gt; {<br>        writeLog(`✅ Print success`);<br>    }).catch(err =&gt; {<br>        writeLog(`❌ Error: ${err.message}`);<br>    });<br><br>    // API immediately returns success before the browser even finishes rendering!<br>    res.send({ success: true }); <br>};</pre><p>Because the execution block was not awaited, the server responded with a 200 OK to the client client application instantly. Meanwhile, the headless browser was left running in the background to handle the rendering layer.</p><p>If the host machine’s CPU or RAM spiked, or if a second print job came in, the browser page context was overwritten or abruptly terminated before the PDF buffer could ever reach the OS spooler. The client application assumed success, but the physical document was dropped entirely.</p><h3>2. Thread Throttling via --single-process</h3><p>To optimize local resource consumption on lower-end POS hardware, the Chromium instance was configured with the --single-process flag during launch.</p><p>While this prevents multiple instances in the Windows Task Manager, it forces the entire browser execution engine, the V8 JavaScript engine, the page layout system, and the heavy PDF rasterizer into a <strong>single operating system thread</strong>. When dynamic graphic rendering tasks (like decoding a brand logo) occurred simultaneously with page serialization, the thread experienced silent micro-deadlocks, throwing unhandled Target Closed or Browser Disconnected exceptions.</p><h3>3. The page.setContent() Race Condition</h3><p>To display the restaurant logo, the frontend sent raw HTML strings containing standard image source attributes. The rendering layer loaded these using Puppeteer’s page.setContent(html).</p><p>However, page.setContent() resolves as soon as the raw HTML DOM structure is initialized. It <strong>does not wait</strong> for external assets—like local or network-hosted images—to finish downloading and decoding. The browser was triggering the PDF generation process while the logo element was still an empty container, resulting in a blank document.</p><h3>The Architectural Re-engineering</h3><p>To achieve absolute zero-drop printing stability, I completely refactored the communication flow and introduced a strict synchronization framework.</p><h3>Step 1: Sequential Concurrency with an In-Memory Queue</h3><p>Instead of allowing concurrent API requests to spawn arbitrary headless browser pages and choke host memory, I built a strict execution queue natively within Node.js.</p><p>Every incoming print request is wrapped in a Promise and appended to a central queue array. A worker loops through the jobs sequentially, ensuring that exactly <strong>one print job</strong> is processed at any given moment.</p><pre>const printQueue = [];<br>let isProcessing = false;<br><br>async function printHtmlBuffer(html, printerName, width, waitMode) {<br>    return new Promise((resolve, reject) =&gt; {<br>        // Enqueue the job along with its promise lifecycles<br>        printQueue.push({ html, printerName, width, waitMode, resolve, reject });<br>        processQueue();<br>    });<br>}<br><br>async function processQueue() {<br>    if (isProcessing || printQueue.length === 0) return;<br><br>    isProcessing = true;<br>    const currentJob = printQueue[0];<br><br>    try {<br>        // Await the entire browser and hardware spooling lifecycle completely<br>        await executePrintHtml(currentJob.html, currentJob.printerName, currentJob.width, currentJob.waitMode);<br>        currentJob.resolve();<br>    } catch (error) {<br>        currentJob.reject(error);<br>    } finally {<br>        printQueue.shift(); // Evict the processed job<br>        isProcessing = false;<br>        processQueue(); // Recurse to process the next inline job<br>    }<br>}</pre><h3>Step 2: Enforcing Asset Loading via Temporary File Navigation</h3><p>To circumvent the limitations of page.setContent(), I shifted to a file system navigation method. By writing the incoming HTML payload to a transient file in the operating system&#39;s secure temp directory, I could leverage Puppeteer&#39;s native page.goto() network lifecycles.</p><pre>// Generate an insulated unique filename in the OS temporary directory<br>const tempHtmlFileName = `temp_${Date.now()}_${Math.floor(Math.random() * 1000)}.html`;<br>const tempHtmlPath = path.join(os.tmpdir(), tempHtmlFileName);<br><br>// Persist the modified HTML safely to disk<br>fs.writeFileSync(tempHtmlPath, finalHtml, &#39;utf8&#39;);<br><br>try {<br>    // Navigate via file:// protocol to trigger strict asset fetching<br>    await page.goto(`file://${tempHtmlPath}`, { <br>        waitUntil: &#39;networkidle0&#39;, // Essential: Halts execution until network traffic is dead silent<br>        timeout: 20000 <br>    });<br>} finally {<br>    // Self-cleaning hook to guarantee no sensitive transaction data permanently leaks to disk<br>    if (fs.existsSync(tempHtmlPath)) {<br>        fs.unlinkSync(tempHtmlPath);<br>    }<br>}</pre><p>By switching to page.goto() with waitUntil: &#39;networkidle0&#39;, the browser engine is explicitly commanded to halt execution until the logo graphic is 100% downloaded, decoded, and rendered into the layout tree.</p><h3>Step 3: Removing Process Constraints</h3><p>Finally, I stripped the --single-process flag from the browser instantiation logic. This restored Chromium&#39;s default multi-process isolation architecture. The layout engine could now spin up a distinct sandbox thread for page rasterization without deadlocking the primary main process thread.</p><h3>The Production Impact</h3><p>After deploying this refactored print microservice, the stability metrics shifted immediately:</p><ul><li><strong>Print Failure Rate:</strong> Dropped from a volatile ~8% during busy meal rushes to <strong>0.0%</strong>.</li><li><strong>Resource Predictability:</strong> RAM consumption stabilized into a flat line because the in-memory queue strictly capped concurrent browser page overhead.</li><li><strong>Graphic Integrity:</strong> Cashier bills now render crisp, high-contrast company logos on every single transaction without missing frames.</li></ul><h3>Key Engineering Takeaways</h3><ol><li><strong>Beware of Fire-and-Forget on Hardware Bridges:</strong> When your software acts as an intermediary to physical hardware (like thermal printers), your API must establish a reliable synchronous feedback loop. Never declare a request “successful” until the payload safely registers in the OS system spooler.</li><li><strong>Optimize Context-Aware Lifecycles:</strong> Tools like Puppeteer are designed for complex web scraping and end-to-end testing. When using them for raw layout compilation, understand the limits of data injection methods like setContent() vs disk navigation with networkidle0.</li><li><strong>Isolate Throttling Flags:</strong> While optimization flags sound attractive on paper, forcing multi-process layout engines into single-threaded contexts introduces extreme unpredictability under production graphics processing.</li></ol><p><em>Have you encountered asynchronous hardware sync issues while building Node.js integration services? Let’s connect and discuss architectural patterns in the comments below!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5788b4c8496" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating E-commerce: Bridging the Gap Between WooCommerce and ERP Systems]]></title>
            <link>https://medium.com/@premodsuraweera1/automating-e-commerce-bridging-the-gap-between-woocommerce-and-erp-systems-c956eb476ea5?source=rss-540f49a34470------2</link>
            <guid isPermaLink="false">https://medium.com/p/c956eb476ea5</guid>
            <category><![CDATA[woocommerce]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[api-integration]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Premodsuraweera]]></dc:creator>
            <pubDate>Sun, 12 Apr 2026 06:44:19 GMT</pubDate>
            <atom:updated>2026-04-12T06:53:47.422Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s fast-paced digital economy, the biggest bottleneck for growing businesses is manual data entry. Managing sales on <strong>WooCommerce</strong> while manually updating inventory in an <strong>ERP (Enterprise Resource Planning)</strong> system is not just tedious — it’s a recipe for error.</p><p>I recently completed a project for a client where I built a seamless, real-time bridge between their WooCommerce store and a custom Laravel-based ERP. Here is a look at how I tackled the integration and the tech stack behind it.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FJmAuWPzaXgk%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJmAuWPzaXgk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FJmAuWPzaXgk%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c41733859bef95b28a86985d9301d04/href">https://medium.com/media/2c41733859bef95b28a86985d9301d04/href</a></iframe><p>The Technical Challenge</p><p>The goal was simple but critical: Whenever a customer places an order online, the ERP must generate an invoice, update stock levels, and notify the warehouse immediately — without human intervention.</p><h3>The Tech Stack:</h3><ul><li><strong>Backend Framework:</strong> Laravel (Powering the ERP logic).</li><li><strong>WooCommerce REST API:</strong> For bi-directional data flow (Product updates and stock syncing).</li><li><strong>Webhooks:</strong> To capture real-time events like order.created and product.updated.</li><li><strong>Ngrok:</strong> A vital tool during the development phase to expose my local server to a public URL, allowing WooCommerce to send Webhook payloads to my local machine for testing.</li></ul><h3>How it Works (The Workflow)</h3><h3>1. Real-Time Sync via Webhooks</h3><p>Instead of “polling” the API every few minutes (which wastes server resources), I utilized <strong>Webhooks</strong>. The moment an order is placed, WooCommerce pushes a JSON payload to my Laravel endpoint.</p><h3>2. Solving the Connectivity Gap with Ngrok</h3><p>Webhooks require a public IP or URL to function. Since I develop locally, I used <strong>Ngrok</strong> to create a secure tunnel. This allowed me to simulate the live production environment perfectly, ensuring the logic was rock-solid before deployment.</p><h3>3. Inventory Integrity</h3><p>The system ensures that stock levels are the “Source of Truth.” If an item is sold in-store (via the ERP), the system automatically triggers a REST API call to update the WooCommerce stock, preventing “overselling” online.</p><h3>Why This Matters for Businesses</h3><ul><li><strong>Zero Manual Entry:</strong> Reduces labor costs and eliminates human error.</li><li><strong>Data Accuracy:</strong> Financial reports and stock levels are always 100% accurate across both platforms.</li><li><strong>Scalability:</strong> Whether it’s 10 orders or 10,000, the automation handles the load effortlessly.</li></ul><h3>Lessons from the Field</h3><p>Building this reinforced the importance of robust error handling and logging. When dealing with financial data between two systems, you need to account for failed requests and network timeouts.</p><p>I previously shared a basic version of a WooCommerce integration on my GitHub, which served as the foundation for this more complex ERP implementation. You can see that early work here:<br> 👉 <a href="https://github.com/Premod1/woocommerce-integrate">View my previous WooCommerce Integration Project</a></p><h3>Final Thoughts</h3><p>Automation isn’t just a luxury; it’s a necessity for any business looking to scale. By leveraging <strong>Laravel</strong> and <strong>Modern APIs</strong>, we can turn fragmented tools into a unified, high-performance ecosystem.</p><p><strong>Are you looking to automate your business workflow or sync your e-commerce store with an internal system? Let’s connect and discuss how I can help you bridge the gap.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c956eb476ea5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is your POS system slowing down checkout because of print popups?]]></title>
            <link>https://medium.com/@premodsuraweera1/is-your-pos-system-slowing-down-checkout-because-of-print-popups-3e6296bb4825?source=rss-540f49a34470------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e6296bb4825</guid>
            <category><![CDATA[pos]]></category>
            <category><![CDATA[restaurant-tech]]></category>
            <category><![CDATA[retail-solutions]]></category>
            <category><![CDATA[business-automation]]></category>
            <dc:creator><![CDATA[Premodsuraweera]]></dc:creator>
            <pubDate>Wed, 11 Feb 2026 19:26:25 GMT</pubDate>
            <atom:updated>2026-02-11T19:26:25.572Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kfwACzBbEPWnExHfvYaI6Q.png" /></figure><p>There’s a better way.</p><p>With our new POS solution, you can print directly to Receipt and Kitchen printers from your web-based POS — without triggering a print confirmation popup every time.</p><p>Key Benefits</p><blockquote>Faster checkout with seamless direct printing</blockquote><blockquote>Instant kitchen order printing</blockquote><blockquote>Fully web-based interface</blockquote><blockquote>Stable and reliable performance</blockquote><blockquote>Ideal for retail and restaurant operations</blockquote><p>Designed for Supermarkets, Cafés, Restaurants, Takeaway outlets, and Multi-branch businesses.</p><p>If you’re looking to improve operational speed and eliminate unnecessary friction at the billing counter, we’d be happy to arrange a live demo tailored to your printer setup.</p><p>Let’s make your business operations faster and more efficient.</p><p><a href="https://uhb.pericorex.com/#capabilities">https://uhb.pericorex.com/#capabilities</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e6296bb4825" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Encrypt Your Laravel Source Code Using phpBolt]]></title>
            <link>https://medium.com/@premodsuraweera1/how-to-encrypt-your-laravel-source-code-using-phpbolt-eeda104a9177?source=rss-540f49a34470------2</link>
            <guid isPermaLink="false">https://medium.com/p/eeda104a9177</guid>
            <category><![CDATA[sass]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Premodsuraweera]]></dc:creator>
            <pubDate>Tue, 03 Feb 2026 17:46:16 GMT</pubDate>
            <atom:updated>2026-02-03T17:46:16.438Z</atom:updated>
            <content:encoded><![CDATA[<p>Protecting your intellectual property is a major concern when distributing Laravel applications to client servers. While PHP is an interpreted language, you can still protect your logic by encrypting your source code.</p><p>In this guide, we will use <strong>phpBolt</strong> and the <strong>Laravel Source Encrypter</strong> package to secure your application.</p><h3>Prerequisites</h3><ul><li>A Laravel application (Version 8.x, 9.x, 10.x, or 11.x).</li><li>Access to the server where the code will run.</li><li>PHP 8.2 (or your specific version) installed.</li></ul><h3>Step 1: Install the phpBolt Extension</h3><p>Before your server can read encrypted files, it needs the phpBolt “decoder.”</p><ol><li><strong>Download:</strong> Go to <a href="https://phpbolt.com/download-phpbolt/">phpBolt.com</a> and download the extension that matches your PHP version and OS.</li><li><strong>Locate Extension Dir:</strong> Find where your PHP extensions live by running:</li><li>Bash</li></ol><p>php -i | grep extension_dir</p><ol><li><strong>Copy the File:</strong> Move the downloaded bolt.so (Linux) or bolt.dll (Windows) into that directory.</li><li><strong>Enable it:</strong> Create a configuration file (e.g., /etc/php/8.2/cli/conf.d/20-bolt.ini) and add:</li><li>Ini, TOML</li></ol><ul><li>extension=bolt.so</li></ul><ol><li><strong>Verify:</strong> Run php -m | grep bolt. If you see &quot;bolt,&quot; the decoder is active.</li></ol><h3>Step 2: Install Laravel Source Encrypter</h3><p>To automate the encryption of your Laravel files, we use a dedicated wrapper for phpBolt.</p><ol><li><strong>Install via Composer:</strong> Open your terminal in your project root and run:</li></ol><ul><li>composer require siavashbamshadnia/laravel-source-encrypter</li></ul><ol><li><strong>Publish Configuration (Optional):</strong> If you want to customize which folders are encrypted, publish the config:</li><li>Bash</li></ol><pre>php artisan vendor:publish --provider=&quot;SiavashBamshadnia\LaravelSourceEncrypter\SourceEncrypterServiceProvider&quot;</pre><h3>Step 3: Encrypting Your Code</h3><p>The package provides a simple artisan command to handle the heavy lifting.</p><p><strong>To encrypt your source code:</strong></p><p>Bash</p><pre>php artisan encrypt-source</pre><h3>What happens next?</h3><ul><li>The command will look through your directories (defined in the config).</li><li>It uses the phpBolt algorithm to scramble the PHP logic.</li><li>Your original readable code is replaced with encrypted strings that only a server with the bolt.so extension can interpret.</li></ul><p><strong>Pro Tip:</strong> Always run this on a <strong>copy</strong> of your project or as part of your deployment pipeline. Never encrypt your local development source code without a backup!</p><h3>Step 4: Deployment and Running</h3><p>Once encrypted, your files will look like a jumble of random characters. To run the app:</p><ul><li><strong>Upload</strong> the encrypted files to your production server.</li><li>Ensure the <strong>phpBolt extension</strong> is installed on the production server (see Step 1).</li><li>Restart your web service (php-fpm or apache).</li><li>Your Laravel app will now run normally, but the logic remains hidden from anyone browsing the files on the server.</li></ul><h3>Conclusion</h3><p>By combining the power of <strong>phpBolt</strong> with the <strong>Laravel Source Encrypter</strong> package, you can confidently distribute your SaaS or enterprise software while keeping your source code private.</p><p><strong>Resources:</strong></p><ul><li><a href="https://phpbolt.com/">phpBolt Official Site</a></li><li><a href="https://github.com/SiavashBamshadnia/Laravel-Source-Encrypter">Laravel Source Encrypter on GitHub</a></li><li><a href="https://packagist.org/packages/phpbolt/encrypt">Packagist Listing</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eeda104a9177" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>