Inspiration

Every year the FDA issues thousands of drug recalls — medications pulled because they're contaminated, mislabeled, or outright dangerous. But the recall almost never reaches the person who actually has the pills in their cabinet. The process is slow, manual, and full of gaps: notices get posted to a federal database, then trickle through distributors and pharmacies over days or weeks, while people keep taking the recalled drug. We wanted to collapse that timeline from weeks to seconds — and, just as importantly, to close the loop by hearing back from real patients about how the recall actually affected them.

What it does

SafetyConnect is an autonomous drug-recall defense system. It continuously ingests the latest recalls from the openFDA enforcement feed, uses xAI's Grok model to classify how dangerous each one is (with a plain-language rationale, not a black box), and matches the recalled product against a nationwide cohort of 1M+ patients across thousands of pharmacies in ClickHouse. It then coordinates a response — alerting the patient, their pharmacy, their in-network care provider, and their insurer at once — and sends a real check-in link to the patient's phone via Telegram. The patient can respond through a Grok voice agent or a quick form; Grok triages their symptoms, routes urgent cases to the pharmacy's action queue, and rolls every response up into an aggregated, de-identified signal the FDA can act on. The whole pipeline streams live on a dashboard, step by step, with an interactive US map of the fan-out.

How we built it

A single TypeScript/Next.js app deployed on Vercel. Inngest powers the durable orchestration — a cron-driven openFDA ingestion function plus a multi-step "defense" workflow that publishes each stage over Inngest Realtime so the dashboard animates the trace as it happens. xAI Grok does severity classification, patient-card copy, and symptom triage, and the Grok voice agent (real-time speech over WebSockets with function calling) runs the conversational patient check-in. ClickHouse stores recalls and the synthetic patient/pharmacy network and does the cohort matching and aggregation, with deterministic hashing to derive each patient's care provider and insurer without storing PII. D3-geo renders the interactive map; Telegram delivers the live demo alert.

Challenges we ran into

Keeping the Realtime subscription stable was the trickiest — the dashboard kept resubscribing on every render and dropping pipeline stages until we memoized the channel, topics, and token. The Grok voice agent was a deep integration: ephemeral client-secret auth, PCM16 audio streaming at 24kHz, and getting it to stop listening and tear down cleanly the moment it submitted the form. We also hit a subtle recall-mismatch bug where voice feedback landed in the database but didn't show on the dashboard because the panel was scoped to a different recall. Deployment surfaced its own issues: serializing server-action tokens across the server/client boundary, reaching a local ClickHouse from Vercel via a tunnel, and wiring Inngest Cloud's event and signing keys.

Accomplishments that we're proud of

We built a genuinely end-to-end, explainable pipeline — every step is something you can narrate and point to live, from the raw FDA recall to an individual patient and back. The "closing the loop" feedback system, where a Grok voice conversation turns into a triaged pharmacy task and an FDA-level aggregate in real time, came together cleanly. And the whole thing is privacy-conscious by design: only de-identified aggregates and pseudonymous patient references ever surface in the UI or to the LLM.

What we learned

We learned how much durable, event-driven orchestration (Inngest) simplifies a multi-stage real-time system compared to hand-rolled crons and sockets, and how powerful an LLM is when you make it explain its reasoning rather than just emit a label. The Grok voice agent taught us the realities of low-latency audio in the browser — buffering, lifecycle, and graceful teardown. And we got a real appreciation for handling healthcare data carefully: deriving relationships deterministically and keeping everything de-identified end to end.

What's next for SafetyConnect

Real delivery channels at scale (verified SMS/voice and pharmacy-system integrations), a true ClickHouse Cloud deployment instead of a tunnel, and richer multi-recall handling. We'd add provider and insurer portals so the coordinated-care network is actionable on their side too, deeper Grok-driven triage with escalation to telehealth, and a real FDA-facing analytics view that turns aggregated patient signals into early safety detection.

Built With

  • clickhouse
  • grok
  • inngest
  • vercel
  • xai
Share this project:

Updates