A Background-remover application finished by Ai

Dev.to / 3/28/2026

💬 OpinionDeveloper Stack & InfrastructureTools & Practical Usage

Key Points

  • The article describes building a free AI-powered background remover website deployed with Cloudflare Pages (frontend), Cloudflare Workers (backend), and Cloudflare D1 (database), using the Remove.bg API for image processing.
  • Users can use the tool 3 times per day without login, while authenticated users via Google Login get cross-device syncing of credits and membership status.
  • The author highlights a key improvement by moving from localStorage to D1, enabling persistent credit/membership data across devices after login.
  • The implementation uses Cloudflare Workers to serve HTML pages and handle routes through a single Worker, simplifying deployment and backend logic.
  • Monetization is handled through credit packs and subscription-style membership plans paid via PayPal.

I Built a Free AI Background Remover Using Cloudflare Workers + D1

I spent my weekend building an AI background remover website, with both frontend and backend deployed on Cloudflare, costing almost nothing. Here's my development journey and some lessons learned.

🌟 Project URL

https://zmjjkk.xyz

🔧 Tech Stack

  • Frontend: Static HTML + JavaScript (Cloudflare Pages)
  • Backend: Cloudflare Workers
  • Database: Cloudflare D1
  • AI Background Removal: Remove.bg API
  • Payment: PayPal

🚀 Features

  1. Free to Use: 3 free uses per day, no login required
  2. Google Login: Cross-device sync after login
  3. Credit Packs: Purchase credits via PayPal
  4. Membership: Monthly/Yearly unlimited plans

💡 Key Highlights

1. Benefits of D1 Database

Previously I used localStorage, so users would lose their data when switching devices. After switching to D1, once a user logs in, their credits and membership sync across all devices.

-- User table structure
CREATE TABLE users (
  id INTEGER PRIMARY KEY,
  google_id TEXT UNIQUE,
  email TEXT,
  credits INTEGER DEFAULT 0,
  membership TEXT,
  membership_expire TEXT,
  total_used INTEGER DEFAULT 0
);

2. Interesting Uses of Workers

Workers aren't just for APIs - they can also serve HTML pages directly. One Worker handles all routes:

// Home page
if (path === '/') {
  return new Response(HOME_PAGE, {
    headers: { 'Content-Type': 'text/html' }
  })
}

// Pricing page
if (path === '/pro') {
  return new Response(PRO_PAGE, {...})
}

// API endpoint
if (path === '/purchase' && method === 'POST') {
  return handlePurchase(request, env)
}

3. PayPal Integration Lessons

Sandbox and production have different API addresses, and sandbox testing sometimes has weird CORS issues. The final solution was to provide a manual payment confirmation as a fallback, in case the automatic flow fails after user pays.

📊 Cost Estimate

Service Free Tier Overage
Workers 100,000 req/day $0.50/million
D1 5GB storage $1/GB/month
Pages 500MB Free
Remove.bg - $0.07/image

Currently with a few hundred visits per day, everything is within the free tier.

🔜 Future Plans

  • [ ] Add more AI features (background replacement, resize)
  • [ ] Batch processing support
  • [ ] Open API for developers

🤔 Reflection

This project made me rethink Cloudflare's product capabilities. The Workers + D1 + Pages combo is amazing for small to medium web applications - easy deployment, global CDN, and extremely low cost.

If you have similar ideas, try this stack! Feel free to ask questions in the comments!

Feel free to try https://zmjjkk.xyz and leave your feedback in the comments!