How syedaejazahmed/clinicsynapse works
Purpose and Entry Points
Trial Screening Copilot is an MVP for evidence-backed clinical-trial eligibility screening. It evaluates synthetic patient records against trial protocols and returns deterministic Eligible, Needs Review, or Ineligible decisions with criterion-level evidence. The backend starts at app/main.py as a FastAPI service; the separate Vite/React client starts at Frontend/src/main.tsx and composes the application in Frontend/src/App.tsx.
Shared Domain and Seed Data
Backend request, response, patient, trial, criteria, and matching schemas are centralized in app/models.py; these form the contract for API consumers and matching logic. The default offline dataset is JSON-backed, with synthetic records in app/data/patients.json, app/data/trials.json, and app/data/studies.json. This permits the core workflow without live model access or real PHI.
Eligibility Extraction Pipeline
Protocol text is converted into structured eligibility criteria by app/extraction.py. It can use an Anthropic-backed LLM path when ANTHROPIC_API_KEY is configured, but falls back to pre-extracted criteria in app/data/trials.json, preserving application functionality offline. Rule-oriented extraction support is separated into app/extract_rules.py.
Deterministic Matching Core
app/matching_engine.py is the product’s decision boundary: it compares structured patient attributes and trial criteria without relying on an LLM for eligibility decisions. Its output carries individual criterion outcomes and supporting evidence, allowing API and UI layers to explain the final status rather than merely expose a score. API orchestration and report generation are exposed through app/main.py.
Backend API and Reporting Flow
Clients retrieve patients and trials, submit a patient/trial match request, or request a patient-wide screening report. FastAPI in app/main.py loads domain data, invokes extraction or matching as needed, and serializes model-defined responses from app/models.py. Interactive backend documentation is available through FastAPI’s /docs; the service is intended to run under Uvicorn with Python dependencies from requirements.txt.
Frontend Clinical Workflow
The React frontend organizes operational views around patient, trial, study, matching, report, audit, and research-assistant workflows, including Frontend/src/pages/Patients.tsx, Frontend/src/pages/Matching.tsx, and Frontend/src/pages/Reports.tsx. Typed HTTP client modules such as Frontend/src/services/patientApi.ts, Frontend/src/services/matchingApi.ts, and Frontend/src/services/reportApi.ts isolate backend communication from UI pages. Reusable evidence-oriented presentation components include Frontend/src/components/EligibilityCard.tsx, Frontend/src/components/CriteriaTable.tsx, and Frontend/src/components/EvidencePanel.tsx.
Research and PDF RAG Boundary
A distinct research-assistant capability exists outside deterministic screening, implemented in app/research_assistant.py and app/rag_pdf.py. Its retrieval pipeline includes PDF conversion, cleaning, chunking, index construction, and querying under app/utils/pdf_to_text.py, app/utils/build_index.py, and app/utils/query_index.py. Sample protocol PDFs reside in dataset/; this subsystem may use LLM-provider abstraction in app/utils/llm_provider.py and should remain separate from the authoritative deterministic eligibility decision path.
Main entry points: main.py FastAPI API & reports · rag_pdf.py PDF RAG orchestration · extraction.py Eligibility extraction · matching_engine.py Deterministic matcher
Components 20
Deterministic Screening Backend
Authoritative eligibility API and decision flow.
- FastAPI API & reports · Orchestrates retrieval, matching, and patient-wide reports.
app/main.py - Shared domain models · API contract for patients, trials, criteria, matches, and responses.
app/models.py - Synthetic patients
app/data/patients.json - Trials & extracted criteria · Offline trial source and extraction fallback.
app/data/trials.json - Studies data
app/data/studies.json - Eligibility extraction · Uses Anthropic when configured or stored criteria offline.
app/extraction.py - Rule extraction support
app/extract_rules.py - Deterministic matcher · Produces status, criterion outcomes, and evidence without LLM decisions.
app/matching_engine.py
React Clinical Client
Operational screening and evidence views.
- React app composition
Frontend/src/App.tsx - Vite entry point
Frontend/src/main.tsx - Clinical workflow pages · Patient, matching, and report workflows.
Frontend/src/pages/Matching.tsx - Typed API clients · Isolates patient, matching, and report API calls.
Frontend/src/services/matchingApi.ts - Evidence presentation · Renders eligibility outcomes, criteria, and supporting evidence.
Frontend/src/components/EvidencePanel.tsx
Research PDF RAG
Separate, non-authoritative protocol research capability.
- Research assistant · Separate from authoritative screening decisions.
app/research_assistant.py - PDF RAG orchestration
app/rag_pdf.py - Sample protocol PDFs
- PDF conversion & cleaning
app/utils/pdf_to_text.py - Chunking & index build
app/utils/build_index.py - Index querying
app/utils/query_index.py - LLM provider abstraction
app/utils/llm_provider.py
Connections 21
- Vite entry point → React app composition: mounts
- React app composition → Clinical workflow pages: composes
- Clinical workflow pages → Typed API clients: uses
- Clinical workflow pages → Evidence presentation: renders
- Typed API clients → FastAPI API & reports: HTTP requests
- FastAPI API & reports → Shared domain models: serializes contract
- FastAPI API & reports → Synthetic patients: loads
- FastAPI API & reports → Trials & extracted criteria: loads
- FastAPI API & reports → Studies data: loads
- FastAPI API & reports → Eligibility extraction: extracts criteria as needed
- FastAPI API & reports → Deterministic matcher: submits patient-trial match
- Eligibility extraction → Rule extraction support: uses rules
- Eligibility extraction → Trials & extracted criteria: offline criteria fallback
- Deterministic matcher → Shared domain models: reads structured inputs and emits outcomes
- Deterministic matcher → Trials & extracted criteria: evaluates criteria
- Research assistant → PDF RAG orchestration: uses retrieval
- PDF RAG orchestration → PDF conversion & cleaning: converts and cleans
- PDF conversion & cleaning → Sample protocol PDFs: reads
- PDF RAG orchestration → Chunking & index build: builds index
- PDF RAG orchestration → Index querying: queries index
- PDF RAG orchestration → LLM provider abstraction: optional LLM access