<?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"><channel><title><![CDATA[Bicep Heart Build Log]]></title><description><![CDATA[Bicep Heart Build Log]]></description><link>https://bicepheart.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Dec 2026 22:04:54 GMT</lastBuildDate><atom:link href="https://bicepheart.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[I built a fixed-routine AI video tool on Cloudflare Workers — here's the architecture]]></title><description><![CDATA[The "Bicep Heart" is a TikTok/Reels pose trend: you flex a bicep and touch it with your opposite hand to form a heart-shaped gap. People keep asking how to…]]></description><link>https://bicepheart.hashnode.dev/i-built-a-fixed-routine-ai-video-tool-on-cloudflare-workers-here-s-the-architecture</link><guid isPermaLink="true">https://bicepheart.hashnode.dev/i-built-a-fixed-routine-ai-video-tool-on-cloudflare-workers-here-s-the-architecture</guid><category><![CDATA[cloudflare]]></category><category><![CDATA[AI]]></category><category><![CDATA[webdev]]></category><category><![CDATA[indie-hacker]]></category><dc:creator><![CDATA[Qian Gao]]></dc:creator><pubDate>Thu, 12 Nov 2026 16:12:32 GMT</pubDate><content:encoded><![CDATA[<p>The "Bicep Heart" is a TikTok/Reels pose trend: you flex a bicep and touch it with your opposite hand to form a heart-shaped gap. People keep asking how to make one of <em>themselves</em> without learning the routine and filming it. So I built <strong>Bicep Heart</strong> — a browser tool that turns one photo of a person into a 7-second vertical video of them doing the pose.</p>
<p>The interesting engineering problem wasn't the AI. It was making a <em>paid</em> render reliable.</p>
<h2>Why not just prompt a video model?</h2>
<p>Text-prompt video models improvise. Tell one "a person doing the bicep heart pose" and you get a different framing, timing, and camera angle every time. Trend clips live or die on consistency — same pose, same timing, same camera as the original.</p>
<p>So instead of prompting, Bicep Heart uses a <strong>fixed reference routine</strong>: one reference clip of the exact pose + motion, and the user's uploaded photo. The motion is transferred from the reference via Kling v2.6 Motion Control (image-to-video with reference video). Output framing is identical every time because it comes from the clip, not from a prompt.</p>
<h2>The stack</h2>
<ul>
<li><strong>Cloudflare Workers + TanStack Start</strong> for SSR</li>
<li><strong>D1</strong> (SQLite at the edge) for the credit ledger and orders</li>
<li><strong>R2</strong> for input photos and finished videos</li>
<li><strong>Queues + Dead Letter Queue + a 5-minute cron</strong> for async rendering and reconciliation</li>
<li><strong>Kling v2.6 via APIMart</strong> as the video provider (~$0.40 per render)</li>
<li><strong>Dodo Payments</strong> as merchant of record (handles tax/VAT)</li>
</ul>
<h2>The real problem: paid renders fail</h2>
<p>A render costs real money and the user has already paid (in credits). But renders fail for reasons outside our control:</p>
<ul>
<li>The provider rejects the media (e.g. the reference requires a full upper-body person; an animal photo gets refused)</li>
<li>Network/timeout errors mid-job</li>
<li>Provider 5xx</li>
</ul>
<p>If a paid render fails, the user must get their credits back <strong>automatically and exactly once</strong> — no double-charges, no silent losses.</p>
<h2>The reliability architecture</h2>
<pre><code class="language-plaintext">upload → charge credits (ledger + idempotency key)
      → enqueue render job
Worker: submit to provider → poll task
      → success: store to R2, fire webhook, mark done
      → failure: send to DLQ
Cron (every 5 min): scan DLQ + stuck jobs
      → refund credits (idempotent) + notify
</code></pre>
<p>Two things make this safe:</p>
<ol>
<li><strong>Idempotency keys everywhere.</strong> Credits are charged as a <code>credit_grants</code> batch + <code>credit_ledger</code> row behind a unique idempotency key. A retried submit can't double-charge. Refunds are the same — keyed so a job retried by the cron can't refund twice.</li>
<li><strong>Ledger, not a counter.</strong> "Credits" is never a single column you <code>UPDATE</code>. It's a ledger of deltas. Consumption checks the ledger balance, so a desync can't leave a user negative or let them render for free.</li>
</ol>
<p>The DLQ + cron reconciliation means even if the worker dies mid-render, the credits come back within 5 minutes. Users see "render failed, credits refunded" instead of "where did my money go."</p>
<h2>Why Cloudflare</h2>
<p>The whole thing runs on one bill: Workers for compute, D1 for the ledger, R2 for video storage, Queues for the async pipeline. No separate message broker, no object-store bill, no region hopping. For a solo maker shipping a paid product, that operational simplicity is the feature.</p>
<h2>Numbers</h2>
<ul>
<li>Cost to render: ~$0.40 (provider) → sold at $4.99 for 7 credits (one 7s render), healthy margin</li>
<li>First-week organic (zero promotion): 414 Google impressions, 8 clicks, 34 pages indexed</li>
</ul>
<h2>Try it</h2>
<p>The tool is live at <a href="https://bicepheart.site"><strong>https://bicepheart.site</strong></a> (Google sign-in, EN/CN UI, $4.99 starter pack). I wrote up the first-week numbers and the full build here: <a href="https://dev.to/steveaipro/i-built-a-tool-that-recreates-the-bicep-heart-trend-from-one-photo-week-one-numbers-inside-2fkj">https://dev.to/steveaipro/i-built-a-tool-that-recreates-the-bicep-heart-trend-from-one-photo-week-one-numbers-inside-2fkj</a></p>
<p>If you're building a paid AI product on Cloudflare, the queue + DLQ + cron refund pattern above is the part worth stealing.</p>
]]></content:encoded></item></channel></rss>