<?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: skyler</title>
    <description>The latest articles on DEV Community by skyler (@skyler_7abb6ba5f692ca05e6).</description>
    <link>https://dev.to/skyler_7abb6ba5f692ca05e6</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%2F2689943%2Fa688a0f2-9cb5-4bbe-a42d-170bd3627520.png</url>
      <title>DEV Community: skyler</title>
      <link>https://dev.to/skyler_7abb6ba5f692ca05e6</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/skyler_7abb6ba5f692ca05e6"/>
    <language>en</language>
    <item>
      <title>Building an AI Clothes Changer on Cloudflare Workers</title>
      <dc:creator>skyler</dc:creator>
      <pubDate>Mon, 30 Nov 2026 12:58:45 +0000</pubDate>
      <link>https://dev.to/skyler_7abb6ba5f692ca05e6/building-an-ai-clothes-changer-on-cloudflare-workers-l2f</link>
      <guid>https://dev.to/skyler_7abb6ba5f692ca05e6/building-an-ai-clothes-changer-on-cloudflare-workers-l2f</guid>
      <description>&lt;p&gt;Most AI photo tools start as a single &lt;code&gt;POST&lt;/code&gt; that blocks until the image comes back. That works in a notebook. It falls apart the moment a real user closes the tab, hits refresh, or double-taps the generate button — and it falls apart harder when money is involved, because now you have to answer "was this person charged?" with certainty, not with a guess.&lt;/p&gt;

&lt;p&gt;I recently shipped &lt;a href="https://ai-clothes-changer.net" rel="noopener noreferrer"&gt;AI Clothes Changer&lt;/a&gt;, a tool that takes a photo of a person and a photo of a garment and re-renders the outfit in place. It runs entirely on Cloudflare Workers, with D1 as the database and R2 for storage. This post is about the five pieces that actually took the time: the async job model, the credit ledger, the webhook, the polling fallback, and the storage move.&lt;/p&gt;

&lt;p&gt;Nothing here is exotic. It's the boring plumbing that separates a demo from a product.&lt;/p&gt;

&lt;h2&gt;
  
  
  The shape of the problem
&lt;/h2&gt;

&lt;p&gt;One generation looks like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A logged-in user uploads two images (person + garment) and picks a mode.&lt;/li&gt;
&lt;li&gt;The server submits a job to a hosted model provider and gets back a prediction ID.&lt;/li&gt;
&lt;li&gt;Somewhere between 10 and 60 seconds later, the provider finishes and notifies you.&lt;/li&gt;
&lt;li&gt;The image URL it hands you is temporary. You need to copy the bytes to your own storage.&lt;/li&gt;
&lt;li&gt;If it fails or times out, the user gets their credits back.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Steps 2 through 5 are all asynchronous, and every one of them can be delivered twice, delivered late, or not delivered at all. That's the whole design constraint. Everything below follows from it.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Pre-deduct, don't post-deduct
&lt;/h2&gt;

&lt;p&gt;The intuitive order is: generate first, charge on success. It reads as friendlier, and it's wrong.&lt;/p&gt;

&lt;p&gt;On a serverless platform you have no admission control. Ten concurrent requests from the same account all hit the balance check at the same instant, all see the same balance, all pass, and all generate. By the time you go to deduct, nine of them have already spent real GPU time on the provider's side. You eat the cost, or you show the user a negative balance.&lt;/p&gt;

&lt;p&gt;So the order is inverted: create the job record, deduct the credits, &lt;em&gt;then&lt;/em&gt; submit to the provider. If the submit fails, refund. The user is briefly charged for something that may not happen, and the refund path puts it back.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// create the job first — the job id becomes the idempotency key&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;createGenerationJob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;creditCost&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="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;await&lt;/span&gt; &lt;span class="nf"&gt;consumeCredits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;creditCost&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'clothes-generation'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;idempotencyKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`clothes-generation:${job.id}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;generationJobId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;phase&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'preauth'&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="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key detail is &lt;code&gt;idempotencyKey: \&lt;/code&gt;clothes-generation:${job.id}``. It isn't a random UUID per request — it's derived from the job. If the client retries the request and ends up on the same job, the ledger refuses the second write. If two different requests somehow produce two jobs, they produce two keys, and that's correct too.&lt;/p&gt;

