Development of CiteWard Medical AI by Asad BaigDevelopment of CiteWard Medical AI by Asad Baig

Development of CiteWard Medical AI

Asad Baig

Asad Baig

CiteWard: How I Built a Medical AI That Is Not Allowed to Make Things Up

Overview

CiteWard is a medical AI for clinicians, students and researchers. You ask a clinical question in plain language and it answers from real evidence, with every claim linked to the paper, guideline or label behind it.
I designed and built the whole platform myself: the answer engine, the safety layer, the apps for four kinds of user, a medical image analysis tool and the database underneath.
The idea that drove every decision: in medicine, a confident wrong answer is worse than no answer. So the product is built to show its sources, show its uncertainty and refuse to quietly change numbers that matter.

The Challenge

General chatbots are fluent and often wrong in exactly the ways that hurt in medicine. They invent studies, blur doses together and state guideline claims with no source behind them.
I needed a system that could:
Answer real clinical questions, including multi-drug dosing cases
Prove every statement by linking it to a source a clinician can open
Never let the AI silently alter a dose or a calculated value
Tell the user clearly when something could not be verified, instead of hiding it
Stay useful for very different people: a first-year student, an exam candidate, a working clinician and a researcher.

The approach: evidence first, then checks

The pipeline has five steps. The AI never answers from memory alone.
The user asks a question.
The system retrieves real evidence from sources such as PubMed, the FDA and NICE.
The AI drafts an answer from that evidence only.
A checking layer inspects doses, figures, calculator results and regulatory claims.
The answer is shown with numbered citations, plus flags on anything unverified.
Each citation marker opens the actual source, so a clinician can check any claim in one click.

Safety enforced in code, not just in the prompt

A prompt is a suggestion. Code is a guarantee. The rules that must never be broken live in code, outside the model:
A drug dose can never be deleted or rewritten by the AI
Built-in clinical calculators do their own maths. If the AI computes a different number, the calculator's value wins
Every calculator result is cited to its own source, so the working is traceable
Any figure the system cannot verify is flagged on screen: red if a citation looks fabricated, amber if a number is simply unverified
Regulatory claims with no retrieved label get a visible warning instead of being stated as fact
Evidence rows that lose their outcome are dropped rather than shown half-complete
I tested the rules on hard cases: a multi-calculator dosing case and an apixaban dosing vignette. In both, every dose was preserved and the arithmetic was shown.

One platform, four kinds of user

The same engine serves four types of user, each with its own dashboard, tool order and defaults:
Pre-clinical student: study tools and revision
Exam candidate: question bank and exam focus
Clinician: clinic mode and calculators
Researcher: evidence and research mode
The user type is derived from their profile, not stored as a separate setting, so it cannot drift out of date. Personalisation only reorders tools. It never hides them.
A guided onboarding flow collects the essentials, and the dashboard shows a weekly report, a study library and continuing education tracking drawn from real activity.

Three modes for three jobs

Auto mode picks the right lens for the question. Study mode explains like a tutor. Clinic mode answers like a decision-support tool, with calculators close at hand. Research mode reviews the evidence. Users can switch at any time, and every chat is saved and tagged by mode.

Medical image analysis, built as decision support

The platform also includes an image analysis tool for clinicians, designed so it cannot overreach:
Independent AI readers examine the same image. When they disagree materially, a third reader steps in
Findings are structured, and the final output carries a disposition: whether the study is suitable, incomplete or needs a human
Confidence is capped when evidence is thin, when the study is incomplete or when readers disagree
Case state is stored on the server and cannot be altered from the browser, so a later step cannot be tampered with. If the state is missing or invalid, the system fails closed and restarts the case instead of guessing
An automated test suite covers the engine
It supports a clinician's judgment. It does not claim to diagnose.

A debugging story: why I ship a diagnostic after two failed fixes

One stage of the pipeline kept timing out and falling back to a weak answer. I shipped several fixes based on guesses, and each was wrong.
After the second failed fix I changed my rule: the next change is a diagnostic, not a third fix. I added a trace that recorded what every stage received and returned. A single run showed the real cause, a time budget that was too short for the generation step, so the repair stage never got to run.
I raised the limits, changed the behaviour so the product always returns an answer with a notice listing anything unverified, and stopped withholding answers when a check failed. The principle I keep from it: measure before you guess again.

Honest limits and what is next

No system like this is finished. A known open problem is claim-to-source alignment: a correctly retrieved trial can still be cited for a point it does not actually support. That cannot be checked with a simple rule, so the next step is a dedicated citation verification layer.
I only claim what I can document. No compliance badges are shown, and the platform is positioned as decision support, not a substitute for clinical judgment.

Stack

Next.js (App Router), TypeScript, Tailwind CSS, Supabase (Postgres with row-level security and authentication), a retrieval pipeline, usage limits and rate limiting, automated tests.
Like this project

Posted Oct 31, 2026

Developed CiteWard, a medical AI ensuring accurate evidence-based answers.