Firestore Listeners vs WebSockets: How Real-Time Updates Actually Work

Firestore has one of the most convenient real-time APIs in web and mobile development. We write a listener: import { collection, onSnapshot, query, where } from "firebase/firestore"; const q = query( collection(db, "messages"), where("roomId", "==", "general") ); const unsubscribe = onSnapshot(q, (snapshot) => { snapshot.docChanges().forEach((change) => { console.log(change.type, change.doc.id, change.doc.data()); }); }); After that, the UI updates whenever matching documents are added, modified, or removed. It feels similar to a WebSocket because the browser receives real-time updates without manually polling. But Firestore listeners and WebSockets are not the same abstraction. ...

May 3, 2026 · 13 min · Nitin

WebSockets Explained: How Real-Time Communication Works on the Web

Most web applications start with a simple request-response model. The browser asks for something, the server responds, and the connection is done. That model works well for pages, APIs, forms, dashboards, and most CRUD applications. But some features need something different: chat messages that appear instantly live sports scores multiplayer game state collaborative editing cursors trading prices delivery tracking real-time notifications terminal sessions in the browser For these features, repeatedly asking the server “anything new?” becomes wasteful and slow. ...

May 3, 2026 · 12 min · Nitin
CAP theorem cover illustrationA triangle showing consistency, availability, and partition tolerance with a note that partitions force a trade-off between consistency and availability.CAP TheoremHow distributed systems choose behaviorwhen the network stops cooperatingCConsistencyAAvailabilityPPartitionToleranceNetwork splitWhen a partition happens, you usually choose CP or AP.

CAP Theorem Explained: Consistency vs Availability in Distributed Systems

The CAP theorem is one of the most important ideas in distributed systems because it explains why “just make it always correct and always online” is not a realistic requirement once multiple nodes and unreliable networks enter the picture. In simple terms, CAP says that when a network partition happens, a distributed system can prioritize either: Consistency Availability But not both at the same time. Partition tolerance is not a feature you casually add or remove. If your system runs across multiple machines, partitions are a fact of life, so the real design choice is usually CP vs AP. ...

March 9, 2026 · 4 min · Nitin
Stripe hosted checkout flow using webhook-first fulfillment and order status polling

Integrating Stripe Payment with Checkout Flow (Webhooks + Polling)

If you use a hosted payment page like Stripe Checkout, the safest architecture is: Create an internal order before redirecting. Redirect the user to the hosted checkout URL. Use webhooks as the source of truth for fulfillment. Let the frontend poll order status after return. This avoids race conditions and ensures users still get entitlements even if they close the tab before the success page loads. Why This Pattern Works Hosted checkout redirects are excellent for UX and compliance, but redirects are not guaranteed delivery signals. ...

March 3, 2026 · 2 min · Nitin
Migrating WordPress to Hugo with Cloudflare Pages

How to Migrate WordPress to Hugo with Decap CMS and Cloudflare Pages (Free Hosting)

Why Migrate from WordPress? WordPress is powerful, but for a technical blog that mostly serves static content, it comes with unnecessary overhead — hosting costs, plugin updates, security patches, and slower page loads. Static site generators like Hugo offer a simpler, faster, and cheaper alternative. Here’s what we migrated to: Hugo — blazing fast static site generator PaperMod — clean, minimal theme perfect for tech blogs Decap CMS — web-based content management with GitHub backend Cloudflare Pages — free hosting with global CDN Google AdSense — preserved auto ads from the WordPress site The result? A site that builds in under 1 second, costs $0/month to host, and is served from Cloudflare’s global edge network. ...

February 8, 2026 · 5 min · Nitin

Resolving CORS Errors When Fetching Images from AWS S3 with Signed URLs

If you’re displaying images stored in an AWS S3 private bucket using signed URLs, you might have encountered a confusing scenario: images display perfectly in your web pages but throw CORS errors when you try to download them using JavaScript’s fetch API. Let’s break down the issue and explore a practical solution. Understanding the Problem Imagine you have your images securely stored in a private S3 bucket, and you’re using pre-signed URLs to grant temporary access: ...

June 29, 2025 · 3 min · Nitin

Building Robust Systems: Key Lessons from Designing Data-Intensive Applications Chapter 1

Introduction If you’re involved in building software today, chances are you’re dealing with data. Lots of it. Maybe it’s user activity, sensor readings, financial transactions, or something else entirely. Martin Kleppmann’s phenomenal book, “Designing Data-Intensive Applications” (often called DDIA), is practically required reading for navigating this landscape. Let’s dive into some key takeaways from this essential chapter. The Shift: It’s About the Data, Not Just the CPU The chapter opens by highlighting a crucial distinction: many modern applications are data-intensive, not compute-intensive. While CPU power is abundant, the real challenges often lie in: ...

May 4, 2025 · 5 min · Nitin

WebRTC Signaling & Connection Establishment

What is Signaling in WebRTC, and Why is it Needed? WebRTC allows direct peer-to-peer (P2P) communication, but before two peers can connect, they need to exchange network and media information. This process is called signaling. Signaling is needed for: Exchanging session descriptions (SDP – Session Description Protocol) between peers. Sharing ICE candidates to determine the best network path. Handling NAT traversal by identifying public and private network addresses. Establishing data channels for text, files, and other non-media communication. WebRTC does not define a signaling protocol. Developers must implement their own using available technologies like WebSockets, WebRTC Data Channels, or existing protocols like SIP. ...

February 7, 2025 · 4 min · Nitin

WebRTC Fundamentals

WebRTC (Web Real-Time Communication) is an open-source project that enables real-time communication between browsers and devices using peer-to-peer connections. It allows audio, video, and data sharing without requiring additional plugins or external software. How Does WebRTC Work? WebRTC works by establishing a direct connection between two peers (browsers or applications) to transmit media (audio/video) and data. The connection process involves several steps: Media Capture – A user’s camera and microphone are accessed. Signaling – Exchanging connection details between peers via a signaling server (e.g., using WebSockets). ICE Candidate Discovery – Finding the best network path between peers. Connection Establishment – Securely connecting the peers. Data Transmission – Streaming audio/video or sending arbitrary data. 2. Main Components of WebRTC WebRTC consists of three primary components: ...

February 7, 2025 · 3 min · Nitin

Building ARM64 Docker Images on x86_64 Machines Using QEMU and Docker Buildx

Introduction In the world of software development, the ability to build and deploy applications across different architectures is invaluable. This capability becomes particularly essential when dealing with ARM-based applications such as those for embedded systems or newer ARM-based servers. In this blog post, we will explore how to build ARM64 Docker container images on an x86_64 machine using QEMU emulation and Docker’s buildx tool. Understanding the Challenge The main challenge in building Docker images for a different architecture than your host machine lies in the architecture-specific binaries and dependencies. Directly running ARM binaries on an x86_64 machine is not possible without emulation due to differences in architecture instruction sets. ...

May 11, 2024 · 4 min · Nitin