<?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 Ali Haider on Medium]]></title>
        <description><![CDATA[Stories by Ali Haider on Medium]]></description>
        <link>https://medium.com/@ali.haider8014?source=rss-1f750eed85d0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*smPNwt8HUzPZ08cAXeFozw.jpeg</url>
            <title>Stories by Ali Haider on Medium</title>
            <link>https://medium.com/@ali.haider8014?source=rss-1f750eed85d0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 10:21:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ali.haider8014/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[Audit Logs vs System Logs: The Architecture That Built Trust in Our Healthcare App]]></title>
            <link>https://medium.com/@ali.haider8014/audit-logs-vs-system-logs-the-architecture-that-built-trust-in-our-healthcare-app-a12d1055bc35?source=rss-1f750eed85d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/a12d1055bc35</guid>
            <category><![CDATA[audit-logs]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[logs]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[healthcare]]></category>
            <dc:creator><![CDATA[Ali Haider]]></dc:creator>
            <pubDate>Thu, 30 Jul 2026 15:31:34 GMT</pubDate>
            <atom:updated>2026-07-30T15:31:34.632Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How a well-designed logging architecture improves debugging, accountability, and patient safety.</em></p><blockquote><em>“Users rarely notice a good logging system. But when something goes wrong, it becomes one of the most valuable parts of the entire application.”</em></blockquote><p>When developers think about healthcare software, the first things that usually come to mind are electronic health records (EHRs), appointment scheduling, prescriptions, billing, or patient portals. Those are certainly important, but after spending years working on healthcare systems, I’ve come to appreciate another component that quietly works behind the scenes every single day: <strong>logging</strong>.</p><p>Logging isn’t a flashy feature. Patients don’t see it. Providers rarely think about it. Yet without it, diagnosing production issues, tracing user activity, and understanding what happened during a critical operation would be incredibly difficult.</p><p>In healthcare, data is more than just information stored in a database. Every patient record, medication update, appointment change, or clinical note may directly influence patient care. Because of that, every important action deserves to be traceable.</p><p>That’s where <strong>Audit Logs</strong> and <strong>System Logs</strong> become essential.</p><p>In this article, I’ll share how we approached logging in a healthcare application, why we separated audit logs from system logs, and some lessons I learned while building and maintaining this architecture.</p><figure><img alt="A scalable logging architecture that separates audit trails from system logs builds trust in healthcare software." src="https://cdn-images-1.medium.com/max/1024/1*-WzVqfhEPGgelaxuj_DyMw.jpeg" /></figure><h3>Why Healthcare Needs Audit Logs</h3><p>Healthcare applications manage some of the most sensitive data in the world.</p><p>Consider a few everyday operations:</p><ul><li>A nurse updates a patient’s allergy information.</li><li>A physician modifies a diagnosis.</li><li>An administrator changes insurance details.</li><li>A receptionist reschedules an appointment.</li><li>A provider signs a clinical encounter.</li></ul><p>Each of these actions changes important business data.</p><p>Now imagine someone asks:</p><blockquote><em>“Who changed this information yesterday?”</em></blockquote><p>Without audit logs, the investigation becomes difficult.</p><p>With proper audit logging, the answer is usually available within seconds.</p><p>A good audit log should answer questions like:</p><ul><li>Who performed the action?</li><li>What was changed?</li><li>When did it happen?</li><li>Which patient or record was affected?</li><li>What were the old values?</li><li>What are the new values?</li></ul><p>These questions aren’t only useful during production incidents — they also improve accountability, transparency, and trust within the system.</p><h3>Audit Logs vs. System Logs</h3><pre>                      Enterprise Application<br>                              │<br>          ┌───────────────────┴───────────────────┐<br>          ▼                                       ▼<br>     System Logs                           Audit Logs<br><br>  Technical Events                     Business Events<br><br>  • Request Path                       • Record Created<br>  • Response Status                    • Record Updated<br>  • Execution Time                     • Record Deleted<br>  • Exceptions                         • User Activity<br>  • Infrastructure                     • Business Changes<br><br>          └───────────────────┬───────────────────┘<br>                              ▼<br>                 Search &amp; Analytics Platform</pre><p>One pattern I keep seeing is treating audit logs and system logs as the same thing. Although both record events, they serve completely different purposes.</p><h3>Audit Logs</h3><p>Audit logs capture <strong>business events</strong>.</p><p>Examples include:</p><ul><li>Patient created</li><li>Appointment updated</li><li>Medication deleted</li><li>Insurance modified</li><li>Clinical note signed</li><li>Provider assigned</li></ul><p>These events describe <strong>what happened from a business perspective</strong>.</p><h3>System Logs</h3><p>System logs focus on the application’s technical behavior.</p><p>Examples include:</p><ul><li>Incoming API request</li><li>Request parameters</li><li>Controller and action</li><li>Authentication</li><li>Response status</li><li>Exception details</li><li>Execution time</li><li>Background job execution</li></ul><p>System logs help developers answer questions like:</p><ul><li>Why did this API fail?</li><li>Why did the request take 8 seconds?</li><li>Which endpoint produced the error?</li></ul><p>Think of it this way:</p><blockquote><strong><em>Audit logs tell the story of the business.</em></strong></blockquote><blockquote><strong><em>System logs tell the story of the application.</em></strong></blockquote><p>Both are important.</p><h3>Designing a Scalable Logging Architecture</h3><pre>                     Client Application<br>                            │<br>                            ▼<br>                  HTTP Request Received<br>                            │<br>                            ▼<br>               Request Processing Layer<br>        (Middleware / Filter / Interceptor)<br>                            │<br>          ┌─────────────────┴─────────────────┐<br>          ▼                                   ▼<br>   System Logging                     Business Logic<br>          │                                   │<br>          ▼                                   ▼<br> Capture Technical Data              Audit Event Dispatcher<br>          │                                   │<br>          ▼                     ┌─────────────┼─────────────┐<br>                                ▼             ▼             ▼<br>                         Domain A      Domain B      Domain C<br>                                │             │             │<br>                                └─────────────┼─────────────┘<br>                                              ▼<br>                                Search &amp; Analytics Platform</pre><p>Instead of allowing every controller to create logs independently, we decided to centralize the logging process.</p><p>Whenever a request enters the application, it first reaches a common entry point.</p><p>From there, two different logging processes begin.</p><p>Separating these responsibilities keeps the application cleaner while making both logging systems easier to maintain.</p><h3>Request Flow</h3><p>Every HTTP request entering the application already contains valuable information before any business logic executes.</p><p>Some examples include:</p><ul><li>Request URL</li><li>HTTP Method</li><li>User ID</li><li>Practice ID</li><li>IP Address</li><li>Controller</li><li>Action</li><li>Request Parameters</li><li>Timestamp</li></ul><p>Instead of waiting until the request finishes, we prepare the system log data at the application’s entry point.</p><p>For example, a request may look like this:</p><pre>PUT /api/v1/resource<br><br>User ID<br><br>Organization ID<br><br>Endpoint<br><br>Timestamp<br><br>Client IP</pre><p>Capturing this information early ensures that even if an exception occurs later, we still have enough context to investigate the issue.</p><h3>Audit Flow</h3><p>Unlike system logs, not every request should generate an audit log.</p><p>For example:</p><ul><li>Viewing a dashboard usually doesn’t require an audit log.</li><li>Updating patient demographics does.</li></ul><p>To solve this, One approach is a centralized <strong>Audit Handler</strong>.</p><p>Instead of writing audit logic inside every controller, each request first passes through this handler.</p><p>The handler identifies which business operation is being performed and delegates the work to the appropriate audit component.</p><p>A simplified flow looks like this:</p><pre>Business Action</pre><pre>│</pre><pre>▼</pre><pre>Audit Dispatcher</pre><pre>│</pre><pre>Determine Business Domain</pre><pre>│</pre><pre>┌──────┼────────┐</pre><pre>▼      ▼        ▼</pre><pre>Module A Module B Module C</pre><pre>│</pre><pre>▼</pre><pre>Compare Previous State</pre><pre>│</pre><pre>▼</pre><pre>Generate Audit Event</pre><pre>│</pre><pre>▼</pre><pre>Store Event</pre><p>Each component understands its own domain.</p><p>For example, a Patient Audit component knows how to process:</p><ul><li>Create Patient</li><li>Update Patient</li><li>Delete Patient</li><li>Restore Patient</li></ul><p>An Appointment Audit component understands appointment-specific events.</p><p>This modular approach keeps the codebase easier to extend as the application grows.</p><h3>System Log Flow</h3><p>System logging follows a different philosophy.</p><p>Every request generates a system log regardless of whether it changes business data.</p><p>The log typically contains:</p><ul><li>Controller</li><li>Action</li><li>User</li><li>Practice</li><li>Request parameters</li><li>IP Address</li><li>Response status</li><li>Response time</li><li>Exception details (if any)</li></ul><p>The flow looks like this:</p><pre>Incoming Request<br>↓</pre><pre>Prepare Request Metadata</pre><pre>↓</pre><pre>Execute Business Logic</pre><pre>↓</pre><pre>Capture Response</pre><pre>↓</pre><pre>Store System Log</pre><p>Having this information available dramatically reduces debugging time.</p><p>Rather than reproducing issues manually, developers can inspect the logs and understand exactly what happened.</p><h3>Choosing a Search Platform</h3><p>Traditional relational databases work well for transactional data, but they aren’t always the best choice for searching millions of log entries.</p><p>As the application grows, log volume increases quickly.</p><p>Searching by:</p><ul><li>User</li><li>Patient</li><li>Controller</li><li>Date</li><li>Practice</li><li>Action</li></ul><p>needs to remain fast.</p><p>That’s where Elasticsearch becomes valuable.</p><p>Instead of storing logs alongside business data, they are indexed separately.</p><p>This provides:</p><ul><li>Full-text search</li><li>Fast filtering</li><li>Near real-time indexing</li><li>Scalable storage</li><li>Powerful aggregations</li></ul><p>Searching through thousands — or even millions — of logs becomes much more efficient than relying solely on SQL queries.</p><h3>Benefits</h3><p>Organizations that adopt this architecture often observe several practical benefits.</p><h3>Faster Debugging</h3><p>Instead of asking multiple team members what happened, we could simply inspect the logs.</p><p>Most production investigations became significantly faster.</p><h3>Better Accountability</h3><p>Every important business action became traceable.</p><p>Developers, support teams, and administrators could quickly understand who performed an action and when.</p><h3>Easier Production Support</h3><p>Support engineers no longer needed to reproduce every issue.</p><p>The logs often contained enough information to identify the root cause immediately.</p><h3>Improved Monitoring</h3><p>System logs provided visibility into API failures, background jobs, and integration issues before users even reported them.</p><h3>Performance Considerations</h3><p>Logging is important, but excessive logging can create new problems.</p><p>One lesson we learned is that not everything deserves to be logged.</p><p>A few principles helped keep the system efficient:</p><ul><li>Log meaningful business events.</li><li>Avoid storing unnecessary sensitive information.</li><li>Keep log payloads concise.</li><li>Separate audit logs from system logs.</li><li>Index frequently searched fields.</li><li>Archive or rotate older logs when appropriate.</li></ul><p>A well-designed logging strategy should improve observability without negatively affecting application performance.</p><h3>Best Practices</h3><p>If you’re designing a logging system for healthcare applications, here are a few practices I recommend:</p><h3>Common Logging Mistakes</h3><p>Just five bullets.</p><ul><li>Mixing audit logs with system logs</li><li>Logging sensitive information</li><li>Logging everything</li><li>Not defining retention policies</li><li>Making logs impossible to search</li></ul><h3>Separate audit logs from system logs.</h3><p>They solve different problems and should evolve independently.</p><h3>Centralize logging.</h3><p>Avoid scattering logging logic throughout controllers and services.</p><h3>Record context.</h3><p>Include useful metadata such as:</p><ul><li>User ID</li><li>Practice ID</li><li>Timestamp</li><li>IP Address</li><li>Request ID</li></ul><p>Context makes troubleshooting much easier.</p><h3>Protect sensitive information.</h3><p>Not every piece of patient data belongs in a log.</p><p>Avoid recording passwords, authentication tokens, or unnecessary protected health information.</p><h3>Keep logs searchable.</h3><p>A log is only useful if you can find the information quickly.</p><p>Design your indexes with common search patterns in mind.</p><h3>Lessons Learned</h3><p>Looking back, one lesson stands out.</p><p>Logging should never be treated as something you add after finishing a feature.</p><p>It should be considered part of the application’s architecture from the beginning.</p><p>After we introduced the centralized audit dispatcher, average time to answer ‘who changed this’ dropped from hours to under a minute</p><p>Good logging doesn’t only help developers.</p><p>It helps support engineers investigate issues.</p><p>It helps administrators understand user activity.</p><p>It helps healthcare organizations maintain confidence in their systems.</p><p>And ultimately, it contributes to safer and more reliable software.</p><p>As AI continues to evolve, logs become more than historical records. Large Language Models can summarize incidents, identify unusual patterns, explain failures in natural language, and even assist engineers during production investigations. I believe this is one of the most exciting directions for modern observability in healthcare systems.</p><p>That feels like the next evolution of observability in healthcare systems.</p><h3>Conclusion</h3><p>Healthcare software is built on trust.</p><p>Patients trust providers.</p><p>Providers trust the software they use every day.</p><p>Developers have a responsibility to build systems that deserve that trust.</p><p>Audit logs and system logs may never appear in product demos, but they quietly protect data integrity, simplify troubleshooting, improve accountability, and support reliable operations every single day.</p><p>The next time you build a healthcare application, don’t think of logging as a feature to add later.</p><p>Treat it as a core part of the system’s design.</p><p>Because in healthcare, understanding <strong>what happened</strong>, <strong>when it happened</strong>, and <strong>why it happened</strong> can be just as important as the feature itself.</p><h3>About the Author</h3><p>Hi, I’m Ali Haider, a Software Engineer with a passion for backend architecture, healthcare technology, AI, and scalable SaaS platforms. I enjoy solving complex engineering problems and sharing practical lessons learned from building real-world systems. I’m currently exploring how AI can improve healthcare workflows, observability, and software reliability</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a12d1055bc35" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Was Tired of “true”/“false” Strings Breaking My Laravel API Validation — So I Built a Fix]]></title>
            <link>https://medium.com/@ali.haider8014/why-laravel-needs-flexible-boolean-validation-0ea8838dd660?source=rss-1f750eed85d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ea8838dd660</guid>
            <category><![CDATA[package]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[validation]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Ali Haider]]></dc:creator>
            <pubDate>Tue, 31 Mar 2026 19:24:27 GMT</pubDate>
            <atom:updated>2026-04-01T10:09:25.305Z</atom:updated>
            <content:encoded><![CDATA[<h4>A small but incredibly annoying Laravel gotcha that costs developers hours. Here’s how I solved it once and for all.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gkwao8dJpSzqyBnlnnihww.jpeg" /></figure><p>I’ll be honest — this tiny issue frustrated me way more than it had any right to.</p><p>I was building yet another Laravel API for a React frontend when validation started failing randomly. The culprit? Simple boolean fields.</p><p>Laravel’s built-in boolean validation rule is strict (and honestly, I usually love that strictness). But it doesn’t accept the string values “true” and “false” that modern frontends love to send — especially from JavaScript, query parameters, or third-party integrations.</p><p>Instead of clean validation, I kept getting 422 errors and had to scatter manual casting or custom rules across controllers. It felt like patching the same leak over and over again.</p><p>After the third or fourth project, I finally said “enough” and decided to solve it properly.</p><h3>The Real-World Pain</h3><p>In real APIs, boolean values rarely arrive as clean PHP booleans. You’ll commonly receive:</p><ul><li>“true” / “false” (from JSON or form data)</li><li>1 / 0</li><li>Actual true / false</li></ul><p>Laravel accepts 1, 0, “1”, and “0” — but not the literal strings “true” and “false”. That mismatch creates unnecessary friction in every API you build.</p><h3>The Solution I Built</h3><p>I created a lightweight Laravel package called <strong>flexible-boolean</strong> that extends the default boolean validation to handle real-world API data cleanly.</p><p>It supports all these formats without breaking Laravel’s validation flow or security:</p><ul><li>“true” / “false” strings</li><li>1 / 0</li><li>Actual true / false</li></ul><h3>How to Use It</h3><p>After installing the package, you can use it just like Laravel’s native rule:</p><p>PHP</p><pre>use AliHaider\FlexibleBoolean\FlexibleBooleanRule;</pre><pre>// In your Form Request or controller<br>$request-&gt;validate([<br>    &#39;is_active&#39; =&gt; [&#39;required&#39;, new FlexibleBooleanRule()],<br>    &#39;is_featured&#39; =&gt; &#39;boolean|flexible&#39;, // if you prefer the string rule<br>]);</pre><p>Or register it globally for even smoother usage.</p><p>The package stays lightweight, respects all existing Laravel behaviors, and adds zero overhead in production.</p><h3>Why This Matters</h3><p>It’s a small change, but it removes a surprising amount of friction when building modern APIs. No more manual filter_var() hacks, no more custom rules duplicated across projects, and fewer mysterious validation failures at 2 AM.</p><p>If you’ve ever fought with boolean values coming from the frontend, you know exactly how annoying this is.</p><h3>What Do You Think?</h3><p>How do you usually handle boolean values in your Laravel APIs?</p><ul><li>Do you cast everything manually in the controller?</li><li>Write custom validation rules every time?</li><li>Use a different package or trick?</li></ul><p>I’d genuinely love to hear your approach in the comments.</p><p>You can check out the package here: <a href="https://packagist.org/packages/alihaider/flexible-boolean">https://packagist.org/packages/alihaider/flexible-boolean</a></p><p>If this helped you, feel free to clap/share so other Laravel developers can discover it too.</p><p>#Laravel #PHP #APIDevelopment #BackendDevelopment</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0ea8838dd660" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ElasticFrom Custom Log Scripts to Scalable Logging: Implementing Elasticsearch with Filebeat &…]]></title>
            <link>https://medium.com/@ali.haider8014/elasticfrom-custom-log-scripts-to-scalable-logging-implementing-elasticsearch-with-filebeat-42d634f9bef2?source=rss-1f750eed85d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/42d634f9bef2</guid>
            <category><![CDATA[filebeat]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[logs]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Ali Haider]]></dc:creator>
            <pubDate>Thu, 12 Feb 2026 19:11:35 GMT</pubDate>
            <atom:updated>2026-02-12T19:11:35.586Z</atom:updated>
            <content:encoded><![CDATA[<h3>ElasticFrom Custom Log Scripts to Scalable Logging: Implementing Elasticsearch with Filebeat &amp; Keystore</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gW0dAZQfnEQq-thQghfP0w.png" /></figure><p>This article explains how we migrated from a custom log-pushing script to a scalable logging solution using Filebeat and Elasticsearch. It highlights the challenges we faced with memory usage, reliability, and security, and how Filebeat with Keystore solved them efficiently. A practical step-by-step implementation guide is included.</p><p>Logging is easy — until it isn’t.</p><p>At first, we built a simple command-line script that:</p><ol><li>Read log files</li><li>Parsed data</li><li>Pushed logs to Elasticsearch</li></ol><p>It worked… until production traffic increased.</p><p>That’s when the real problems started.</p><h3>🚨 The Problem with Custom Log Scripts</h3><p>Our old approach looked something like this:</p><pre>php read_logs.php</pre><p>Inside the script:</p><ul><li>Read file using file_get_contents()</li><li>Parse JSON</li><li>Send via CURL to Elasticsearch</li></ul><p>It had multiple issues:</p><h3>❌ 1. High Memory Usage</h3><p>Large files were loaded entirely into memory.</p><h3>❌ 2. No Real-Time Streaming</h3><p>We had to run cron jobs repeatedly.</p><h3>❌ 3. Failure Handling Was Weak</h3><p>If Elasticsearch was down → logs were lost.</p><h3>❌ 4. Security Risk</h3><p>Credentials were stored directly in the script:</p><pre>$auth = &quot;elastic:password123&quot;;</pre><p>That’s dangerous in production.</p><p>We needed something:</p><ul><li>Lightweight</li><li>Real-time</li><li>Secure</li><li>Production-ready</li></ul><p>That’s when we moved to <strong>Filebeat</strong>.</p><h3>🚀 What is Filebeat?</h3><p>Filebeat is a lightweight log shipper from Elastic Stack.</p><p>It:</p><ul><li>Watches log files</li><li>Detects new lines</li><li>Sends them to Elasticsearch</li><li>Handles retries automatically</li><li>Keeps track of file offsets</li></ul><p>Basically, it does everything our custom script was trying to do — but better.</p><h3>🛠 Step-by-Step: Implementing Filebeat</h3><h3>1️⃣ Install Filebeat</h3><p>On Ubuntu:</p><pre>sudo apt update<br>sudo apt install filebeat</pre><p>Check version:</p><pre>filebeat version</pre><h3>2️⃣ Configure Filebeat</h3><p>Edit:</p><pre>/etc/filebeat/filebeat.yml</pre><h3>Example Configuration:</h3><pre>filebeat.inputs:<br>  - type: log<br>    enabled: true<br>    paths:<br>      - /var/log/application/*.log</pre><pre>output.elasticsearch:<br>  hosts: [&quot;https://localhost:9200&quot;]<br>  username: &quot;elastic&quot;<br>  password: &quot;your_password&quot;</pre><p>Now Filebeat watches logs in real-time.</p><h3>🔐 Problem: Hardcoding Credentials (Bad Practice)</h3><p>Storing passwords inside filebeat.yml is risky.</p><p>Instead, use <strong>Filebeat Keystore</strong>.</p><h3>🔐 What is Filebeat Keystore?</h3><p>It securely stores secrets (like passwords, API keys).</p><p>No plain-text credentials inside config files.</p><h3>🛠 How to Implement Filebeat Keystore</h3><h3>1️⃣ Create Keystore</h3><pre>sudo filebeat keystore create</pre><h3>2️⃣ Add Elasticsearch Password</h3><pre>sudo filebeat keystore add ES_PASSWORD</pre><p>It will prompt for password securely.</p><h3>3️⃣ Update filebeat.yml</h3><p>Instead of:</p><pre>password: &quot;your_password&quot;</pre><p>Use:</p><pre>password: &quot;${ES_PASSWORD}&quot;</pre><p>Now password is securely loaded from keystore.</p><h3>4️⃣ Test Configuration</h3><pre>sudo filebeat test config</pre><h3>5️⃣ Start Filebeat</h3><pre>sudo systemctl start filebeat</pre><p>Enable on boot:</p><pre>sudo systemctl enable filebeat</pre><h3>🧠 What Problems Did This Solve?</h3><p>Before:</p><ul><li>Manual Script</li><li>Memory-Heavy</li><li>Cron Dependency</li><li>Credentials Exposed</li><li>No Retry Handling</li></ul><p>After:</p><ul><li>Automatic Log Steaming</li><li>Lightweight Agent</li><li>Real-Time Monitoring</li><li>Secure Keystore</li><li>Built-in Retry &amp; Buffering</li></ul><h3>🎯 Architecture Overview</h3><p>Application → Log File → Filebeat → Elasticsearch → Kibana</p><p>Simple. Scalable. Secure.</p><h3>⚡ Bonus: Why Filebeat is Better Than Custom Scripts</h3><ul><li>Uses minimal CPU</li><li>Handles file rotation</li><li>Tracks file offset</li><li>Supports multiline logs</li><li>Built-in backpressure handling</li><li>Production tested</li></ul><p>Your custom script would eventually re-implement half of Filebeat badly.</p><h3>🏁 Final Thoughts</h3><p>Moving from a custom log-push command to Filebeat was a major upgrade.</p><p>It improved:</p><p>✔ Reliability<br>✔ Security<br>✔ Scalability<br>✔ Maintainability</p><p>Sometimes the best engineering decision is not writing more code — <br>it’s using the right tool.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42d634f9bef2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Common PHP Mistakes That Fail Interviews (And How to Avoid Them)]]></title>
            <link>https://medium.com/@ali.haider8014/common-php-mistakes-that-fail-interviews-and-how-to-avoid-them-425f4ddce0ef?source=rss-1f750eed85d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/425f4ddce0ef</guid>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[sql-injection]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Ali Haider]]></dc:creator>
            <pubDate>Wed, 11 Feb 2026 17:36:59 GMT</pubDate>
            <atom:updated>2026-02-11T17:36:59.741Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bwJjsUBjZ2n72INFhV2QhA.png" /></figure><p>Many developers don’t fail interviews because they don’t know PHP — they fail because they use PHP <strong>the wrong way</strong>.</p><p>Interviewers look for <strong>clean thinking, safe coding, and strong fundamentals</strong>. These mistakes are instant red flags.</p><h3>❌ 1. Using == Instead of ===</h3><p>Loose comparison can break logic.</p><pre>var_dump(0 == &quot;abc&quot;);   // true ❌<br>var_dump(0 === &quot;abc&quot;);  // false ✅</pre><p><strong>Why this fails interviews:</strong><br>You show you don’t understand <strong>type juggling</strong>, which causes real production bugs.</p><p>👉 <strong>Rule:</strong> Always use === unless you have a strong reason not to.</p><h3>❌ 2. Not Validating Input</h3><pre>$email = $_POST[&#39;email&#39;];</pre><p>No validation? That’s unsafe.</p><pre>$email = filter_input(INPUT_POST, &#39;email&#39;, FILTER_VALIDATE_EMAIL);</pre><p><strong>Why this fails:</strong><br>Interviewers think: <em>“This person will cause security issues.”</em></p><h3>❌ 3. Writing SQL Without Prepared Statements</h3><pre>$query = &quot;SELECT * FROM users WHERE id = &quot; . $_GET[&#39;id&#39;]; // ❌ SQL Injection risk</pre><p>Correct way:</p><pre>$stmt = $pdo-&gt;prepare(&quot;SELECT * FROM users WHERE id = ?&quot;);<br>$stmt-&gt;execute([$_GET[&#39;id&#39;]]);</pre><p><strong>Fail reason:</strong> You didn’t think about <strong>security</strong>.</p><h3>❌ 4. Ignoring Error Handling</h3><pre>$data = file_get_contents(&quot;file.txt&quot;); // what if file doesn&#39;t exist?</pre><p>Better:</p><pre>if (!file_exists(&quot;file.txt&quot;)) {<br>    throw new Exception(&quot;File missing&quot;);<br>}</pre><p>Interviewers want devs who <strong>expect failure cases</strong>.</p><h3>❌ 5. Misusing empty() and isset()</h3><pre>$value = &quot;0&quot;;<br>empty($value); // true ❌</pre><p><strong>Fail reason:</strong> You don’t know how PHP treats &quot;0&quot;.</p><p>👉 Use isset() when checking existence<br>👉 Use strict checks for values</p><h3>❌ 6. Writing Everything in One Function</h3><pre>function processOrder() {<br>    // 200 lines of logic 😵<br>}</pre><p><strong>Fail reason:</strong> No understanding of <strong>separation of concerns</strong>.</p><h3>❌ 7. Not Using Built-in Functions</h3><p>Writing loops for things PHP already solves:</p><pre>// ❌ long code<br>foreach ($arr as $v) {<br>   if ($v == $search) return true;<br>}</pre><p>Instead:</p><pre>in_array($search, $arr); // ✅</pre><p><strong>Fail reason:</strong> Inefficient thinking.</p><h3>❌ 8. Ignoring Edge Cases</h3><p>Question: Reverse a string<br> Candidate answer:</p><pre>strrev($str);</pre><p>But what about:</p><ul><li>empty string?</li><li>null?</li><li>multibyte characters?</li></ul><p>Interviewers want <strong>thinking</strong>, not shortcuts only.</p><h3>❌ 9. Poor Naming</h3><pre>$a = getData($b);</pre><p>Better:</p><pre>$userOrders = getOrdersByUser($userId);</pre><p>Bad naming = bad readability = fail.</p><h3>❌ 10. Not Understanding Time Complexity</h3><pre>foreach ($users as $u) {<br>   foreach ($orders as $o) {<br>      // nested loop ❌<br>   }<br>}</pre><p>Better approach: index by key.</p><p>Interviewers LOVE candidates who mention <strong>O(n)</strong>.</p><h3>❌ 11. No Knowledge of OOP Basics</h3><p>If you can’t explain:</p><ul><li>Class</li><li>Object</li><li>Interface vs Abstract</li><li>Inheritance</li><li>Dependency Injection</li></ul><p>You’ll struggle in backend interviews.</p><h3>❌ 12. Not Explaining Your Thought Process</h3><p>Silence = fail.</p><p>Interviewers prefer:</p><blockquote><em>“First I validate input, then I optimize query, then handle edge cases.”</em></blockquote><h3>🎯 What Interviewers Actually Want</h3><p>They look for developers who:</p><p>✔ Think about security<br>✔ Handle edge cases<br>✔ Write readable code<br>✔ Use built-in functions<br>✔ Understand performance<br>✔ Explain their logic</p><h3>🚀 Golden Rule</h3><blockquote><strong><em>Bad PHP devs write code that works.<br>Good PHP devs write code that works safely, efficiently, and cleanly.</em></strong></blockquote><p>Avoid these mistakes, and you instantly move from <strong>average candidate → strong candidate</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=425f4ddce0ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Deploying a Three-Tier Web Application on AWS]]></title>
            <link>https://medium.com/@ali.haider8014/deploying-a-three-tier-web-application-on-aws-2c8ddbffacd7?source=rss-1f750eed85d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c8ddbffacd7</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[3-tier-architecture]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Ali Haider]]></dc:creator>
            <pubDate>Sun, 19 Oct 2025 11:31:09 GMT</pubDate>
            <atom:updated>2025-10-19T11:31:09.399Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>A Complete Guide from VPC to CloudFront</strong></p><h3>🌐 Introduction</h3><p>Building a modern web application isn’t just about writing code — it’s about <strong>designing a secure, scalable, and reliable infrastructure</strong>.</p><p>In this article, we’ll walk through how to deploy a <strong>three-tier web application</strong> on <strong>Amazon Web Services (AWS)</strong>.<br>This architecture separates the <strong>frontend</strong>, <strong>backend</strong>, and <strong>database</strong> layers — improving scalability, security, and maintainability.</p><p>By the end of this guide, you’ll understand how each AWS service fits together to form a <strong>production-ready cloud environment</strong>.</p><h3>🧭 Architecture Overview</h3><p>Here’s the big picture of what we’ll build:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o4EwNuS1sRHW6OGt3ZL7hg.png" /><figcaption>3-tier application on AWS</figcaption></figure><h3>🧱 Step 1 — Create the Network Foundation (VPC &amp; Subnets)</h3><p>Start by creating a <strong>VPC</strong> (Virtual Private Cloud), which acts as your application’s private network within AWS.</p><ul><li><strong>VPC CIDR:</strong> 10.0.0.0/16</li><li><strong>Public Subnet:</strong> 10.0.1.0/24</li><li><strong>Private Subnet:</strong> 10.0.2.0/24</li></ul><p>Then configure:</p><ul><li><strong>Internet Gateway (IGW)</strong> → provides internet access for public subnet</li><li><strong>NAT Gateway</strong> → allows private instances to access the internet securely</li><li><strong>Route Tables</strong>:</li><li>Public route → 0.0.0.0/0 → IGW</li><li>Private route → 0.0.0.0/0 → NAT Gateway</li></ul><h3>🧩 1.1 Virtual Private Cloud (VPC)</h3><p><strong>What:</strong> We created a custom VPC to isolate our infrastructure logically within AWS.<br> <strong>Why:</strong> It allows us to control networking, security, and communication between our application tiers.</p><h3>🌐 1.2 Subnets (Public &amp; Private)</h3><p><strong>What:</strong> Two subnets were created — a public subnet for the bastion host and a private subnet for the application and database.<br> <strong>Why:</strong> Separating public and private components ensures better security and controlled access.</p><h3>🚪 1.3 Internet Gateway &amp; NAT Gateway</h3><p><strong>What:</strong> The Internet Gateway allows outbound/inbound traffic to public resources, while the NAT Gateway lets private instances reach the internet securely.<br> <strong>Why:</strong> This ensures only the bastion or load balancer is publicly reachable, while the app and DB remain protected.</p><h3>🧭 1.4 Route Tables</h3><p><strong>What:</strong> Configured routing rules for public and private subnets.<br> <strong>Why:</strong> Enables traffic to flow correctly — public subnet routes through the internet gateway, private through the NAT gateway.</p><blockquote>💡 <em>A subnet becomes public only when its route table points to an Internet Gateway.</em></blockquote><h3>💻 Step 2 — Launch EC2 Instances (Bastion &amp; Application Servers)</h3><h3>🧩 Bastion Host (Jump Server)</h3><ul><li>Deployed in <strong>public subnet</strong></li><li>Has a <strong>public IP</strong></li><li>Security group allows SSH (port 22) <strong>only from your IP</strong></li></ul><h3>🖥 Application Server</h3><ul><li>Deployed in <strong>private subnet</strong></li><li>No public IP</li><li>Security group allows:</li><li>SSH (port 22) from <strong>Bastion Host</strong></li><li>HTTP (port 80) from <strong>Load Balancer</strong></li></ul><h3>💻 2.1 EC2 Instances (Bastion &amp; App Server)</h3><p><strong>What:</strong> A Bastion host in the public subnet and an application server in the private subnet were deployed.<br> <strong>Why:</strong> The bastion provides secure SSH access to the app server without exposing it publicly.</p><h3>🔑 2.2 Security Groups &amp; Key Pairs</h3><p><strong>What:</strong> Configured security groups to restrict access to only necessary ports and created key pairs for SSH access.<br> <strong>Why:</strong> Protects the infrastructure from unauthorized access.</p><h3>🧱 2.3 SSH via Bastion</h3><p><strong>What:</strong> Accessed the application server through the bastion host using SSH agent forwarding.<br> <strong>Why:</strong> Maintains security by not exposing private EC2s to the internet.</p><h3>🧰 2.4 Server Setup</h3><p><strong>What:</strong> Installed NGINX, PHP, MySQL client, Git, Composer, and configured Laravel permissions.<br> <strong>Why:</strong> Prepares a fully functional environment for the backend to run smoothly.</p><blockquote><em>🔐 Using a Bastion Host ensures you never expose your private servers directly to the internet.</em></blockquote><h3>🗄 Step 3 — Configure Amazon RDS (Database Layer)</h3><ol><li>Create a <strong>MySQL (or PostgreSQL)</strong> instance via <strong>Amazon RDS</strong>.</li><li>Use <strong>private subnets</strong> only (via Subnet Group).</li><li>Configure security: Allow inbound traffic on port 3306 <strong>only from the Application Server’s security group</strong>.</li></ol><h3>🗄️ 3.1 RDS (MySQL Database)</h3><p><strong>What:</strong> A managed RDS instance in a private subnet.<br> <strong>Why:</strong> Provides a secure, automated, and scalable database layer for our Laravel app.</p><blockquote><em>🔐 </em>Your database now lives securely in a private subnet with no public exposure.</blockquote><h3>🔐 Step 4 — SSH Access Through Bastion Host</h3><p>Use SSH agent forwarding or proxying to connect to your private instance through the bastion host.</p><h3>From local machine:</h3><pre>ssh -i bastion-key.pem -A ec2-user@&lt;bastion-public-ip&gt;</pre><p>Then from the bastion:</p><pre>ssh ec2-user@&lt;private-ip-of-app-server&gt;</pre><blockquote><em>🔐 This approach keeps your backend server full private and secure.</em></blockquote><h3>⚙️ Step 5 — Set Up the Application Server</h3><p>Once you’re on your private EC2 instance, install the required dependencies for your backend (e.g., PHP, Node.js, Python, etc.).</p><p>Example (for a typical Linux server):</p><pre>sudo dnf update -y<br>sudo dnf install nginx git curl unzip -y</pre><p>If it’s a PHP-based backend:</p><pre>sudo dnf install php php-fpm php-mysqlnd php-xml php-mbstring php-cli php-curl php-zip -y<br>sudo systemctl enable php-fpm<br>sudo systemctl start php-fpm</pre><h3>🌍 Step 6 — Configure Nginx as a Reverse Proxy</h3><p>Create a configuration file for your web application:</p><pre>sudo nano /etc/nginx/conf.d/app.conf</pre><p>Example:</p><pre>server {<br>    listen 80;<br>    server_name laravel-application.com;<br>    root /var/www/app/public;</pre><pre>    index index.php index.html;</pre><pre>    location / {<br>        try_files $uri $uri/ /index.php?$query_string;<br>    }</pre><pre>    location ~ \.php$ {<br>        include fastcgi_params;<br>        fastcgi_pass unix:/run/php-fpm/www.sock;<br>        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;<br>    }</pre><pre>    location ~ /\.ht {<br>        deny all;<br>    }<br>}</pre><p>Reload Nginx:</p><pre>sudo nginx -t<br>sudo systemctl reload nginx</pre><h3>🔑 Step 7 — Set Permissions &amp; Environment Configuration</h3><p>Give proper permissions to storage or log folders:</p><pre>sudo chmod -R 775 /var/www/app/storage<br>sudo chmod -R 775 /var/www/app/bootstrap/cache</pre><p>Configure your application’s environment file (e.g., .env) to include your database and other credentials.</p><h3>🗃 Step 8 — Create and Connect the Database</h3><p>Connect to your RDS instance via MySQL client:</p><pre>mysql -h &lt;rds-endpoint&gt; -u admin -p</pre><p>Create a new database and user:</p><pre>CREATE DATABASE app_db;<br>GRANT ALL PRIVILEGES ON app_db.* TO &#39;app_user&#39;@&#39;%&#39; IDENTIFIED BY &#39;secure_password&#39;;<br>FLUSH PRIVILEGES;</pre><h3>⚖️ Step 9 — Set Up a Load Balancer</h3><p>Use an <strong>Application Load Balancer (ALB)</strong> for better scalability and traffic management.</p><ol><li>Create an <strong>ALB</strong> in public subnets.</li><li>Create a <strong>Target Group</strong> that includes your private EC2 instance.</li><li>Update your Application Server security group to allow inbound traffic from the ALB only.</li></ol><h3>⚙️ 9.1. Load Balancer &amp; Target Groups</h3><p><strong>What:</strong> Created an Application Load Balancer to distribute traffic to our private EC2 instance.<br> <strong>Why:</strong> Improves scalability, high availability, and performance of our backend.</p><blockquote><em>🔐 This ensure your application scales gracefully and maintains security.</em></blockquote><h3>🪣 Step 10 — Deploy Frontend on S3 + CloudFront</h3><h4>1️⃣ Build Your Frontend (React, Vue, Angular, etc.)</h4><pre>npm run build</pre><h4>2️⃣ Create an S3 Bucket</h4><ul><li>Enable <strong>Static Website Hosting</strong></li><li>Uncheck “Block all public access”</li><li>Upload your build files</li></ul><p>Set public-read permissions:</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: &quot;*&quot;,<br>      &quot;Action&quot;: [&quot;s3:GetObject&quot;],<br>      &quot;Resource&quot;: [&quot;arn:aws:s3:::my-frontend-app/*&quot;]<br>    }<br>  ]<br>}</pre><p>Access via:</p><pre>http://my-frontend-app.s3-website-us-east-1.amazonaws.com</pre><h4>3️⃣ Add CloudFront for Global CDN</h4><ul><li>Set <strong>Origin</strong> to your S3 bucket</li><li>Enable <strong>Redirect HTTP to HTTPS</strong></li><li>Optionally connect <strong>Route 53 domain</strong> + <strong>ACM SSL Certificate</strong></li></ul><h3>🗃️ 10.1 S3 and CloudFront (Frontend Hosting)</h3><p><strong>What:</strong> Deployed the Vue.js frontend to S3 and accelerated content delivery with CloudFront.<br> <strong>Why:</strong> S3 provides reliable static hosting, while CloudFront ensures low latency and global performance.</p><blockquote>💡 CloudFront adds SSL, caching, and performance boost using AWS’s edge network.</blockquote><h3>✅ Step 11 — Test the Full Flow</h3><p>Now test everything together:</p><ol><li><strong>Frontend (S3 + CloudFront)</strong> → static website</li><li><strong>Backend (EC2 + ALB)</strong> → API layer</li><li><strong>Database (RDS)</strong> → persistent data storage</li><li><strong>Bastion Host</strong> → secure SSH entry point</li></ol><blockquote>🎯 Your three-tier architecture is live and production-ready.</blockquote><h3>🧠 Key Concepts and Topics Covered</h3><p>Here’s a full list of AWS concepts we covered in this deployment:</p><h3>🧩 Networking</h3><ul><li>VPC (Virtual Private Cloud)</li><li>Public and Private Subnets</li><li>Route Tables</li><li>Internet Gateway</li><li>NAT Gateway</li></ul><h3>💻 Compute</h3><ul><li>EC2 Instances (Bastion + Application Servers)</li><li>Load Balancer (ALB)</li><li>Key Pairs</li><li>Security Groups</li><li>Target Groups</li></ul><h3>🗄 Database Layer</h3><ul><li>Amazon RDS</li><li>Subnet Groups</li><li>MySQL Configuration</li></ul><h3>🔐 Access &amp; Security</h3><ul><li>SSH via Bastion Host</li><li>Agent Forwarding / ProxyJump</li><li>Least Privilege Networking</li></ul><h3>⚙️ Server Setup</h3><ul><li>Installing Dependencies (Nginx, PHP, MySQL, Git, Curl, Composer)</li><li>Folder Permissions</li><li>Environment Configuration</li></ul><h3>🌍 Frontend Hosting</h3><ul><li>S3 (Static Hosting)</li><li>CloudFront (CDN + HTTPS)</li><li>Route 53 (Custom Domain Integration)</li></ul><h3>🧰 Infrastructure Design</h3><ul><li>Three-tier Application Model</li><li>High Availability through ALB</li><li>Secure Private Networking</li><li>Scalability and Cost Optimization</li></ul><h3>🎯 Conclusion</h3><p>Deploying a three-tier web application on AWS teaches you the foundation of <strong>cloud architecture design</strong> — networking, compute, storage, and security all working together.</p><p>Once you understand this pattern, you can confidently host anything:<br> a Laravel API, a Node.js backend, or even a React or Vue frontend — all in a secure, scalable way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c8ddbffacd7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Building a Translation Management Service API with Laravel]]></title>
            <link>https://medium.com/@ali.haider8014/building-a-translation-management-service-api-with-laravel-76cfd6e15f63?source=rss-1f750eed85d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/76cfd6e15f63</guid>
            <category><![CDATA[localization]]></category>
            <category><![CDATA[multilingual]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Ali Haider]]></dc:creator>
            <pubDate>Wed, 03 Sep 2025 11:27:52 GMT</pubDate>
            <atom:updated>2025-09-03T11:27:52.831Z</atom:updated>
            <content:encoded><![CDATA[<p>Managing translations at scale is one of the most common challenges when building multilingual applications. Whether for a web app, a mobile app, or both, developers often need a system that can:</p><ul><li>Store translations for multiple languages.</li><li>Organize them by tags (e.g., web, mobile, desktop).</li><li>Provide APIs so frontend apps can fetch localized content in real time.</li><li>Scale to handle <strong>hundreds of thousands of records</strong> without performance bottlenecks.</li></ul><p>In this article, I’ll walk you through the <strong>concept and architecture</strong> of a Laravel-based <strong>Translation Management Service API</strong> that solves exactly these problems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0JepvlGhA5-Z-2UVCPB4pQ.png" /><figcaption>translation management workflow</figcaption></figure><h3>🔑 Why a Translation API?</h3><p>Traditionally, Laravel apps store translations inside static JSON or PHP language files. While this works for smaller projects, it quickly becomes a pain point when:</p><ul><li>You need to support dozens of locales (en, fr, de, es, …).</li><li>Marketing and product teams (non-developers) need to manage translations.</li><li>You need to fetch translations dynamically for SPAs, mobile apps, or microservices.</li><li>The project scales to <strong>100k+ translation entries</strong>, where file-based storage is inefficient.</li></ul><p>A <strong>database-driven Translation API</strong> solves these problems by centralizing and exposing translations as a service.</p><h3>🏗️ Architecture Overview</h3><p>The <strong>Translation Management Service API</strong> consists of:</p><ol><li><strong>Database Schema</strong> — Stores translations with fields like key, locale, value, and tags.</li><li><strong>API Endpoints</strong> — Create, update, search, and delete translations.</li><li><strong>Search Functionality</strong> — Look up translations by keys, values, or tags.</li><li><strong>Export Endpoint</strong> — Always delivers the latest translations as JSON for frontend/mobile apps.</li><li><strong>Scalability Features</strong> — Database indexing, efficient queries, and seed data for load testing.</li><li><strong>Security Layer</strong> — Token-based authentication to protect the API.</li></ol><h3>⚡ Performance &amp; Scalability</h3><p>The system is designed to remain fast even with <strong>large datasets</strong>:</p><ul><li><strong>Unique indexes</strong> prevent duplicates and optimize lookups.</li><li><strong>JSON indexing</strong> on tags allows efficient tag-based searching.</li><li><strong>Chunked queries</strong> ensure large export responses stay under <strong>500ms</strong>.</li><li>A <strong>seeder/command</strong> populates the database with <strong>100k+ records</strong> for stress testing.</li></ul><p>This makes it practical for <strong>real-world enterprise projects</strong> where translations can grow rapidly.</p><h3>🔐 Security</h3><p>The API is secured using <strong>token-based authentication (Laravel Sanctum)</strong>.<br> This ensures only authorized services (e.g., frontend apps, mobile apps) can access or update translations.</p><h3>📦 Key Features</h3><ol><li><strong>Multi-locale Support</strong> — Store and fetch translations for any number of languages.</li><li><strong>Tagging</strong> — Contextual tags like mobile, web, or admin help categorize translations.</li><li><strong>CRUD API Endpoints</strong> — Easy to manage translations through standard REST APIs.</li><li><strong>JSON Export Endpoint</strong> — Frontend applications (Vue.js, React, or mobile apps) can consume the latest translations anytime.</li><li><strong>Scalability Tested</strong> — Handles <strong>100k+ translations</strong> efficiently.</li></ol><h3>🧪 Example Use Case</h3><p>Imagine you’re building a SaaS platform that supports <strong>English, French, and Spanish</strong>.</p><ul><li>The <strong>marketing team</strong> wants to add new phrases for campaigns.</li><li>The <strong>mobile app</strong> needs translations specific to its UI.</li><li>The <strong>web app</strong> requires real-time access to updated messages.</li></ul><p>With this Translation API:</p><ul><li>Marketing adds new translations via API (no need to edit files).</li><li>Mobile and web apps fetch the <strong>latest translations via JSON export</strong>.</li><li>Performance stays smooth even with thousands of translations.</li></ul><h3>🚀 Deployment</h3><p>To make this solution truly production-ready:</p><ul><li>A <strong>Docker setup</strong> is included for easy deployment.</li><li><strong>Swagger/OpenAPI documentation</strong> describes all endpoints.</li><li>Unit and feature tests provide <strong>95%+ coverage</strong>, including performance testing.</li></ul><h3>📂 Source Code</h3><p>I’ve implemented the complete solution with models, controllers, requests, factories, and routes in Laravel. You can find the <strong>GitHub repository here:</strong></p><p>👉 <a href="https://github.com/Alihaider8014/laravel-translation-management-service">GitHub Repository — Laravel Translation Management Service</a></p><h3>🎯 Conclusion</h3><p>By building a <strong>Translation Management Service API in Laravel</strong>, we:</p><p>✅ Centralized translations in a scalable database.<br> ✅ Exposed them via secure and fast APIs.<br> ✅ Enabled frontend/mobile apps to fetch real-time translations.<br> ✅ Future-proofed the system for large-scale multilingual projects.</p><p>This architecture ensures translations remain manageable, secure, and performant as your product grows globally. 🌍</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76cfd6e15f63" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an AI-Powered Resume Matching System with Laravel, Vue.js, and OpenAI | ChatGPT]]></title>
            <link>https://medium.com/@ali.haider8014/building-an-ai-powered-resume-matching-system-with-laravel-vue-js-and-openai-chatgpt-29722958284f?source=rss-1f750eed85d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/29722958284f</guid>
            <dc:creator><![CDATA[Ali Haider]]></dc:creator>
            <pubDate>Fri, 31 Jan 2025 10:39:10 GMT</pubDate>
            <atom:updated>2025-01-31T10:39:10.503Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*PVxF6EIqq8YzAu_cqGaEfw.jpeg" /></figure><h3>Introduction</h3><p>Recruiters often face challenges in efficiently screening and shortlisting resumes. Manually comparing thousands of resumes against a job description is time-consuming and prone to human error. To solve this problem, we built an <strong>AI-powered resume matching system</strong> using <strong>Laravel, Vue.js, and OpenAI</strong>. This system allows recruiters to upload multiple resumes in PDF format, compare them against a given job description, and receive ranked results based on their relevance.</p><h3>Features</h3><ul><li><strong>Bulk Resume Upload</strong>: Users can upload multiple resumes in PDF format.</li><li><strong>AI-Powered Matching</strong>: OpenAI analyzes the resumes against the job description and provides a match score.</li><li><strong>Ranking &amp; Insights</strong>: Resumes are ranked based on relevance, with missing skills and justifications displayed.</li><li><strong>Scalability</strong>: Efficiently processes thousands of resumes with optimized performance.</li></ul><h3>Tech Stack</h3><ul><li><strong>Backend</strong>: Laravel (PHP)</li><li><strong>Frontend</strong>: Vue.js</li><li><strong>AI Processing</strong>: OpenAI API (GPT models)</li><li><strong>File Handling</strong>: Spatie PDF Parser</li><li><strong>Database</strong>: MySQL/PostgreSQL</li></ul><h3>System Workflow</h3><ol><li><strong>Upload Job Description &amp; Resumes</strong>: Users enter a job description and upload multiple resumes.</li><li><strong>Extract Text from Resumes</strong>: The system extracts text from PDFs using <strong>Spatie PDF Parser</strong>.</li><li><strong>AI Processing with OpenAI</strong>: The job description and extracted text are sent to OpenAI for ranking and analysis.</li><li><strong>Display Results</strong>: The system ranks resumes based on relevance and displays match scores, missing skills, and justifications.</li></ol><h3>Developer Setup Guide</h3><h3>Prerequisites</h3><p>Ensure you have the following installed:</p><ul><li>PHP 8+</li><li>Laravel 10+</li><li>Node.js &amp; npm</li><li>Composer</li><li>MySQL/PostgreSQL</li></ul><h3>Step 1: Clone the Repository</h3><pre>git clone https://github.com/Alihaider8014/AI-Powered-resume-matching-system.git<br>cd AI-Powered-resume-matching-system</pre><h3>Step 2: Install Dependencies</h3><pre>composer install<br>npm install</pre><h3>Step 3: Configure Environment Variables</h3><p>Copy the .env.example file and rename it to .env:</p><pre>cp .env.example .env</pre><p>Then, update the following values in .env:</p><pre>OPENAI_API_KEY=your_openai_api_key<br>DB_CONNECTION=mysql<br>DB_HOST=127.0.0.1<br>DB_PORT=3306<br>DB_DATABASE=your_database<br>DB_USERNAME=your_username<br>DB_PASSWORD=your_password</pre><h3>Step 4: Migrate Database</h3><pre>php artisan migrate</pre><h3>Step 5: Start Laravel Backend</h3><pre>php artisan serve</pre><h3>Step 6: Start Vue.js Frontend</h3><pre>npm run dev</pre><h3>API Endpoints</h3><h3>Upload Resumes &amp; Process Matching</h3><pre>POST /upload-resumes</pre><h4>Request Body (Form Data)</h4><pre>{<br>  &quot;job_description&quot;: &quot;Full Stack Developer with Laravel and Vue.js experience.&quot;,<br>  &quot;resumes&quot;: [&quot;file1.pdf&quot;, &quot;file2.pdf&quot;]<br>}</pre><h4>Response Example</h4><pre>{<br>  &quot;ranked_resumes&quot;: [<br>    {<br>      &quot;name&quot;: &quot;John Doe&quot;,<br>      &quot;matchScore&quot;: 85,<br>      &quot;missingSkills&quot;: [&quot;AWS&quot;, &quot;Docker&quot;],<br>      &quot;justification&quot;: &quot;Good match but lacks cloud experience.&quot;<br>    },<br>    {<br>      &quot;name&quot;: &quot;Jane Smith&quot;,<br>      &quot;matchScore&quot;: 78,<br>      &quot;missingSkills&quot;: [&quot;Vue.js&quot;],<br>      &quot;justification&quot;: &quot;Strong backend skills but needs frontend expertise.&quot;<br>    }<br>  ]<br>}</pre><h3>Conclusion</h3><p>By integrating <strong>Laravel, Vue.js, and OpenAI</strong>, we successfully built an AI-powered resume matcher that streamlines the hiring process. Recruiters can now quickly identify the best candidates, saving time and improving hiring accuracy.</p><p>🚀 <strong>Future Improvements:</strong></p><ul><li>Support for more file formats (e.g., DOCX, TXT)</li><li>Improve AI prompt engineering for better accuracy</li><li>Deploy as a SaaS-based resume screening tool</li></ul><p>Feel free to <strong>contribute, suggest improvements, or fork the project</strong>! 🔥</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29722958284f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recovering from a Git Disaster: My Journey and Lessons Learned]]></title>
            <link>https://medium.com/@ali.haider8014/recovering-from-a-git-disaster-my-journey-and-lessons-learned-fa6ab95e7931?source=rss-1f750eed85d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa6ab95e7931</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Ali Haider]]></dc:creator>
            <pubDate>Wed, 22 May 2024 16:36:01 GMT</pubDate>
            <atom:updated>2024-05-22T16:36:01.528Z</atom:updated>
            <content:encoded><![CDATA[<p>We all know the feeling of excitement when pushing code into GitHub. Recently, I had an experience that taught me valuable lessons about Git, resilience, and problem-solving. Picture this: one moment, you’re on top of the world, about to make the final push, and the next moment, you’ve made a tiny mistake that feels catastrophic. What started as a small error turned into an educational journey, filled with twists and turns, offering new insights, a few laughs, and some valuable skills.</p><h3>Problem: The Git Catastrophe</h3><p>I was setting up my project with Git. Everything was going well:</p><pre>git init</pre><pre>git add .</pre><p>But then, I accidentally ran:</p><pre>git reset --hard</pre><p>This command wiped out all my files. To make matters worse, I hadn’t made any commits yet. My work vanished, and I was left staring at an empty project.</p><h3>Solution: The Path to Recovery</h3><p>Initially, I panicked. Then, I discovered a way to potentially recover my lost files. Here’s how I did it:</p><ol><li><strong>Run Git File System Check:</strong></li></ol><pre>git fsck --lost-found</pre><p><strong>2. Write a Bash Script to Restore Files:</strong></p><p>With the lost files found, I wrote a bash script to restore them: Because I’ve almost 90 PHP files.</p><pre># Define an array of commit hashes<br>commits=(<br>    &quot;00c6506709b51915dea40e1867613d145d52fe7f&quot;<br>    &quot;01e4a6cda9eb380973b23a40d562bca8a3a198b4&quot;<br>    &quot;037e17df03b0598d7bbd27ed333312e8e337fb1b&quot;<br>    # Add more hashes as needed<br>)<br><br># Initialize a counter<br>counter=1<br><br># Loop over each commit hash and save its changes to a separate file<br>for commit in &quot;${commits[@]}&quot;; do<br>    # Create a file name with the counter<br>    file_name=&quot;${counter}_${commit}.php&quot;<br>    # Increment the counter<br>    ((counter++))<br>    # Use git show to save the changes to the file<br>    if git show &quot;$commit&quot; &gt; &quot;$file_name&quot;; then<br>        echo &quot;Restored: $file_name&quot;<br>    else<br>        echo &quot;Failed to create: $file_name&quot;<br>    fi<br>done</pre><p>This script helped me recover my lost files, restoring each one from the Git lost and found directory.</p><h3>Conclusion</h3><p>This experience was a rollercoaster of emotions, but it taught me crucial lessons about the importance of frequent commits, backups, and the power of problem-solving. Mistakes are inevitable, but they are also opportunities to learn and grow. Now, I’m more prepared and resilient, ready to handle future challenges with confidence.</p><p>Remember, every setback is a setup for a comeback. Keep coding, keep learning, and embrace every experience as a chance to improve. 🚀</p><p>By sharing this journey, I hope to inspire others to stay calm in the face of adversity and to always look for solutions, no matter how dire the situation may seem. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa6ab95e7931" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to integrate ChatGPT in a Laravel Application| OpenAI]]></title>
            <link>https://medium.com/@ali.haider8014/how-to-integrate-chatgpt-in-a-laravel-application-openai-b089050d6e00?source=rss-1f750eed85d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/b089050d6e00</guid>
            <dc:creator><![CDATA[Ali Haider]]></dc:creator>
            <pubDate>Mon, 27 Mar 2023 16:42:31 GMT</pubDate>
            <atom:updated>2023-03-28T18:07:58.032Z</atom:updated>
            <content:encoded><![CDATA[<p>Chatbots have become an essential part of many businesses and industries, as they can help improve customer engagement and provide quick and personalized responses to customer inquiries. With the recent advancements in AI technology, chatbots are becoming more advanced and intelligent, making them more effective and efficient in serving customers.</p><p>One of the most advanced chatbots available today is ChatGPT, an AI-powered chatbot developed by OpenAI. ChatGPT is built on top of the GPT-3 language model, which is one of the most powerful language models available today. In this tutorial, we’ll show you how to integrate ChatGPT in a Laravel application using the OpenAI API.</p><h3>Prerequisites</h3><p>Before we start, make sure you have the following:</p><ul><li>A basic understanding of Laravel</li><li>An OpenAI API key</li><li>Composer installed on your system</li></ul><h3>Step 1: Install GuzzleHTTP</h3><p>To make requests to the OpenAI API, we’ll use GuzzleHTTP, a PHP HTTP client. You can install it using Composer by running the following command in your Laravel project directory:</p><pre>composer require guzzlehttp/guzzle</pre><h3>Step 2: Create a Controller</h3><p>Next, let’s create a new controller that will handle incoming chatbot requests. Run the following command to create a new controller in Laravel:</p><pre>php artisan make:controller ChatGPTController</pre><p>Then, open the ChatGPTController.php file that was just created in the app/Http/Controllers directory, and add the following code to it:</p><pre>&lt;?php<br><br>namespace App\Http\Controllers;<br><br>use Illuminate\Http\Request;<br>use GuzzleHttp\Client;<br><br>class ChatGPTController extends Controller<br>{<br>    public function chatGPT(Request $request)<br>    {<br>        // Create a new Guzzle client<br>        $client = new Client();<br><br>        // Make a request to the OpenAI API<br>        $response = $client-&gt;request(&#39;POST&#39;,&#39;https://api.openai.com/v1/chat/completions&#39;, [<br>            &#39;headers&#39; =&gt; [<br>                &#39;Authorization&#39; =&gt; &#39;Bearer &#39; . env(&#39;OPENAI_API_KEY&#39;),<br>                &#39;Content-Type&#39; =&gt; &#39;application/json&#39;,<br>            ],<br>            &#39;json&#39; =&gt; [<br>                &#39;messages&#39; =&gt; [[&#39;role&#39; =&gt; &#39;user&#39;, &#39;content&#39; =&gt; $request-&gt;input(&#39;prompt&#39;)]],<br>                &#39;model&#39;    =&gt; &quot;gpt-3.5-turbo&quot;,<br>                &#39;temperature&#39; =&gt; 0.8<br>            ],<br>        ]);<br><br>        // Get the response body and return it as JSON<br>        $responseBody = json_decode($response-&gt;getBody(), true);<br>        $chatResponse = $responseBody[&#39;choices&#39;][0][&#39;message&#39;][&#39;content&#39;];<br><br>        return response()-&gt;json([<br>            &#39;message&#39; =&gt; $chatResponse,<br>        ]);<br>    }<br>}</pre><p>This code creates a new Guzzle client, makes a request to the OpenAI API using the gpt-3.5-turbo model, and returns the response as a JSON object.</p><h3>Step 3: Create a Route</h3><p>Now, let’s create a route that will point to our ChatGPTController. Open the routes/api.php file and add the following code:</p><pre>Route::post(&#39;/chatgpt&#39;, [ChatGPTController::class,&#39;chatGPT&#39;]);</pre><p>This code creates a new route that points to the chatgpt method of our ChatGPTController when a POST request is made to the /chatgpt endpoint.</p><h3>Step 4: Add Your OpenAI API Key</h3><p>To make requests to the OpenAI API, you’ll need to add your API key to your Laravel application. Open the .env file in your Laravel project directory and add the following line:</p><pre>OPENAI_API_KEY=YOUR-API-KEY</pre><h3>Step 5: Open Your Postman</h3><p>Make sure you have a postman for API testing: Here is the example of ChatGPT:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Si3b-J-N0mO3Jv4z-T2B9Q.png" /></figure><blockquote>Note: You will send any prompt which do you want.</blockquote><p>I hope this article will help you to integrate ChatGPT in your laravel application, and boost your learning to next level.</p><p>You will find laravel project with proper integration. Here is the link of repo: <br>Github: <a href="https://github.com/Alihaider8014/integrate-chatgpt-laravel">https://github.com/Alihaider8014/integrate-chatgpt-laravel</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b089050d6e00" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to setup Laravel project using Composer]]></title>
            <link>https://medium.com/@ali.haider8014/how-to-setup-laravel-project-using-composer-e64cd9f84e56?source=rss-1f750eed85d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/e64cd9f84e56</guid>
            <dc:creator><![CDATA[Ali Haider]]></dc:creator>
            <pubDate>Mon, 16 Jan 2023 17:34:13 GMT</pubDate>
            <atom:updated>2023-01-16T17:34:13.034Z</atom:updated>
            <content:encoded><![CDATA[<p>Laravel is a popular PHP framework that makes it easy to build modern, robust web applications. One of the best ways to get started with Laravel is by using Composer, a dependency manager for PHP. In this blog post, we’ll show you how to set up a new Laravel project using Composer.</p><p>First, you’ll need to make sure that you have Composer installed on your system. If you don’t have it already, you can download it from the official website (<a href="https://getcomposer.org/">https://getcomposer.org/</a>) and follow the instructions to install it.</p><p>Once you have Composer installed, open up your command line interface (CLI) and navigate to the directory where you want to create your new Laravel project. Then, run the following command:</p><pre>composer create-project --prefer-dist laravel/laravel myproject</pre><p>This command will create a new directory called “myproject” in your current location, and install the latest version of Laravel inside it. The --prefer-dist flag tells Composer to download a pre-built version of Laravel, rather than installing it from source.</p><p>After Composer has finished installing the dependencies, navigate inside the newly created project directory:</p><pre>cd myproject</pre><p>Now, you need to configure the environment for your project, for that create a copy of the .env file from .env.example</p><pre>cp .env.example .env</pre><p>You should edit the .env file to match your local environment, including adding your database credentials, app name, and other settings.</p><p>The last step is to generate an application key, it is used for security purposes. Run this command:</p><pre>php artisan key:generate</pre><p>This command will automatically generate a new key and add it to your .env file.</p><p>You have now successfully set up a new Laravel project using Composer. You can now start building your application by following the documentation on the Laravel website (<a href="https://laravel.com/docs/">https://laravel.com/docs/</a>) and using the many tools and features that Laravel provides.</p><p>In conclusion, Composer is an essential tool for working with Laravel, and using it to set up a new project is a quick and easy way to get started. With a few simple commands, you can have a new Laravel project up and running, ready for you to start building your next great web application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e64cd9f84e56" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>