DEV Community

Cover image for Building TrialBridge: An AI clinical trial matcher built in a single hack day
Akshara Sree
Akshara Sree

Posted on

Building TrialBridge: An AI clinical trial matcher built in a single hack day

Hacktoberfest: Contribution Chronicles

We, Team Latent, built TrialBridge during the Hacktoberfest Hack Day Coimbatore x (INIT Club & IDEA Club). We wanted to tackle a problem that actually matters: cancer treatments often push Indian families into debt, while slots for free, cutting-edge clinical trials go unfilled. The barrier is the data—eligibility rules are dense pages of medical jargon that patients can't understand and busy oncologists rarely have time to read.

Here is how our team built an AI-powered screening aid to bridge that gap.

How it works**

Our stack is Next.js 16 (App Router), React 19, TypeScript, Tailwind CSS 4, and zod.

  1. Intake: Users upload photos of their medical reports, scans, and current prescriptions. To stay within Vercel's hosting request-size limits, we shrink the photos directly in the browser before they hit the backend.

  2. Registry Data: We pull active, recruiting trials with open (or opening soon) Indian sites directly from the ClinicalTrials.gov v2 API.

  3. The Logic: We built a custom text splitter (lib/criteria.ts) to break down the massive blocks of registry text into atomic inclusion and exclusion rules.

  4. The Output: The app generates a printable summary for the oncologist, complete with a ✓ / ✗ / ? checklist for every rule. It even checks trial rules against the patient's current medicines (accounting for end dates and washout periods) to generate specific questions for the doctor.

  5. Safety First: The app never claims true medical eligibility—it only says "may qualify, confirm with your oncologist".

The Gemma 4 Partner Challenge

We submitted this for the Best Use of Gemma challenge. We used Google's open-weight gemma-4-26b-a4b-it model via the Gemini API to do the heavy lifting.

First, Gemma performs multimodal extraction, reading the uploaded images to build a structured patient profile (cancer type, stage, biomarkers, ECOG, labs, current medicines) alongside the exact quotes it used as evidence. The user manually checks this profile before any matching happens.

Then, Gemma judges the patient against each eligibility rule separately. A crucial architectural decision we made was keeping the AI strictly as a rule-judge, while plain, unit-tested code decides the final trial outcome (likely match, possible match, or not eligible).

Stuff that broke (and how we fixed it)

Building this in a day meant hitting a lot of walls. Here is what we learned:

  • Latency: Our first parallel runs took about 3 minutes per trial. We fixed this by switching Gemma to minimal thinking mode and writing medical hints directly into the prompt (e.g., "stage IV means metastatic"). This dropped a 4-trial batch down to 42 seconds with no thinking tokens used.

  • Double Negatives: Asking the AI "does the patient pass this exclusion rule?" was ambiguous and caused errors. We changed the prompt to simply ask "does this exclusion apply?" and flipped the boolean in our code.

  • Free-Tier Rate Limits: On our first live run, Gemma's free tier got busy and threw 429 errors. We handled this by building automatic retries with a UI countdown. We also added a "quick first look" prompt to filter out obvious mismatches early, which narrowed 20 trials down to 4 full checks.

  • Drug Washout Windows: The model initially treated completed drug courses as current. Injecting today's exact date into the prompt fixed it, allowing Gemma to correctly calculate washout periods.

  • Messy Registry Text: Real registry criteria are full of escaped characters, mixed headings, and nested sub-rules. We had to refine our text splitter against a sanity run of 33 trials and 579 rules to finally get clean data.

Links

Huge thanks to the team for surviving the sprint!

(Built for Hacktoberfest Hack Day Coimbatore x (INIT Club & IDEA Club) 2026)

Top comments (0)