codingwithaibook.com
← Back to codingwithaibook.com

Case study · Greenfield, end-to-end

Building an AI SaaS from scratch

The book doesn't just describe the method — it ships a real product with it. From an empty directory to a deployable freemium AI app, every load-bearing piece included.

The product

Wild West Wanted Poster — upload a selfie, get an AI-generated Old-West "WANTED — DEAD OR ALIVE" poster of yourself. Email sign-up, 5 free generations a month, $1 for 10 more credits, and an admin backend. Small enough to read end-to-end; complete enough to have every part a real product has.

What actually got built

Not a toy. The case study walks through the boring, load-bearing pieces tutorials skip and production punishes — DNS, IAM, idempotency, refunds, a queue, a cron, a payment webhook — all driven by the book's method: agent-ready issues, a single verify command, and tight human review on anything touching money or secrets.

Route53 + ACM → ALB → ECS "web" (Next.js) → RDS / S3 / SQS / Stripe │ SQS queue ▼ ECS "worker" → Gemini → poster → S3 → SES EventBridge (monthly) → grant 5 free credits

Domain + DNS

Route53 hosted zone, DNS-validated ACM TLS for apex + www.

Terraform / AWS

VPC, ECS Fargate, ALB, RDS, S3, SQS, SES, IAM, Secrets Manager, EventBridge — all as code.

App server

Next.js 14: upload UI, magic-link auth, admin backend, JSON API.

Postgres

Event-sourced credit ledger — balance is summed, never stored.

Queue + worker

SQS jobs, a Node worker, a dead-letter queue, credit refund on failure.

Stripe

Checkout + signed webhook. Credits granted only on the verified event.

Gemini

Image model restyles the portrait; sharp composites the poster frame.

Email + cron

SES for sign-in and "poster ready"; EventBridge for the monthly free grant.

Why it's shaped this way

Read the full build

The complete case study — the chapter walkthrough plus every artifact (Terraform, the Next.js app, the worker, the schema, the agent-ready issues used to build it) — is open source in the companion repo.