How mrqasimasif/cliniq works
ClinIQ lets researchers describe a trial search in conversational language, refine it over multiple turns, and receive ranked trial cards with an AI-written explanation. The main request flows from the chat UI through a Next.js proxy to the FastAPI chat handler, which restores session filters, parses intent, runs hard-filter and semantic retrieval, generates a response, and persists the session and matches. A separate ingestion job seeds and refreshes the trial store from ClinicalTrials.gov. The matcher excerpt is partial; links are shown only where supported by the supplied source or README.
Main entry points: chat.py Chat and session handler · page.tsx Chat and results UI · route.ts Chat API proxy · intent_parser.py Intent and response LLM
Components 12
Researcher interface
- Chat and results UI
frontend/app/page.tsx - Filter badges
frontend/components/FilterBadges.tsx - Trial cards
frontend/components/TrialCard.tsx - Chat API proxy
frontend/app/api/chat/route.ts
Conversation API
- Chat and session handler
backend/app/routers/chat.py - Intent and response LLM
backend/services/intent_parser.py
Trial retrieval
- Two-stage matcher
backend/services/matcher.py
Trial catalog
- PostgreSQL trial store
001_init.sql - Trial ingestion and embeddings
backend/scripts/ingest_trials.py
Other components
- Researcher
- Groq LLM
- ClinicalTrials.gov API
Connections 15
- Researcher → Chat and results UI: enters query
- Chat and results UI → Chat API proxy: posts message
- Chat API proxy → Chat and session handler: forwards request
- Chat and session handler → Intent and response LLM: parses intent
- Intent and response LLM → Groq LLM: calls LLM
- Chat and session handler → Two-stage matcher: runs retrieval
- Two-stage matcher → PostgreSQL trial store: queries trials
- Chat and session handler → Intent and response LLM: generates explanation
- Chat and session handler → PostgreSQL trial store: loads and saves session; saves matches
- Chat and session handler → Chat API proxy: returns filters, trials, reply
- Chat API proxy → Chat and results UI: returns response
- Chat and results UI → Filter badges: shows active filters
- Chat and results UI → Trial cards: renders matches
- Trial ingestion and embeddings → ClinicalTrials.gov API: fetches studies
- Trial ingestion and embeddings → PostgreSQL trial store: upserts trials and embeddings