&lt;p&gt;A second guard sits at the database level: one active job per user, enforced by a partial unique index rather than application logic.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`sql&lt;br&gt;
CREATE UNIQUE INDEX clothes_generation_active_user_unique&lt;br&gt;
  ON clothes_generation (user_id, status)&lt;br&gt;
  WHERE status IN ('queued', 'generating');&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Two concurrent submissions race, one &lt;code&gt;INSERT&lt;/code&gt; loses, and the loser returns &lt;code&gt;409&lt;/code&gt; with the existing job — no charge, no second render. The application checks for an active job first for a clean error message, but the index is what actually guarantees it. Checks are advisory; constraints are law.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. D1 has no interactive transactions
&lt;/h2&gt;

&lt;p&gt;This is the part that surprised me most. D1 gives you &lt;code&gt;batch()&lt;/code&gt;, which runs a list of statements in a single implicit transaction, but it does not give you an interactive transaction — you can't &lt;code&gt;SELECT&lt;/code&gt;, branch in JavaScript, and then &lt;code&gt;UPDATE&lt;/code&gt; with the guarantee that nothing changed in between.&lt;/p&gt;

&lt;p&gt;The usual read-modify-write pattern is therefore unsafe:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`plaintext&lt;br&gt;
read balance  →  check balance &amp;gt;= cost  →  write balance - cost&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Between the check and the write, another request can spend the same credits.&lt;/p&gt;

&lt;p&gt;The fix is to push the conditional into the SQL itself, so the check and the write are one statement. Here's the actual deduction, abridged:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`sql&lt;br&gt;
INSERT INTO credit_ledger&lt;br&gt;
  (id, user_id, amount, balance_after, type, source_id, idempotency_key, metadata, created_at)&lt;br&gt;
SELECT ?, ?, ?, COALESCE((SELECT balance FROM credit_balance WHERE user_id = ?), 0) - ?,&lt;br&gt;
       'consume', 'clothes-generation', ?, ?, ?&lt;br&gt;
WHERE COALESCE((SELECT balance FROM credit_balance WHERE user_id = ?), 0) - ? &amp;gt;= 0;&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;WHERE ... &amp;gt;= 0&lt;/code&gt; clause makes the insert a no-op when the balance is too low. The ledger row simply doesn't appear. Then the balance update is gated on whether that row exists:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`sql&lt;br&gt;
UPDATE credit_balance&lt;br&gt;
SET balance = balance - ?, expiring = MAX(0, expiring - ?), updated_at = ?&lt;br&gt;
WHERE user_id = ? AND EXISTS (SELECT 1 FROM credit_ledger WHERE id = ?);&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Two statements in one &lt;code&gt;batch()&lt;/code&gt;. If the first inserts nothing, the second updates nothing. There is no window where a balance goes negative, and no &lt;code&gt;SELECT&lt;/code&gt; that can go stale, because there is no separate read step to go stale.&lt;/p&gt;

&lt;p&gt;The balance itself has two compartments: subscription credits that expire at the end of the billing period, and purchased or granted credits that never expire. Both live in one row (&lt;code&gt;balance&lt;/code&gt; total, &lt;code&gt;expiring&lt;/code&gt; subset), and consumption drains the expiring portion first — which keeps &lt;code&gt;MAX(0, ...)&lt;/code&gt; meaningful in the update above.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Webhooks are signed — verify them properly
&lt;/h2&gt;

&lt;p&gt;The provider signs its callbacks. Verifying the signature is not optional: your webhook endpoint is public, and a forged callback can mark a job as succeeded and skip a refund, or mark it failed and trigger one.&lt;/p&gt;

