Case Study

Hayaat Intake AI — Case Study

AI software engineer case study: full stack developer website development for Medicaid voice/SMS intake—Next.js, Vapi, Twilio, OpenAI agents, and Supabase CRM.

Hayaat Intake AI — Case Study
By Published Updated

Hayaat Intake AI — Engineering Case Study

1. The 60-Word "AI Citation" Summary

Hayaat Intake AI is a Next.js 16 (App Router) application for a Michigan Medicaid home-help agency—a full stack developer and AI software engineer delivery combining website development with voice and SMS agent flows. Vapi voice intake, Twilio SMS with OpenAI (gpt-4o) tool-calling, and Supabase (PostgreSQL + Auth + Storage) power public intake and a staff admin console protected by middleware and Supabase SSR sessions.

2. The Power Stack Table

CategoryTechnologies
LanguagesTypeScript, SQL (Supabase migrations / sprint scripts)
Framework & UINext.js 16.1.2, React 19.2.3, Tailwind CSS 4, Radix UI (Dialog, Tabs), class-variance-authority, Lucide, @hello-pangea/dnd, Recharts
Data & AuthSupabase (@supabase/supabase-js, @supabase/ssr), generated Database types
Voice & CommsVapi (@vapi-ai/web, REST outbound calls), Twilio (SMS, webhooks)
AIOpenAI (gpt-4o) with function tools in lib/ai_chat.ts
Documentspdf-lib, private Supabase Storage bucket documents
Infra / OpsVercel-style deployment (see README), optional cron keep-alive route hitting Supabase

Note: Stripe is not present in this repository; billing is modeled as internal billing_records in Supabase.

3. The Challenge

Manual, fragmented intake for Medicaid home-help services: phone-heavy triage, inconsistent capture of client vs. caregiver context, and slow handoff to applications and staff workflows. The product compresses that funnel into a single state machine (clients, caregivers, doctors) with explicit intake, medical form, and application pipelines—so every voice call, SMS, or web message can land in one CRM with traceable history.

Full-stack delivery context

Delivered as mobile phone application development-ready responsive web plus website development on Next.js—owned by an AI software engineer team at AlrightTech with 6+ years shipping healthcare-adjacent agent systems. Public users get voice or web chat intake; staff operate a full CRM without sacrificing auditability.

4. Engineering Architecture — The "Why"

DecisionRationale
App Router + Server Components for marketing/admin shellsKeeps auth-sensitive reads on the server (createClient from utils/supabase/server), while isolating interactive widgets (VapiCallButton, ChatWidget, Kanban) as client components.
Middleware on /admin/* onlyPublic /apply and landing stay frictionless; staff surfaces enforce session refresh and redirect unauthenticated users to /login.
Service-role Supabase in webhooks & AITwilio and Vapi hit server-only routes; the service role bypasses RLS for trusted server writes (messages, leads, logs)—with the tradeoff that correctness lives in application code, not client-side queries.
Vapi end-of-call-report + recursive payload parsingVapi payloads vary; deep findKey / findCallSummary makes the integration resilient to schema drift without redeploying the assistant.
Signed URL document routePrivate bucket + short-lived redirects avoid exposing raw storage paths and support compliance-minded access patterns.

5. Three Technical Wins (Repo-Specific)

Win A — Resilient Vapi → CRM + SMS handoff

The Vapi webhook ignores non-terminal events, extracts caller metadata from nested JSON, upserts clients or caregivers on phone, fires non-blocking sendApplicationLink SMS, and logs intake_logs—so the webhook returns quickly while downstream work continues.

Win B — OpenAI create_lead with retroactive message linking

When the model invokes create_lead, the server upserts the client and then updates prior rows in messages that matched session_id or from_number but had no client_id—fixing anonymous SMS/web threads after identity is disclosed.

Win C — Middleware session hygiene

Invalid refresh tokens are cleared (sb-access-token / sb-refresh-token deletes) before redirecting to login, reducing stuck sessions and support churn for staff.

6. Security & Performance (MSIS Focus)

AreaImplementation
Transport & sessionsSupabase SSR cookie adapter in middleware and server client; admin routes gated by authenticated getUser().
Webhook trustRoutes use server env (SUPABASE_SERVICE_ROLE_KEY, Twilio secrets); no client exposure of service keys.
StorageSQL policies in database/sprint2.sql scope documents bucket; app serves files via createSignedUrl (1 hour) in app/api/documents/[...path]/route.ts.
AI safetyTruncation of very long replies (~1600 chars), fallback copy when OpenAI or Twilio is misconfigured, structured logging for failures.
Cold start / DB wakeGET /api/cron/keep-alive performs a minimal clients select with the service role—useful for scheduled pings on serverless hosts.

7. Agentic Influence

LayerRole
Product AIAlex persona in SMS/web (lib/ai_chat.ts); tool calling to persist leads; doctor follow-up outbound calls via lib/vapi.ts.
VoiceVapi Web SDK on the landing page with lifecycle hooks (call state, volume-based “speaking” UI, optional ringtone).
DevelopmentTyped Supabase workflow (types/supabase.ts), sprint SQL artifacts under database/, and explicit “no invented columns” rule in project_context.md to keep AI-assisted coding aligned with schema.

Key achievements

  • Voice + SMS intake
  • Unified CRM
  • Signed URLs for PHI documents
  • Website development
  • AI software engineer

Industry

Healthcare, Medicaid intake

Stack

Next.js 16, Supabase, Vapi, Twilio, OpenAI, Full stack developer

Outcomes

Voice + SMS intake, Unified CRM, Signed URLs for PHI documents, Website development, AI software engineer

Project links

Want a broader project snapshot?

Browse the portfolio for shorter project cards with stack, links, and demo references.

View portfolio

More case studies

COOARD Salon & Barber Booking Platform Case Study

Full stack developer case study: Next.js website development plus Capacitor mobile application development for a multi-tenant salon platform with Stripe, Supabase RLS, and AI catalog automation.

View case study

Twinsting Case Study: Role-Aware Marketplace Architecture

Full stack engineer case study: Next.js 15 website development and Express API for a multi-role marketplace—web dev, app developers delivery, Stripe Connect, and realtime chat.

View case study

CPMS — Comprehensive Procurement Management System

Full stack engineer case study: enterprise website development on Next.js 15 with Prisma, Auth.js RBAC, backend developer workflows, and UI UX developer procurement surfaces.

View case study

Tuttle Case Study: AI Localization Platform Architecture

AI software engineer case study: full stack developer website development for AI video dubbing SaaS—React, Next.js, HeyGen, DeepL, Stripe, and metered AI localization.

View case study