<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Takbir</title>
    <description>The latest articles on DEV Community by Takbir (@takbirzaman).</description>
    <link>https://dev.to/takbirzaman</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4286092%2F242db09a-fed8-4fd0-97ec-f70492dd39e2.png</url>
      <title>DEV Community: Takbir</title>
      <link>https://dev.to/takbirzaman</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/takbirzaman"/>
    <language>en</language>
    <item>
      <title>Offline-first is a queue problem, not a caching problem</title>
      <dc:creator>Takbir</dc:creator>
      <pubDate>Sun, 06 Dec 2026 10:18:22 +0000</pubDate>
      <link>https://dev.to/takbirzaman/offline-first-is-a-queue-problem-not-a-caching-problem-422n</link>
      <guid>https://dev.to/takbirzaman/offline-first-is-a-queue-problem-not-a-caching-problem-422n</guid>
      <description>&lt;p&gt;Most "offline support" implementations are caches. They store the last response and show it when the network is down. That works for reading. It fails for writing, because a write has to survive, in order, and reach the server later.&lt;/p&gt;

&lt;p&gt;An offline-first app is a queue with a UI attached.&lt;/p&gt;

&lt;h2&gt;
  
  
  The shape that works
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;The user action writes to local storage first.&lt;/li&gt;
&lt;li&gt;The same write is appended to a queue with a stable local id.&lt;/li&gt;
&lt;li&gt;The UI confirms immediately; it does not wait for the network.&lt;/li&gt;
&lt;li&gt;A sync worker drains the queue in order when connectivity returns.&lt;/li&gt;
&lt;li&gt;Each item is retried until it succeeds or is explicitly marked failed.&lt;/li&gt;
&lt;li&gt;The server treats the local id as an idempotency key, so a retry after a timeout does not create a duplicate.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The critical detail is step 1 happening before step 3. If the UI says "saved" and the write is only in memory, a crash loses it. If the write is on disk, the promise is true.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ordering and duplicates are the hard parts
&lt;/h2&gt;

&lt;p&gt;Two writes to the same record, made offline, must arrive in the order the user made them. A queue gives that for free if it is drained sequentially. Firing them in parallel does not.&lt;/p&gt;

&lt;p&gt;Duplicates come from the network, not the user. A request can succeed on the server and still time out on the phone. Without an idempotency key, the retry writes the row twice. With one, the second attempt is a no-op that returns success.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to test
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Airplane mode, create three records, force-quit, reopen, go online. All three should sync once, in order.&lt;/li&gt;
&lt;li&gt;Create a record, disable the network mid-request, then re-enable. The record should exist exactly once.&lt;/li&gt;
&lt;li&gt;Two devices editing the same record offline. Decide the conflict rule before shipping; last-write-wins is a choice, not a default.&lt;/li&gt;
&lt;li&gt;Kill the app during sync. On restart, the queue should resume without skipping an item.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the app only tests the happy path, none of these are covered.&lt;/p&gt;

&lt;h2&gt;
  
  
  The app I built with this pattern
&lt;/h2&gt;

&lt;p&gt;Daily Cash is an Android ledger built in Flutter with a write-ahead queue in front of Supabase. Entries are written locally first, replayed when connectivity returns, and exported to PDF and Excel on the device. The schema includes row-level security so each user's data is isolated in their own Supabase project.&lt;/p&gt;

&lt;p&gt;Source is $15 with a commercial licence: &lt;a href="https://takbirzaman.gumroad.com/l/daily-cash" rel="noopener noreferrer"&gt;https://takbirzaman.gumroad.com/l/daily-cash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The pattern is more important than the app: write first, queue the write, sync in order, make retries idempotent. Do that and "offline support" stops being a spinner with a warning.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>mobile</category>
      <category>architecture</category>
      <category>offline</category>
    </item>
    <item>
      <title>A document Q&amp;A demo proves nothing unless it shows its sources</title>
      <dc:creator>Takbir</dc:creator>
      <pubDate>Sun, 06 Dec 2026 09:49:42 +0000</pubDate>
      <link>https://dev.to/takbirzaman/a-document-qa-demo-proves-nothing-unless-it-shows-its-sources-1l9h</link>
      <guid>https://dev.to/takbirzaman/a-document-qa-demo-proves-nothing-unless-it-shows-its-sources-1l9h</guid>
      <description>&lt;p&gt;Every "chat with your PDFs" demo looks good in a screenshot. Ask a question, get a confident paragraph. The screenshot does not tell you whether the answer came from the document or from the model's memory.&lt;/p&gt;

&lt;p&gt;For document work that matters, contracts, policies, reports, citations are the product. An answer you cannot check is a liability, not a feature.&lt;/p&gt;

&lt;h2&gt;
  
  
  What grounding actually requires
&lt;/h2&gt;

