AI Fluent · Chapter 08

Edge Functions as Your Backend

The "backend" is everything behind the scenes — processing payments, checking logins, saving data. Edge functions let you handle all of it without a server or an engineering team.

7 min read Shaen Hawkins
Professional kitchen stations viewed from above — each station is an edge function

What Happens Behind the Scenes

When someone taps "Subscribe," a lot happens they never see. Verify login. Send payment to Stripe. Wait for confirmation. Update database. Grant access. All in about two seconds.

All of that invisible work is your backend. In a traditional company, a whole team builds this. As a solo builder, edge functions are how you handle it.

Definition
Backend

Everything that happens behind the scenes. Processing payments, checking passwords, reading/writing data. The kitchen where food gets made — as opposed to the dining room where customers eat.

Definition
Edge Function

A small piece of backend logic that runs in the cloud only when needed. Sleeps when nobody uses it. Wakes up, does its job, goes back to sleep. You pay for usage, not uptime.

Plain English

A traditional server is a full-time salaried cook standing in the kitchen 24/7, whether there are orders or not. An edge function is a line cook who clocks in when there's an order, cooks the dish, clocks out. At 3am when nobody's ordering, you're not paying anyone.

One Handler Per Area

Each function owns its domain completely. When one breaks, the others keep running.

auth-handler

Login, signup, token refresh, account management. Nothing else.

conversation-handler

Eligibility, session management, conversation data. Nothing else.

dashboard-handler

User progress, statistics, subscription status. Nothing else.

webhook-receiver

Incoming events from Stripe, your AI provider, and other external services. Nothing else.

Diagram showing split handler architecture — app request to router to handler

Start Split or Start Together?

Path A: One Big Function

Simple to start. Works great for months. But at ~500 lines, it becomes a nightmare to debug. A bug in payments breaks authentication. Splitting mid-flight is painful.

Best for: genuinely unsure what your product will look like

Path B: Split From Day One

More files, more deployments. Feels like overkill at 200 lines. But when one breaks, the others keep running. You never do a painful mid-flight renovation.

Recommended if you know you'll have 3+ areas of functionality
The Source of Truth Rule

For every piece of important data, decide: which system is the boss? Payment status → Stripe is the boss. User profiles → your database is the boss. Voice or AI configs → your AI provider is the boss. When two systems disagree, the boss wins. Every other system follows.

Chapter Appendix
Edge function setup guideWhen to split a monolithWebhook patternsError handlingRate limiting