&lt;p&gt;The signature is detached Ed25519 over a message built from the request ID, a user ID, a timestamp, and a hash of the raw body:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`ts&lt;br&gt;
function buildFalWebhookMessage({ requestId, userId, timestamp, rawBody }) {&lt;br&gt;
  const bodyHash = createHash('sha256').update(rawBody).digest('hex')&lt;br&gt;
  return Buffer.from(&lt;br&gt;
    [requestId, userId, timestamp, bodyHash].join('\n'),&lt;br&gt;
    'utf-8',&lt;br&gt;
  )&lt;br&gt;
}&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Three things about that construction matter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hash the raw bytes before parsing.&lt;/strong&gt; Parsing first and re-serializing will change whitespace and key order, and the signature will never match. Read &lt;code&gt;arrayBuffer()&lt;/code&gt; once, verify, then parse.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Include the timestamp in the signed payload&lt;/strong&gt;, and separately reject anything older than a few minutes. A valid signature on a replay is still a replay. Five minutes of leeway covers clock skew without leaving a meaningful window open.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cache the JWKS.&lt;/strong&gt; The public keys live at a well-known endpoint; fetching them on every callback adds latency and a failure mode. Cache for 24 hours and let the key rotation window be bounded.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On Workers, Ed25519 verification goes through WebCrypto. &lt;code&gt;crypto.subtle&lt;/code&gt; accepts the algorithm as &lt;code&gt;NODE-ED25519&lt;/code&gt; with a raw imported key:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`ts&lt;br&gt;
const key = await crypto.subtle.importKey(&lt;br&gt;
  'raw',&lt;br&gt;
  publicKeyBytes,&lt;br&gt;
  { name: 'NODE-ED25519', namedCurve: 'NODE-ED25519' },&lt;br&gt;
  false,&lt;br&gt;
  ['verify'],&lt;br&gt;
)&lt;br&gt;
const ok = await crypto.subtle.verify({ name: 'NODE-ED25519' }, key, signature, message)&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;One gotcha worth knowing: if an environment doesn't support that algorithm, &lt;code&gt;importKey&lt;/code&gt; throws. Swallowing the error turns "unsupported runtime" into "invalid signature", which is a miserable thing to debug at 2 a.m. Return three states instead of two — &lt;code&gt;true&lt;/code&gt;, &lt;code&gt;false&lt;/code&gt;, and &lt;code&gt;null&lt;/code&gt; for "couldn't try" — and let the caller decide to fall back to a WASM implementation.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Assume the webhook never arrives
&lt;/h2&gt;

&lt;p&gt;Webhooks get lost. The provider retries, but retries are best-effort, and your endpoint can be down, rate-limited, or replaced mid-deploy. If the callback is your only settlement path, those jobs sit in &lt;code&gt;generating&lt;/code&gt; forever and the user's credits are stuck behind a spinner.&lt;/p&gt;

&lt;p&gt;So the client polls, and the poll endpoint doubles as the recovery path:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`plaintext&lt;br&gt;
GET /api/clothes/:jobId&lt;br&gt;
  → if status is queued or generating, ask the provider directly&lt;br&gt;
  → update the job, settle credits, trigger storage move&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Both paths share the same settlement code, and both are protected by the idempotency keys from earlier. Whichever arrives first wins; the second is a no-op. That's the real payoff of keying everything to the job ID — you don't need to coordinate the two paths, you just need both of them to be individually safe to run twice.&lt;/p&gt;

&lt;p&gt;There's also a deadline. A job that hasn't settled in five minutes is marked failed, with the same refund idempotency key as the failure branch of the webhook:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`ts&lt;br&gt;
await refundCredits({&lt;br&gt;
  userId,&lt;br&gt;
  amount: job.creditCost,&lt;br&gt;
  idempotencyKey: `clothes-generation-refund:${job.id}`,&lt;br&gt;
  metadata: { generationJobId: job.id, reason: 'generation-timeout' },&lt;br&gt;
})&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Because the key is shared, a late success callback after a timeout refund won't double-credit the user. I chose to let the late callback skip the re-charge rather than claw credits back — when in doubt, the error should favor the person paying.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. The output URL is temporary. Move it.
&lt;/h2&gt;

&lt;p&gt;The provider returns something like &lt;code&gt;https://queue.fal.run/.../output.jpg&lt;/code&gt;. That URL is fine for a minute and useless for a year. Persisting it in your database means every old generation in the user's history eventually renders as a broken image.&lt;/p&gt;

