Case study 01 AI clinical trial discovery clinical-trial-matching-pied.vercel.app

TrialMatch

TRIALMATCH TRIALMATCH

AI-powered clinical trial discovery. Patients describe their situation in plain language; TrialMatch extracts a structured patient profile, semantically matches it against a 500-condition corpus, pulls live trials from ClinicalTrials.gov, ranks them for relevance and eligibility, and explains every match in patient-friendly words.

Role
Solo — full stack & AI pipeline
Type
Production web app
Core stack
Next.js · FastAPI · LangGraph
Data layer
PostgreSQL · Redis
TrialMatch landing page with an interactive WebGL globe of live trial locations
01

Interface

02

The agents

The matching logic runs as a LangGraph state machine — six agents, one shared state object. Each agent owns a single decision and writes exactly one part of that state, which is what made every stage testable and swappable instead of buried inside one prompt.

TrialMatch agent dataflow: six LangGraph agents run in order, each fed by one input or service, and each writing a single field of the shared TrialMatchStateinputpatient queryplain languageagent 01extract_querycondition · location · ageexternalGroq LLMextractionagent 02patient_profilestructured profilelocal modelMiniLM + corpus500 conditionsagent 03semantic_matchcondition matchesexternal APIClinicalTrials.govregistry searchagent 04fetch_trialsraw trialsflagged offcross-encoder rerankdisabled in prodagent 05filter_rankranked trialscondition · location · agepatient_profilecondition_matchesraw_trialsranked_trialsfinal_resultsshared stateTrialMatchStateagent 06explain_eligibilityfinal results
Dataflow — inputs and services on the left, the six agents in sequence, and the field each one writes into TrialMatchState. The pulse follows one request through the whole pipeline.
03

Architecture

TrialMatch system architecture: the browser talks only to the Next.js app, which rewrites to FastAPI modules over Postgres, Redis, the condition corpus, ClinicalTrials.gov and the Groq LLMclientBrowser:3000 · JWT in localStoragenext.js 16Next.js app/ · /search · /login · /api/* → :8000entrymain.pyFastAPI :8000 · routesmoduleauth/register · loginmoduleusers/history · savedstorePostgreSQLusers · history · savedmodulecache/cache · rate limitstoreRediscache 1h · 30 req/minmoduleLangGraph6-agent pipelinestorecorpus + embeddings500 conditionsexternalClinicalTrials.govregistry searchexternalGroq LLMextraction · ranking
Two deployed services. The browser only ever talks to the Next.js app, which rewrites /api/* to FastAPI; only the pipeline and the cache layer reach outside.
04

Engineering decisions

05

Stack

TrialMatch / Live app

Try the
matcher.

Next case study Good Bookies