&lt;p&gt;Three things have to be true before an answer is trustworthy:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The retrieved passages are relevant.&lt;/strong&gt; If retrieval returns the wrong pages, a fluent answer is still wrong. Retrieval quality is the ceiling on answer quality.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The answer is constrained to the passages.&lt;/strong&gt; The prompt has to say: use only this context; if the context does not contain the answer, say so.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The passages are shown with the answer.&lt;/strong&gt; Not a link at the bottom. The specific chunks, with their source file and a usable excerpt.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The third one is the one most demos skip, and it is the cheapest to implement.&lt;/p&gt;

&lt;h2&gt;
  
  
  A practical structure
&lt;/h2&gt;

&lt;p&gt;A small local RAG app can be built without a vector database, which removes a lot of setup for personal and small-team use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Split documents into overlapping chunks, for example 800 characters with 100 characters of overlap, so a sentence is not cut in half at a boundary.&lt;/li&gt;
&lt;li&gt;Keep the chunk text and its source label together from the start. Retrofitting provenance later is painful.&lt;/li&gt;
&lt;li&gt;On each question, score chunks against the question, take the top few, and pass only those to the model.&lt;/li&gt;
&lt;li&gt;Instruct the model to answer from context only, and to reply "not in the provided documents" when the context does not cover it.&lt;/li&gt;
&lt;li&gt;Render the sources next to the answer, so a reader can open the chunk and check.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The honesty rule matters more than the model choice. A smaller model that says "I do not know" is more useful than a larger one that invents a clause.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the documents go
&lt;/h2&gt;

&lt;p&gt;This is the question buyers ask first, and it deserves a precise answer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With a local app, documents stay on the machine running it.&lt;/li&gt;
&lt;li&gt;Only the retrieved passages are sent to the model API for that question.&lt;/li&gt;
&lt;li&gt;No third-party vector store receives the corpus.&lt;/li&gt;
&lt;li&gt;The API key is the user's own, so billing and access sit with them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If any of those is not true, say so on the product page. "Private" is not a marketing adjective; it is an architecture claim that can be checked.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to test before trusting it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Ask a question whose answer is in one paragraph. Confirm the shown source contains that paragraph.&lt;/li&gt;
&lt;li&gt;Ask a question the documents do not answer. The correct behaviour is a refusal, not a guess.&lt;/li&gt;
&lt;li&gt;Ask a question with two plausible passages. Confirm the answer does not merge them into something neither says.&lt;/li&gt;
&lt;li&gt;Search for a name that appears in a different document. Confirm retrieval does not pull the wrong file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These four checks catch most of the failure modes that a demo screenshot hides.&lt;/p&gt;

&lt;h2&gt;
  
  
  The version I packaged
&lt;/h2&gt;

&lt;p&gt;I built a local document Q&amp;amp;A app in Streamlit, with retrieval in-process and answers through the user's own Anthropic key. It shows the source passages next to every answer, and the README covers setup, usage and the limits. It is intentionally small: one Python file you can read before you run it.&lt;/p&gt;

&lt;p&gt;Source is $19 with an MIT licence: &lt;a href="https://takbirzaman.gumroad.com/l/rag-chatbot" rel="noopener noreferrer"&gt;https://takbirzaman.gumroad.com/l/rag-chatbot&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You do not need this specific app. You do need the source panel. If your document assistant cannot show you where an answer came from, treat the answer as a draft, not a fact.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>rag</category>
      <category>python</category>
    </item>
    <item>
      <title>Three ways webhook integrations lose events (and how to test for each)</title>
      <dc:creator>Takbir</dc:creator>
      <pubDate>Sun, 06 Dec 2026 09:46:58 +0000</pubDate>
      <link>https://dev.to/takbirzaman/three-ways-webhook-integrations-lose-events-and-how-to-test-for-each-3h56</link>
      <guid>https://dev.to/takbirzaman/three-ways-webhook-integrations-lose-events-and-how-to-test-for-each-3h56</guid>
      <description>&lt;p&gt;Most webhook bugs are not receiving bugs. The request arrived. The handler ran. Something after that point quietly dropped the event, and nobody found out until a customer asked where their order was.&lt;/p&gt;

&lt;p&gt;These are the three failure modes I see most often, each with a test you can run in a few minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The sender gives up after one failure
&lt;/h2&gt;

&lt;p&gt;The target returns 503 because a deploy is rolling, or the database is briefly locked. The sender retries twice in ten seconds, gives up, and marks the event delivered. The event is gone.&lt;/p&gt;