&lt;p&gt;So on success, the bytes are copied to R2 and the permanent URL is what gets stored:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`plaintext&lt;br&gt;
fal temp URL  →  fetch  →  R2 put  →  public CDN URL recorded on the job&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The naive version of this has two bugs. First, the webhook and the polling fallback can both trigger the copy for the same job, uploading the same images twice under the same keys. Second, the copy runs after the response is returned, so on Workers it lives in &lt;code&gt;waitUntil&lt;/code&gt; — and &lt;code&gt;waitUntil&lt;/code&gt; work is not guaranteed to finish. Isolates get recycled mid-flight, deploys roll over, R2 hiccups.&lt;/p&gt;

&lt;p&gt;For the duplicate problem, a short lease: if the job is already marked &lt;code&gt;persisting&lt;/code&gt; and the last attempt was under two minutes ago, skip. For the dropped-work problem, a lazy reconciler — every request tries to backfill the oldest one or two jobs whose status is &lt;code&gt;succeeded&lt;/code&gt; but &lt;code&gt;persistenceStatus&lt;/code&gt; isn't &lt;code&gt;persisted&lt;/code&gt;. It's not a cron job, it's not a queue with a dead-letter handler, and it costs one indexed query on a path that's already hitting the database. Traffic does the work, and the backlog converges on its own.&lt;/p&gt;

&lt;p&gt;I could have reached for Queues or Durable Objects here. For this volume, a lease plus a lazily-drained backlog was less machinery for the same outcome. If the reconcile query ever starts showing a persistent backlog, that's the signal to graduate — not before.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things I'd tell my earlier self
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Every async boundary is a duplicate-delivery problem.&lt;/strong&gt; Job ID as idempotency key, everywhere, from the ledger to the refund to the storage copy. This one decision eliminated an entire category of bugs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Put the invariant in the database, not the handler.&lt;/strong&gt; The partial unique index and the &lt;code&gt;WHERE balance &amp;gt;= 0&lt;/code&gt; clause can't be forgotten, bypassed, or raced. Application-level checks are documentation with a runtime cost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't trust a URL you didn't mint.&lt;/strong&gt; Provider output URLs are ephemeral. Copy on success, keep the key, and make the copy idempotent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Two settlement paths, one settlement function.&lt;/strong&gt; If the webhook and the poller have separate code, they will drift apart and you'll get settlement bugs that only appear on the path you didn't test.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fail open on moderation, but leave a trace.&lt;/strong&gt; Uploaded images get an NSFW check before generation. When the moderation service is unavailable, the request is allowed through and recorded as &lt;code&gt;unverified&lt;/code&gt; — blocking every upload during a third-party outage punishes users for someone else's downtime, but silent fail-open means you can't audit it later.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The product, briefly
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ai-clothes-changer.net" rel="noopener noreferrer"&gt;AI Clothes Changer&lt;/a&gt; is the app that came out of this. Upload a photo of yourself and a photo of a garment, and it rebuilds the clothing on the same person — face, pose, and the photo's original lighting stay put.&lt;/p&gt;

&lt;p&gt;Three modes share the same pipeline with different provider models:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mode&lt;/th&gt;
&lt;th&gt;Credits&lt;/th&gt;
&lt;th&gt;Output&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Preview&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;1 image&lt;/td&gt;
&lt;td&gt;fastest, cheapest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Studio&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;up to 4 variations&lt;/td&gt;
&lt;td&gt;quality mode, best for fabric and pattern detail&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pro&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;1 image&lt;/td&gt;
&lt;td&gt;requires a styling prompt alongside the garment image&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;New accounts get 20 credits on Google sign-up, no card required — enough to run two Preview generations and see whether the results hold up for your photos.&lt;/p&gt;

&lt;p&gt;A few examples of what the pipeline produces:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3hdy2dylxhxkr0sjybvu.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3hdy2dylxhxkr0sjybvu.jpg" alt="Before and after of a man in a maroon suit restyled into a cream suit" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnncgz8hcpy1f92bwdhyd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnncgz8hcpy1f92bwdhyd.jpg" alt="Before and after of a woman restyled into a different dress" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The stack, for anyone curious: TanStack Start on Cloudflare Workers, D1 via Drizzle, R2 with a custom CDN domain, Better Auth for sign-in, and a hosted model provider for the generation itself. The &lt;a href="https://ai-clothes-changer.net/pricing" rel="noopener noreferrer"&gt;pricing page&lt;/a&gt; has the plan details if you want to compare credit costs against your own provider bill.&lt;/p&gt;

&lt;p&gt;If you're building something similar and one of these five problems is the one you're stuck on, the comments are open. The credit ledger in particular is where I'd expect other people's requirements to diverge from mine — a team workspace, for instance, would need pooled balances and a different idempotency story than a per-user one.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>cloudflare</category>
      <category>webdev</category>
      <category>typescript</category>
    </item>
    <item>
      <title>How I Built an AI Photo Restoration App with Next.js, Supabase, and Replicate</title>
      <dc:creator>skyler</dc:creator>
      <pubDate>Thu, 03 Sep 2026 04:36:10 +0000</pubDate>
      <link>https://dev.to/skyler_7abb6ba5f692ca05e6/how-i-built-an-ai-photo-restoration-app-with-nextjs-supabase-and-replicate-55lk</link>
      <guid>https://dev.to/skyler_7abb6ba5f692ca05e6/how-i-built-an-ai-photo-restoration-app-with-nextjs-supabase-and-replicate-55lk</guid>
      <description>&lt;p&gt;A few months ago I dug out a box of family photos from the 80s. Most were faded,&lt;br&gt;
scratched, or had those crease marks where they'd been folded for decades. I tried&lt;br&gt;
fixing them in Photoshop, but I had dozens of them and gave up after the second one.&lt;/p&gt;

&lt;p&gt;So I did what any developer would do: I built a tool for it.&lt;/p&gt;

&lt;p&gt;This post is a technical walkthrough of what I learned building &lt;strong&gt;PixRestorer&lt;/strong&gt; —&lt;br&gt;
an AI photo restoration web app that repairs damaged, blurry, and black-and-white&lt;br&gt;
photos in under 30 seconds. Hopefully the architecture decisions, the edge cases,&lt;br&gt;
and the failure-handling patterns are useful if you're building something similar.&lt;/p&gt;
&lt;h2&gt;
  
  
  The stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Next.js 16&lt;/strong&gt; (App Router, TypeScript)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Supabase&lt;/strong&gt; — Postgres + Auth&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloudflare R2&lt;/strong&gt; — image storage&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replicate&lt;/strong&gt; — the AI models&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloudflare Workers&lt;/strong&gt; — deployment via &lt;code&gt;@opennextjs/cloudflare&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Waffo / Creem&lt;/strong&gt; — payments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The app itself is completely stateless: every dependency (database, auth, AI,&lt;br&gt;
storage, payments) lives outside the app. That's the single most important&lt;br&gt;
architecture decision, and it made deployment trivial.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why serverless, and what it cost me
&lt;/h2&gt;

&lt;p&gt;Initially the app ran on a VPS with PM2. Moving to Cloudflare Workers with OpenNext&lt;br&gt;
removed the server entirely — there is no Node runtime to manage, no &lt;code&gt;sharp&lt;/code&gt; image&lt;br&gt;
processing on the origin (Cloudflare Image Resizing handles it), and rollbacks are&lt;br&gt;
just a DNS change.&lt;/p&gt;

&lt;p&gt;It wasn't free, though. Three things bit me:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Middleware naming.&lt;/strong&gt; In Next 16, &lt;code&gt;proxy.ts&lt;/code&gt; only runs on the Node runtime,
but Workers only support Edge middleware. I had to keep the old &lt;code&gt;middleware.ts&lt;/code&gt;
filename for the Supabase session-refresh logic to work on Workers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Request body limits.&lt;/strong&gt; A 12MB image upload has to make it through the
middleware untouched — worth testing early.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rate limiting.&lt;/strong&gt; In-memory rate limiting is unreliable on Workers. I dropped
it entirely: every image already costs credits via an atomic Postgres RPC, so
the credit balance &lt;em&gt;is&lt;/em&gt; the rate limit.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  The restore pipeline
&lt;/h2&gt;

&lt;p&gt;Here's what happens when a user uploads a photo. It looks simple, but each step&lt;br&gt;
exists to solve a real problem I hit along the way:&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Input validation, including SSRF protection
&lt;/h3&gt;

&lt;p&gt;The API accepts either a data URL (base64 from the browser) or an HTTPS URL. The&lt;br&gt;
URL case was the sneaky one: accepting arbitrary URLs from users is an SSRF hole.&lt;br&gt;
The rule I enforce is that any URL must come &lt;strong&gt;from our own R2 bucket&lt;/strong&gt; — a pre-&lt;br&gt;
signed upload URL the client got from us moments earlier. Anything else is&lt;br&gt;
rejected outright:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isHttpUrl&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="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;hasConfiguredR2PublicUrl&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;R2 public URL is not configured.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;uploadedFileKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;extractKeyFromUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;image&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;uploadedFileKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Invalid image source.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;400&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="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;Credits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;atomic&lt;/span&gt; &lt;span class="nx"&gt;deduction&lt;/span&gt;
&lt;span class="nx"&gt;Each&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="nx"&gt;has&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;credit&lt;/span&gt; &lt;span class="nx"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;Before&lt;/span&gt; &lt;span class="nx"&gt;running&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="nx"&gt;deducts&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;cost&lt;/span&gt; &lt;span class="nx"&gt;atomically&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;database&lt;/span&gt; &lt;span class="err"&gt;—&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;part&lt;/span&gt; &lt;span class="nx"&gt;I&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;m most proud of. Instead of read-check-then-write (which races under concurrency), the deduction is a single SQL update that only succeeds if the balance is sufficient:


sql
UPDATE public.users
SET credits = credits - p_amount, updated_at = NOW()
WHERE id = p_user_id AND credits &amp;gt;= p_amount
RETURNING credits INTO v_remaining;

IF v_remaining IS NULL THEN
  RETURN NULL;  -- insufficient credits
END IF;
Retrying the RPC on transient errors (max 3 attempts, 100ms backoff) made the system resilient against flaky network calls, and NULL cleanly signals "insufficient credits" to the API.

3. Never charge for a failure
The model call happens after deduction. If the model errors, the app refunds the credit immediately — because the user paid for a restored image, not for an error message:


ts
} catch (modelError) {
  await supabase.rpc("refund_credits", { p_user_id: user.id, p_amount: RESTORE_CREDIT_COST });
  throw modelError;
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Clean up after yourself
Uploaded originals are kept temporarily in R2, and the finally block deletes them regardless of what happened. Temp files that pile up are a slow, invisible cost leak.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Moderation before the model&lt;br&gt;
AI image APIs will happily spend your money on anything. I put a moderation gate in front of the restore calls — the prompt and filename are checked before the model runs, so policy violations return a clean 4xx instead of a bill.&lt;/p&gt;

&lt;p&gt;What this costs to run&lt;br&gt;
The restore model runs on Replicate, and costs are per-call. The credit-pricing model (prepaid credits, deducted atomically, refunded on failure) keeps the economics honest: users never pay for a failed request, and I never eat the cost of a successful one.&lt;/p&gt;

&lt;p&gt;Wrapping up&lt;br&gt;
The interesting part of this project wasn't the AI — it was all the boring engineering around it: stateless serverless deployment, atomic money-like arithmetic, SSRF defense, and making sure failures never cost the user anything.&lt;/p&gt;

&lt;p&gt;If you're curious, PixRestorer is live at &lt;a href="https://pixrestorer.com" rel="noopener noreferrer"&gt;pixrestorer.com&lt;/a&gt;&lt;a&gt;. &lt;/a&gt;&lt;/p&gt;
&lt;a&gt;

&lt;p&gt;You can upload one of your own faded photos and see the whole thing end-to-end. I'd love to hear what you think — and if you're building something similar, I'm happy to answer questions about the details I didn't cover here.&lt;/p&gt;

&lt;/a&gt;

</description>
      <category>ai</category>
      <category>fullstack</category>
      <category>nextjs</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Meccha Chameleon Online — A Camouflage Hide-and-Seek Game for Devs' Coffee Breaks</title>
      <dc:creator>skyler</dc:creator>
      <pubDate>Tue, 28 Jul 2026 06:20:09 +0000</pubDate>
      <link>https://dev.to/skyler_7abb6ba5f692ca05e6/meccha-chameleon-online-a-camouflage-hide-and-seek-game-for-devs-coffee-breaks-4hg7</link>
      <guid>https://dev.to/skyler_7abb6ba5f692ca05e6/meccha-chameleon-online-a-camouflage-hide-and-seek-game-for-devs-coffee-breaks-4hg7</guid>
      <description>&lt;p&gt;Every developer knows the feeling: you've been staring at a bug for 45 minutes, your brain is fried, and you need a &lt;strong&gt;complete context switch&lt;/strong&gt; to reset. Not doom-scrolling Twitter, not another cup of coffee — something that actually engages a different part of your brain for 90 seconds, then lets you get back to work.&lt;/p&gt;

&lt;p&gt;I recently stumbled onto a game that fills this niche perfectly: &lt;strong&gt;&lt;a href="https://mecchachameleonplay.com" rel="noopener noreferrer"&gt;Meccha Chameleon Online&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It's a free, browser-based hide-and-seek game where you play as a chameleon that can shift its color to blend into props. An AI hunter patrols the room. You have 90 seconds to survive.&lt;/p&gt;

&lt;p&gt;No download. No account. No Steam client. Open the site, hit play, and you're in.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3890y4fuy20qhrlemeoz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3890y4fuy20qhrlemeoz.png" alt="Meccha Chameleon Online gameplay" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Core Loop (90 Seconds of Pure Focus)
&lt;/h2&gt;

&lt;p&gt;The game follows a tight two-phase structure:&lt;/p&gt;

&lt;h3&gt;
  
  
  Prepare Phase (18 seconds)
&lt;/h3&gt;

&lt;p&gt;The hunter patrols passively. You explore the room, find a colored prop (sofa, plant, bookshelf, wall), and &lt;strong&gt;sample its color&lt;/strong&gt; by pressing &lt;strong&gt;[E]&lt;/strong&gt; on desktop or tapping the sample button on mobile. Your chameleon gradually shifts to match the prop, and a camouflage percentage bar fills up in the HUD.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hunt Phase (90 seconds)
&lt;/h3&gt;

&lt;p&gt;The AI hunter starts actively chasing you. Your camouflage is your only defense:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;≥ 50% camouflage + standing still&lt;/strong&gt; → The hunter's vision is completely blocked. It can walk right past you and not see you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Moving&lt;/strong&gt; caps your camouflage at 25%, making you visible.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Below 50%&lt;/strong&gt; while in the hunter's cone of vision → &lt;code&gt;⚠ SPOTTED&lt;/code&gt; alert flashes red. Run or freeze.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The round ends when either you survive the timer (win) or the hunter touches you (loss).&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Works for Developers
&lt;/h2&gt;

&lt;p&gt;I've been playing this between coding sessions for a week, and here's what makes it click for me:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Zero Friction Entry
&lt;/h3&gt;

&lt;p&gt;There's no "let me install this 20GB game real quick." The site loads in under 2 seconds. I can play one round in 90 seconds and close the tab. It's the same mental model as opening a terminal — fast, focused, disposable.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The Camouflage Mechanic is Surprisingly Strategic
&lt;/h3&gt;

&lt;p&gt;At first glance it looks like a simple hide-and-seek. But the camouflage system adds real depth:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need to &lt;strong&gt;read the room&lt;/strong&gt; during the prepare phase and identify props that offer good cover.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Color matching matters.&lt;/strong&gt; Sampling a bright red sofa when the room is mostly blue means you'll stand out.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Movement vs. stillness&lt;/strong&gt; is a real trade-off. Run to reposition and you lose camouflage; stay still and the hunter might walk right past you.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the kind of lightweight systems-thinking that engages the same part of my brain that enjoys architecture decisions — but without the stakes.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. The AI Hunter Has Clever Design
&lt;/h3&gt;

&lt;p&gt;The hunter isn't just a random walker. It patrols waypoints, switches to chase mode when it spots you, and has a &lt;strong&gt;stuck detection&lt;/strong&gt; system that prevents you from cheesing it by hiding behind obstacles. It also has a "lost target" mechanic — if it doesn't see you for a few seconds, it returns to patrol and you get a green &lt;code&gt;✓ SAFE&lt;/code&gt; indicator.&lt;/p&gt;

&lt;p&gt;From a game development perspective, the hunter AI is a neat example of a finite state machine with smooth transitions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Patrol&lt;/strong&gt; → &lt;strong&gt;Chase&lt;/strong&gt; (triggered by line-of-sight + low camouflage)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Chase&lt;/strong&gt; → &lt;strong&gt;Patrol&lt;/strong&gt; (triggered by distance or time since last sighting)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stuck state&lt;/strong&gt; → Sidestep and retry (prevents wall-hugging exploits)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Controls That Feel Natural
&lt;/h2&gt;

&lt;p&gt;On desktop, the controls are what you'd expect from a browser 3D game:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Key&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;W A S D&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Move&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mouse (click to lock)&lt;/td&gt;
&lt;td&gt;Look / aim&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;A&lt;/code&gt; / &lt;code&gt;D&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Turn (without mouse)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;E&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Sample prop color&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Ctrl&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Crouch&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;On mobile, there's a left joystick for movement and a sample button. The game works surprisingly well on a phone — the rounds are short enough that touch controls don't get fatiguing.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Tech Behind the Fan Site
&lt;/h2&gt;

&lt;p&gt;The game itself is the official browser build embedded via iframe. The fan site at &lt;strong&gt;&lt;a href="https://mecchachameleonplay.com" rel="noopener noreferrer"&gt;mecchachameleonplay.com&lt;/a&gt;&lt;/strong&gt; is built with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;React Router 8&lt;/strong&gt; (with SSR for fast initial loads)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React 19&lt;/strong&gt; + &lt;strong&gt;TypeScript&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TailwindCSS v4&lt;/strong&gt; for styling&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vite 8&lt;/strong&gt; as the build tool&lt;/li&gt;
&lt;li&gt;Deployed on &lt;strong&gt;Cloudflare Pages&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The site serves as a landing page with gameplay instructions, FAQs, SEO metadata, and a mobile-optimized entry point. The game iframe handles the actual rendering, physics, AI, and audio.&lt;/p&gt;

&lt;p&gt;If you're curious about how the route config and SEO setup work for a single-page game hub, the project structure is refreshingly minimal — no massive monorepo, no complex state management. Just routes, copy content, and a few components.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips for New Players
&lt;/h2&gt;

&lt;p&gt;After a week of playing, here's what I've learned:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Use the prepare phase actively.&lt;/strong&gt; Run around and sample 2–3 different props. Find the one that blends best with the room's dominant color scheme.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Full camouflage + stillness = invisibility.&lt;/strong&gt; Once you hit 50%+ camouflage, stop moving. The hunter can walk right past you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If spotted, don't panic-run.&lt;/strong&gt; Sprinting away caps your camouflage at 25%, so the hunter can still see you at close range. Instead, sprint to break line-of-sight, then find a new prop and re-sample.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Crouch is useful.&lt;/strong&gt; It lowers the camera slightly, helping you hide behind low obstacles like desks or small walls.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read the HUD carefully.&lt;/strong&gt; The &lt;code&gt;⚠ SPOTTED&lt;/code&gt; and &lt;code&gt;✓ SAFE&lt;/code&gt; indicators give you real-time feedback on whether the hunter is onto you.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://mecchachameleonplay.com" rel="noopener noreferrer"&gt;Meccha Chameleon Online&lt;/a&gt; is exactly what I want from a coffee-break game: round times measured in seconds, a mechanic that rewards thinking over grinding, and zero commitment.&lt;/p&gt;

&lt;p&gt;If you're a developer looking for a quick mental reset between debugging sessions, or just curious about how a camouflage hide-and-seek mechanic works in a browser game, give it a shot. One round takes 90 seconds — which is about how long your next &lt;code&gt;npm install&lt;/code&gt; will take anyway.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This is an unofficial fan page for the MECCHA CHAMELEON game. For the full paid PC version on Steam, visit the &lt;a href="https://store.steampowered.com/app/2980170/MECCHA_CHAMELEON/" rel="noopener noreferrer"&gt;official Steam page&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>gaming</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>frontend devs</title>
      <dc:creator>skyler</dc:creator>
      <pubDate>Mon, 13 Jan 2025 06:15:48 +0000</pubDate>
      <link>https://dev.to/skyler_7abb6ba5f692ca05e6/frontend-devs-34a4</link>
      <guid>https://dev.to/skyler_7abb6ba5f692ca05e6/frontend-devs-34a4</guid>
      <description></description>
    </item>
  </channel>
</rss>
