Code: 02_ai-engineering-code/the-sea-star/lib/publish-workflow.ts + lib/ai.ts
Problem. One blog post for a bar should fan out to website, Facebook, Instagram, and an email blast — on a schedule and on-brand.
What I built. A workflow orchestrator where the LLM is one governed step:
publish-workflow.ts chains site → social → mailer, each channel independently set to now / schedule / skip.ai.ts calls Groq (llama-3.3-70b, JSON mode, temp 0.5) to generate platform-specific captions, pulling brand-voice guidelines from Supabase site_settings as context, enforcing hashtag/emoji/length rules and validating JSON output.scheduler handles time-based publishing.Stack & rigor. TypeScript · Next.js 14 · Supabase · Resend · dependency-injected (AppDeps) so the LLM and side-effects are mockable; full vitest + Playwright test:e2e + test:gate suite.
Why it matters. Shows LLM output treated as a structured, testable, brand-constrained step in a multi-channel pipeline — not a chat box.
One blog post needs to become a website update, a Facebook post, an Instagram caption, and an email, on a schedule. The orchestrator chains those channels and the LLM is just one governed step in the middle: Groq generates each caption in JSON mode, using brand-voice rules I store in the database as context, with hard limits on length and hashtags. The thing I'm proud of is the structure, I dependency-injected the model and the side effects, so the whole workflow is unit-tested with the LLM mocked. The model output is structured and testable, never a free-form chat box.
Shipped status (confirmed). This is live in the Sea Star admin panel: staff author a post in app/admin/create/*, pick channels per row, and app/api/blog/publish/route.ts calls Groq inline to generate the captions; a Vercel cron (vercel.json, 6am Pacific) runs the scheduler; Supabase stores posts/campaigns/subscribers under RLS. Live: https://the-sea-star-sf.vercel.app · code: 02_ai-engineering-code/the-sea-star/api-blog-publish/route.ts.
GG · Applied AI Engineering portfolio · synced to youdontneedmy.help design