&lt;p&gt;The fix is not "retry more". It is to acknowledge the event, persist it, and retry from a queue with backoff:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Return &lt;code&gt;2xx&lt;/code&gt; only after the event is stored.&lt;/li&gt;
&lt;li&gt;Treat &lt;code&gt;408&lt;/code&gt;, &lt;code&gt;425&lt;/code&gt;, &lt;code&gt;429&lt;/code&gt; and &lt;code&gt;5xx&lt;/code&gt; as transient; retry with exponential backoff and jitter.&lt;/li&gt;
&lt;li&gt;Treat other &lt;code&gt;4xx&lt;/code&gt; as permanent; move the event to a dead-letter queue instead of retrying forever.&lt;/li&gt;
&lt;li&gt;Set a maximum attempt count and make the last error visible.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Test it:&lt;/strong&gt; run a target that returns &lt;code&gt;503&lt;/code&gt; for the first two requests and &lt;code&gt;200&lt;/code&gt; afterwards. Send one signed event, then inspect the stored event. You should see &lt;code&gt;attempts: 2&lt;/code&gt; and &lt;code&gt;last_error&lt;/code&gt; mentioning the 503 before it reaches &lt;code&gt;done&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;BaseHTTPRequestHandler&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;HTTPServer&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="n"&gt;calls&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;H&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;BaseHTTPRequestHandler&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;do_POST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="n"&gt;calls&lt;/span&gt;
        &lt;span class="n"&gt;calls&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Content-Length"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"0"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;calls&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send_response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;503&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end_headers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s2"&gt;"down"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send_response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send_header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"application/json"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end_headers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wfile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"ok"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;log_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="nc"&gt;HTTPServer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"127.0.0.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8788&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;H&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;serve_forever&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your integration never retries, this test fails on the first request and the event disappears. That is the bug.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The same event runs twice
&lt;/h2&gt;

&lt;p&gt;Senders retry. Networks duplicate. A timeout on the sender side does not mean the target did not process the request. If the handler is not idempotent, a retry becomes a second order, a second email, or a second charge.&lt;/p&gt;

&lt;p&gt;Deduplication has to happen before the side effect, using a stable key supplied by the sender:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prefer the sender's event id header, for example &lt;code&gt;X-Event-Id&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Fall back to a hash of the raw body when the sender has no id.&lt;/li&gt;
&lt;li&gt;Store the key with a unique constraint, and return success on a duplicate without running the work again.&lt;/li&gt;
&lt;li&gt;Keep the raw body, because the signature is computed over the exact bytes, not the parsed JSON.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Test it:&lt;/strong&gt; send the same event twice with the same &lt;code&gt;X-Event-Id&lt;/code&gt;. The first response should be &lt;code&gt;202 accepted&lt;/code&gt;; the second should be &lt;code&gt;200 duplicate&lt;/code&gt;, and the target should see exactly one delivery.&lt;/p&gt;

&lt;p&gt;A handler that parses JSON, re-serialises it and then verifies the signature will fail this test for a different reason: the bytes changed. Verify against the raw body.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. The signature check is not replay-safe
&lt;/h2&gt;

&lt;p&gt;Verifying an HMAC proves the request was signed with the shared secret. It does not prove the request is new. A captured request can be replayed later, and a correct signature will still match.&lt;/p&gt;

&lt;p&gt;Two things are needed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sign a timestamp together with the body, for example &lt;code&gt;HMAC(secret, "{timestamp}.{body}")&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Reject timestamps outside a short window, five minutes is typical.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Test it:&lt;/strong&gt; sign a request with a timestamp ten minutes in the past. A correct implementation returns &lt;code&gt;401&lt;/code&gt;. Then replay a fresh, correctly signed request twice. The signature passes both times; the dedupe layer is what stops the second one from running.&lt;/p&gt;

&lt;p&gt;These are separate controls. Signature verification answers "who sent this". Replay protection answers "when was this sent". Idempotency answers "has this already been handled".&lt;/p&gt;

&lt;h2&gt;
  
  
  The order that matters
&lt;/h2&gt;

&lt;p&gt;The sequence inside the handler decides whether failures are recoverable:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Read the raw body.&lt;/li&gt;
&lt;li&gt;Verify signature and timestamp window.&lt;/li&gt;
&lt;li&gt;Check the dedupe key.&lt;/li&gt;
&lt;li&gt;Persist the event.&lt;/li&gt;
&lt;li&gt;Return &lt;code&gt;202&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Do the work asynchronously.&lt;/li&gt;
&lt;li&gt;On failure, retry with backoff or move to the dead-letter queue.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If step 5 happens before step 4, a crash between them loses the event. If step 6 happens before step 5, a slow target turns into sender timeouts and duplicate deliveries.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I built from this
&lt;/h2&gt;

&lt;p&gt;I packaged the pattern as a small self-hosted gateway, HookDesk. It is a FastAPI service with SQLite as the queue, so there is no broker to operate. It verifies HMAC-SHA256 signatures with a five-minute window, deduplicates by &lt;code&gt;X-Event-Id&lt;/code&gt;, retries transient failures with backoff and jitter, and exposes a dead-letter queue plus an admin API for stats and manual retries. There is a Dockerfile, tests, and a sender CLI for the tests above.&lt;/p&gt;

&lt;p&gt;It runs with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uv run uvicorn hookdesk.main:create_app --factory --port 8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Source licence is $29: &lt;a href="https://takbirzaman.gumroad.com/l/hookdesk" rel="noopener noreferrer"&gt;https://takbirzaman.gumroad.com/l/hookdesk&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you only have one endpoint and one retry, you may not need a gateway. The three tests above are still worth running against whatever you have, because each one fails silently today.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>webhooks</category>
      <category>python</category>
      <category>api</category>
    </item>
  </channel>
</rss>
