<?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 Rayhan Kabir on Medium]]></title>
        <description><![CDATA[Stories by Rayhan Kabir on Medium]]></description>
        <link>https://medium.com/@rayhankabir?source=rss-bd8a7dfc5638------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*IpmmdJWQQ4RwQxCd.</url>
            <title>Stories by Rayhan Kabir on Medium</title>
            <link>https://medium.com/@rayhankabir?source=rss-bd8a7dfc5638------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 20:22:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rayhankabir/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[How a Browser Works: From URL to Pixels: Part-1]]></title>
            <link>https://medium.com/@rayhankabir/how-a-browser-works-from-url-to-pixels-part-1-9a2c9bc8e353?source=rss-bd8a7dfc5638------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a2c9bc8e353</guid>
            <dc:creator><![CDATA[Rayhan Kabir]]></dc:creator>
            <pubDate>Wed, 26 Aug 2026 04:51:33 GMT</pubDate>
            <atom:updated>2026-08-26T04:51:33.212Z</atom:updated>
            <content:encoded><![CDATA[<p>When you type a URL like [https://example.com](https://example.com) into your browser address bar and press <strong>Enter</strong>, the website seems to appear instantly.</p><p>In reality, your browser initiates a complex chain of low-level operations involving the operating system, network protocols, DNS resolution, TLS security handshakes, HTML/CSS parsing engines, JavaScript runtime environments, and GPU-driven rendering pipelines.</p><p>For frontend developers and software engineers, understanding this pipeline isn&#39;t just trivia—it is the foundational key to mastering <strong>DOM performance, layout thrashing, repaint/reflow costs, and Core Web Vitals</strong>.</p><p>Here is the step-by-step technical breakdown of what actually happens under the hood.</p><h3>1. URL Parsing &amp; Intent Recognition</h3><p>The sequence begins the exact millisecond keypress events pass from your operating system to the browser process.</p><p>The browser must decompose the input string to extract three critical components:</p><ul><li><strong>Protocol:</strong> https:// (determines how data will be encrypted and transmitted)</li><li><strong>Domain Name:</strong> example.com (maps to the destination host)</li><li><strong>Resource Path:</strong> /products (identifies the specific server resource)</li></ul><p><strong>Edge Case:</strong> If the input fails URL pattern matching (e.g., missing top-level domain or containing space characters), the browser bypasses network routing and redirects the string directly to your default search engine.</p><h3>2. DNS Resolution (Resolving the Host Name to an IP)</h3><p>Computers cannot communicate using human-readable domain names; they route packets using IP addresses. The browser initiates a hierarchical DNS cache lookup to find the matching IP:</p><p>Plaintext</p><p>Browser DNS Cache</p><p>↓</p><p>OS Host Cache &amp; DNS Cache</p><p>↓</p><p>Router Cache</p><p>↓</p><p>ISP DNS Server Cache</p><p>↓</p><p>Recursive DNS Lookup (Root → TLD → Authoritative Server)</p><p>↓</p><p>IP Address Identified (e.g., 93.184.216.34)</p><p>If the entry is not found in local or ISP caches, a <strong>Recursive DNS Resolver</strong> queries the Root DNS servers (.), the Top-Level Domain (TLD) servers (.com), and finally the Authoritative Name Servers to retrieve the target IP.</p><p>For high-traffic systems, this IP entry often points to a load balancer or Anycast routing system rather than a single physical server.</p><h3>3. Connection Establishment (TCP &amp; TLS Handshake)</h3><p>With the IP address identified, the browser opens a network socket to establish a connection.</p><h3>The TCP 3-Way Handshake</h3><p>For HTTP/1.1 and HTTP/2 flows, the browser opens a TCP socket to port <strong>443</strong> (for HTTPS) or port <strong>80</strong> (for HTTP):</p><ol><li><strong>SYN:</strong> Client sends a Synchronization packet to the server.</li><li><strong>SYN-ACK:</strong> Server acknowledges receipt and requests synchronization back.</li><li><strong>ACK:</strong> Client confirms, establishing the TCP connection.</li></ol><h3>The TLS Handshake (HTTPS Security)</h3><p>Before any data transfers over HTTPS, an encrypted layer is negotiated:</p><p>Browser Server</p><p>│</p><p>│─────── ClientHello ────────────────&gt;│ (Supported Ciphers, TLS version)</p><p>│&lt;────── ServerHello + Certificate ───│ (Public Key, Certificate selection)</p><p>│</p><p>│ [Validates CA Certificate] │</p><p>│─────── Key Exchange ───────────────&gt;│ (Session Key generation)</p><p>│</p><p>│&lt;────── Encrypted Stream Ready ──────│</p><p>Once identity is verified against trusted Certificate Authorities (CAs), symmetric session keys are established, and all subsequent communications are encrypted.</p><h3>4. Sending the HTTP Request</h3><p>With an encrypted channel established, the browser sends an HTTP request payload:</p><p>HTTP</p><p>GET /products HTTP/1.1</p><p>Host: example.com</p><p>Accept: text/html,application/xhtml+xml</p><p>Accept-Encoding: gzip, deflate, br</p><p>User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)...</p><p>Cookie: session_id=xyz123; pref_theme=dark</p><p>Key request headers include:</p><ul><li><strong>Method &amp; Path:</strong> Action being requested (GET) and target (/products).</li><li><strong>Content Negotiation:</strong> What formats (Accept) and compressions (Accept-Encoding) the client understands.</li><li><strong>Cookies:</strong> State identifiers sent back to maintain sessions and user authentication.</li></ul><h3>5. Server-Side Processing &amp; Architecture</h3><p>The request reaches the web server (e.g., NGINX, Apache, or AWS ALB). The web server inspects virtual host configurations, SSL settings, and routing rules to determine how to fulfill the request.</p><p>Browser ──&gt; Web Server / Reverse Proxy ──&gt; App Engine ──&gt; Database / Cache</p><ol><li><strong>Static Requests:</strong> The server reads directly from storage and returns the asset.</li><li><strong>Dynamic Requests:</strong> The server delegates the request to an application layer (Node.js, Python, Go, Java, etc.), which queries databases or microservices before building a response.</li></ol><h3>6. Receiving the HTTP Response</h3><p>The server responds with HTTP headers followed by the payload body:</p><p>HTTP</p><p>HTTP/1.1 200 OK</p><p>Content-Type: text/html; charset=UTF-8</p><p>Content-Encoding: gzip</p><p>Cache-Control: max-age=3600</p><p>&lt;!DOCTYPE html&gt;</p><p>&lt;html&gt;...&lt;/html&gt;</p><h3>Response Status Code Quick Reference</h3><p><strong>Category</strong></p><p><strong>Meaning</strong></p><p><strong>Common Examples</strong></p><p><strong>1xx</strong></p><p>Informational</p><p>101 Switching Protocols</p><p><strong>2xx</strong></p><p>Success</p><p>200 OK, 201 Created</p><p><strong>3xx</strong></p><p>Redirection</p><p>301 Moved Permanently, 304 Not Modified</p><p><strong>4xx</strong></p><p>Client Error</p><p>404 Not Found, 401 Unauthorized</p><p><strong>5xx</strong></p><p>Server Error</p><p>500 Internal Server Error, 502 Bad Gateway</p><p>The Content-Type: text/html header signals to the browser&#39;s engine that it must launch its HTML parsing process.</p><h3>7. HTML Parsing &amp; DOM Construction</h3><p>The browser&#39;s rendering engine (e.g., Blink in Chrome, Gecko in Firefox, WebKit in Safari) takes the raw binary response stream and converts it into an internal object hierarchy:</p><p>Plaintext</p><p>Raw Bytes ──&gt; Characters ──&gt; Tokens ──&gt; Nodes ──&gt; DOM Tree</p><ol><li><strong>Bytes to Characters:</strong> Converts raw byte streams into text characters based on character encoding (e.g., UTF-8).</li><li><strong>Tokenization:</strong> Groups characters into HTML tags (&lt;html&gt;, &lt;body&gt;, &lt;h1&gt;).</li><li><strong>Node Creation:</strong> Converts tokens into objects containing properties and rules.</li><li><strong>DOM Construction:</strong> Arranges nodes into a tree structural representation—the <strong>Document Object Model (DOM)</strong>.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a2c9bc8e353" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Transformed a Monolithic React Component into a Scalable, Maintainable Architecture]]></title>
            <link>https://medium.com/@rayhankabir/how-i-transformed-a-monolithic-react-component-into-a-scalable-maintainable-architecture-6b4fbb789b6c?source=rss-bd8a7dfc5638------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b4fbb789b6c</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[context]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Rayhan Kabir]]></dc:creator>
            <pubDate>Wed, 17 Sep 2025 17:38:28 GMT</pubDate>
            <atom:updated>2025-09-17T17:43:38.121Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nmuU_zE2L7ul_tynVH2dSw.jpeg" /></figure><h3>The Challenge: A 1000+ Line Medical Dashboard Component</h3><p>Recently, I faced a massive React component that had grown to over 1000 lines of code. It was a medical dashboard handling patient consultations, prescriptions, lab tests, and reporting — all in a single file! The component had:</p><ul><li>10+ useState hooks managing different aspects of the application</li><li>Complex form handling with react-hook-form</li><li>Multiple API calls for patient data, medicines, lab tests, and diagnoses</li><li>PDF generation functionality</li><li>State management for preview mode and form data</li></ul><p>The code was becoming unmaintainable, difficult to test, and nearly impossible for new developers to understand.</p><h3>The Solution: A Complete Architectural Overhaul</h3><h3>Step 1: Context Management for Shared State</h3><p>I created an AppointmentContext to manage patient and appointment data across components:</p><pre>// Context for managing appointment data<br>export const AppointmentProvider: React.FC&lt;AppointmentProviderProps&gt; = ({<br>  children,<br>  patientId,<br>  appointmentId<br>}) =&gt; {<br>  const [patientInfo, setPatientInfo] = useState&lt;any&gt;({});<br>  <br>  return (<br>    &lt;AppointmentContext.Provider value={{ patientId, appointmentId, patientInfo, setPatientInfo }}&gt;<br>      {children}<br>    &lt;/AppointmentContext.Provider&gt;<br>  );<br>};</pre><h3>Step 2: Custom Hooks for Business Logic</h3><p>I extracted all data fetching and business logic into reusable custom hooks</p><pre>// Custom hook for medical dashboard functionality<br>export const useMedicalDashboard = () =&gt; {<br>  const { patientId } = useAppointment();<br>  const [medicines, setMedicines] = useState([]);<br>  <br>  const handleMedicineSearch = async (keywords: string) =&gt; {<br>    // API call and state management<br>  };<br>  <br>  return { medicines, handleMedicineSearch };<br>};</pre><h3>Step 3: Component Composition Pattern</h3><p>I broke down the monolithic component into focused, single-responsibility components:</p><pre>MedicalDashboard/<br>├── PatientSidebar/          # Patient information and history<br>├── PrescriptionForm/        # Main form container<br>├── sections/<br>│   ├── ReportSection/       # File uploads and reports<br>│   ├── DiagnosisSection/    # Diagnosis selection<br>│   ├── VitalsSection/       # Patient vitals input<br>│   ├── MedicineSection/     # Prescription management<br>│   ├── LabTestsSection/     # Lab test selection<br>│   └── AdditionalInfoSection/ # Notes and follow-up<br>└── PrescriptionPreview/     # PDF preview and download</pre><h3>Step 4: Constants and Configuration Management</h3><p>I moved hardcoded configurations to dedicated constant files:</p><pre>// medicineFieldConfig.ts<br>export const medicineFieldConfig = {<br>  tablet: [<br>    { name: &quot;quantity&quot;, type: &quot;number&quot;, placeholder: &quot;Quantity&quot; },<br>    { name: &quot;duration&quot;, type: &quot;number&quot;, placeholder: &quot;Duration&quot; }<br>  ],<br>  syrup: [<br>    { name: &quot;quantity&quot;, type: &quot;number&quot;, placeholder: &quot;Quantity&quot; },<br>    { name: &quot;unit&quot;, type: &quot;select&quot;, options: [...] }<br>  ]<br>  // ... other medicine types<br>};</pre><h3>Key Benefits Achieved</h3><h3>1. Improved Maintainability</h3><ul><li>Each component is now focused and easier to understand</li><li>Changes to one section don’t affect others</li><li>New developers can onboard faster</li></ul><h3>2. Enhanced Testability</h3><ul><li>Smaller components are easier to test in isolation</li><li>Custom hooks can be tested separately from UI components</li><li>Mocking dependencies became straightforward</li></ul><h3>3. Better Performance</h3><ul><li>Reduced re-renders by localizing state</li><li>Optimized API calls with proper hook dependencies</li><li>Component-level memoization where appropriate</li></ul><h3>4. Scalability</h3><ul><li>New features can be added without touching existing code</li><li>Components can be reused across different parts of the application</li><li>Configuration changes are centralized</li></ul><h3>5. Developer Experience</h3><ul><li>Clear separation of concerns</li><li>Intuitive component structure</li><li>TypeScript support throughout</li><li>Better error handling and loading states</li></ul><h3>Technical Implementation Highlights</h3><h3>Context API for State Sharing</h3><pre>// Clean context usage pattern<br>const { patientId, appointmentId } = useAppointment();</pre><h3>Custom Hooks for Logic Reuse</h3><pre>// Encapsulated API calls and state management<br>const { medicines, searchMedicines } = useMedicineSearch();</pre><h3>Component Composition</h3><pre>// Clean, readable component struct<br>&lt;PrescriptionForm&gt;<br>  &lt;ReportSection /&gt;<br>  &lt;DiagnosisSection /&gt;<br>  &lt;VitalsSection /&gt;<br>  &lt;MedicineSection /&gt;<br>&lt;/PrescriptionForm&gt;</pre><h3>Lessons Learned</h3><ol><li>Start with Context Early: Don’t wait until prop drilling becomes painful</li><li>Custom Hooks are Powerful: They encapsulate logic beautifully</li><li>Configuration Should be External: Hardcoded values belong in constants</li><li>Single Responsibility Principle: applies to React components too</li><li>TypeScript is Non-negotiable: The safety net is worth the setup</li></ol><h3>The Result</h3><p>The refactored codebase now has:</p><ul><li>70% fewer lines in the main component</li><li>Clear separation of concerns</li><li>Reusable components and hooks</li><li>Better performance and maintainability</li><li>Easier testing and debugging</li></ul><h3>Conclusion</h3><p>Refactoring monolithic React components might seem daunting, but the long-term benefits are immense. By applying solid software architecture principles and React best practices, we can create applications that are not just working, but are maintainable, scalable, and enjoyable to work with.</p><p>What’s your experience with refactoring large React components? Share your thoughts in the comments!</p><p>#React #TypeScript #SoftwareArchitecture #Refactoring #FrontendDevelopment #WebDevelopment #CodeQuality #ReactHooks #ComponentDesign</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b4fbb789b6c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>