Workout AI
← All posts

Phase 1: Scaffolding an AI Workout App on Cloudflare Workers

They say, "Necessity is the mother of invention."" I prefer, "Constraints are the calling card of creativity."

CloudFlare Workers are a cool offering that I'm excited to be investigating, but they presented quite a few issues in scaffolding our project. We started with Neon Auth and moved to Better Auth. We started with an fs-driven blog content repository and had to move to a PWA manifest-based one. The non-Node, no-filesystem experience is full of surprises!

Hosting

I discussed this in the initial post, but there was some initial confusion between myself and Claude about whether we should be using Pages or Workers. We soon got that sorted and investigated how ephemeral Workers would operate. I'm accustomed to how Pages handles this (automatically), but there's a tiny bit more to it with Workers. Not a big deal, and GitHub actions are a solid means by which to manage things. We'll explore this some more in a future post.

Auth

The Neon Auth to BetterAuth move was driven by the edge computing issues. But, I have to admit, I didn't hate rolling my own here. Expet a deeper dive on BetterAuth soon!

Database & ORM

My boss at the day job is a big fan of the Drizzle hype war with Prisma, so I thought I would check it out. It's delightful that they knocked out a TypeScript query engine, but I really want to dive into performance metrics at some point. Not having to load the Prisma binary into memory gives Drizzle an initial edge, but it's not hard to imagine how that binary might smoke JS over the lifetime of a serverless instance.

Neon is a no-brainer. It will be interesting to see how costs scale if this app actually gets usage. But, I'll be happy to pay a success tax.

AI

The whole concept of the app is that it will be AI-driven. The days of static logic in personalized interactions are gone. The key decision here was to use the Vercel AI SDK as a model-provider abstraction and let users BYO model API key. Keeping that key safe will be a key bit of infrastructure code that we'll get into later.

Structure

I have had brushes with DDD and Clean Code enthusiasts in the past. I wanted to try to "do it right" and right out of the gate, so I spent some time with Claude building a Tessl (more below) tile to help keep the codebase in line with the philosophy. Right out of the gate I had to make a compromise with orthodoxy. More to come in a future post.

Tooling

This is all pretty straightforward -- Next.js provides a lot out-of-the-box. I went with a pretty standard Tailwind and shadcn/ui combination. The only stand out item is Tessl. After getting inculcated with their product by listening to their podcast, I decided to taste the Kool Aid®. I'm liking it so far.