Full-Stack & Mobile
ThrivePact — Habit Accountability App
ThrivePact helps people break habits through one honest daily check-in and small crews who have all made the same pact. The same Supabase-backed core powers a Next.js web app, a native Swift iOS client through a versioned /api/v1 mobile API, and a fully conversational SMS flow — so a user can commit and check in wherever they are. Streaks, missed-day recovery, AI-generated pacts, payments, and notifications all run off one Postgres schema with row-level security.
Stack
Concepts
How it works
The whole flow, traced from your first tap.
- 01
Web / iOS → API
Make a pact
You describe a habit in plain words and the app drafts a literal title, rules, and a one-line commitment — the AI output is validated with Zod, and if the model is down it silently falls back to deterministic mock rules so creation never breaks.
OpenAI gpt-4o-miniZodMock fallback - 02
Vercel crons → Twilio / Resend
Get nudged at the right hour
Reminder, digest, and daily-SMS cron jobs run hourly and resolve each user's own timezone with Luxon, queueing a text or email for their local check-in time instead of one global blast.
Luxon timezonesEmail queueWhatsApp/SMS - 03
Twilio webhook → Supabase
Check in by text
You just reply Y or N. The webhook verifies the Twilio signature, dedupes the message by SID against a logs table, and parses your answer through a mode-aware resolver so the same reply means the right thing for an avoidance pact versus an action pact.
Twilio signature validationReplay-safe message logPact-mode parser - 04
Supabase + services
Keep your streak honest
Streaks are computed two ways — a consecutive-day rolling streak for crews, and a solo streak where a missed day freezes rather than resets the count and only an explicit negative check-in breaks it — and RLS guarantees only active members can ever write a check-in.
Solo-freeze streak engineRolling streakRLS - 05
API → Postgres function
Buy back a missed day
If you skip a day, gold bars (purchased via Stripe and tracked in a credit ledger) let you recover that exact day — priced by how long ago it was — with the balance debited atomically inside a Postgres credit_transact function so it can never go negative.
Stripe checkoutAtomic credit_transact RPCCalendar-distance pricing - 06
Supabase Storage → Railway worker
Share proof in your crew
Photos and videos attach to a check-in via signed upload URLs, and a standalone Railway worker claims pending video jobs from a queue and compresses them with ffmpeg — auto-rotating and downscaling to 720p — so the crew feed stays fast without blocking your post.
Signed upload URLsJob-claiming queueffmpeg on Railway
The problem
Breaking a habit fails when accountability is optional and check-ins are friction. People download an app, forget it by day three, and quietly give up alone. ThrivePact needed to make the daily moment of honesty unmissable — reachable by text, not just inside an app — and to make a missed day recoverable rather than a reason to quit.
What we built
A solo pact is a personal daily commitment; a crew is a small group who all made the same pact and share a feed. Users create a pact (with an AI-suggested title, rules, and commitment), then check in once a day by web, native iOS, or replying Y/N to a text. Missed days do not break a solo streak — they freeze it — and a paid gold-bar balance lets users buy back specific missed days. Crews add reactions, threaded replies, moderation, and timezone-correct reminders.
One check-in, three front doors
The inbound SMS webhook validates every Twilio request signature, dedupes against a message-log table for replay protection, then parses the reply with a pact-mode-aware parser — for an avoidance pact a Yes is a relapse, for an action pact a Yes is a win — and writes the same check-in row a web or iOS user would. The native Swift app talks to a versioned /api/v1/app surface with bearer auth, OTP login, push tokens, and snake_case request envelopes, reusing the same server handlers as the web so behavior stays identical across clients.
Outcome
ThrivePact runs as a single Supabase-backed product with three real entry points — web, native iOS, and conversational SMS — plus a Stripe-funded credit economy, an AI pact builder with a deterministic fallback, and a Railway ffmpeg worker for media, all coordinated by ten timezone-aware Vercel cron jobs and covered by Playwright and Vitest suites.
Interested in something similar?
Tell us what you need and we'll figure out how to ship it.