Production-Grade Multi-Agent Scientific Research Engine & Mobile Dashboard
Accelerated Evidence Aggregation, Molecule Grounding, Quality Ranking (EQS), Contradiction Detection, 17 Repurposing Sections, and Citation-Backed Synthesis.
- Product Overview
- Key Differentiators
- System Architecture
- Molecule Grounding & Query Context
- The 6-Agent AI Pipeline Workflow
- Governing Mathematical Equations
- The 17 Drug Repurposing Research Sections
- Dual LLM Engine (Gemini & Groq)
- External Scientific Connectors & Source Health
- PDF Pre-Export Validation & Safety
- Complete File & Folder Structure
- Quickstart & Deployment Guide
- Testing & Verification
Pharmalyx (Cureonix Platform) is a production-grade multi-agent research intelligence platform engineered for pharmaceutical researchers, drug discovery scientists, and clinical research analysts. It aggregates evidence from multiple scientific databases, performs semantic vector ranking using Evidence Quality Scores (EQS), detects conflicting research findings between published studies via Natural Language Inference (NLI), synthesises insights across 17 structured drug-repurposing sections, and delivers citation-backed research reports with pre-PDF export validation in seconds.
Core Value Proposition: Ask any complex research question in natural language
| Feature | Pharmalyx | PubMed | Semantic Scholar | Elsevier |
|---|---|---|---|---|
| Molecule Grounding & Anchor Preservation | ✅ | ❌ | ❌ | ❌ |
| Multi-Source Aggregation (PubMed + Trials + DrugBank) | ✅ | ❌ | ❌ | Partial |
| Evidence Quality Scoring (EQS) | ✅ | ❌ | Partial | Partial |
| Contradiction Detection (NLI + ContraScore) | ✅ | ❌ | ❌ | ❌ |
| 17 Structured Drug-Repurposing Sections | ✅ | ❌ | ❌ | ❌ |
| PDF Export Pre-Validation Safety | ✅ | ❌ | ❌ | ❌ |
| Dual LLM Switching (Gemini & Groq) | ✅ | ❌ | ❌ | ❌ |
| Mobile & Web Dashboard (Flutter) | ✅ | ❌ | ❌ | ❌ |
┌───────────────────────────────────────────────────────────────────────────┐
│ PHARMALYX PLATFORM │
│ │
│ ┌──────────────────────────┐ ┌────────────────────────────────┐ │
│ │ Flutter Frontend │◄────────►│ FastAPI Gateway │ │
│ │ (Research Chat, Cards) │ REST │ (POST /api/v1/query, Sessions) │ │
│ └──────────────────────────┘ └───────────────┬────────────────┘ │
│ │ │
│ ┌───────────────────────▼──────────────┐ │
│ │ ORCHESTRATOR PIPELINE │ │
│ └──┬──────┬──────┬──────┬──────┬───────┘ │
│ │ │ │ │ │ │
│ ┌──────▼─┐ ┌─▼──┐ ┌─▼──┐ ┌─▼──┐ ┌─▼──┐ ┌────▼┐│
│ │ 1. QUA │ │2.RA│ │3.ERA││4.CDA││5.SA│ │6.RGA││
│ └────────┘ └─┬──┘ └────┘ └────┘ └────┘ └─────┘│
│ │ │
│ ┌────────────────────▼─────────────────────────────┐ │
│ │ EXTERNAL SCIENTIFIC DATA CONNECTORS │ │
│ │ ┌──────────┐ ┌──────────────────┐ ┌──────────┐ │ │
│ │ │ PubMed │ │ClinicalTrials.gov │ │ DrugBank │ │ │
│ │ └──────────┘ └──────────────────┘ └──────────┘ │ │
│ └──────────────────────────────────────────────────┘ │
└───────────────────────────────────────────────────────────────────────────┘
- Frontend Application Layer: Cross-platform Flutter client (
lib/) providing conversational research interactions, interactive evidence cards with component breakdowns, contradiction alert views, and PDF reporting. - Backend API & Gateway Layer: Python FastAPI ASGI server (
backend/) handling request routing, session persistence, response caching, and error boundaries. - Orchestration Layer: Sequential agent manager (
backend/orchestrator/pipeline.py) governing data flow and timing across the 6 specialized AI agents. - Data & Storage Layer: SQLite database (
backend/data/pharmalyx.db) managing multi-turn session histories, request logs, and cached API responses.
To prevent large language models from hallucinating or silently drifting into generic market analysis (e.g. converting "Evaluate Montelukast for pediatric asthma" into generic "Respiratory market overview"), Pharmalyx enforces Strict Molecule Grounding:
{
"grounding": {
"primary_molecule": "Montelukast",
"molecule_identified": true,
"target_indication": "Pediatric Asthma",
"patient_population": "Pediatric Patients (Ages 2-14)",
"therapy_area": "Respiratory",
"geography": "Global",
"time_horizon": "5 Years",
"user_intent": "drug_repurposing"
}
}Every downstream agent (RA, ERA, CDA, SA, RGA) receives and preserves this structured context. If a user query does not specify a molecule (e.g. "What are current oncology trends?"), the system explicitly sets "molecule_identified": false and "primary_molecule": "Unspecified Molecule", stating clearly to the researcher that no specific molecule was identified rather than fabricating one.
User Query ("Montelukast for pediatric asthma")
│
▼
┌──────────────────────────────┐
│ 1. Query Understanding (QUA) │ ──► Extracts Molecule Grounding, Intent & MeSH terms
└──────────────┬───────────────┘
│
▼
┌──────────────────────────────┐
│ 2. Retrieval Agent (RA) │ ──► Fetches PubMed, CT.gov & DrugBank + Source Status Map
└──────────────┬───────────────┘
│
▼
┌──────────────────────────────┐
│ 3. Evidence Ranking (ERA) │ ──► Computes composite EQS Scores (Semantic + Journal IF + Recency + Citations + StudyType)
└──────────────┬───────────────┘
│
▼
┌──────────────────────────────┐
│4. Contradiction Detection (CDA)► Extracts Claims, runs NLI & ContraScore
└──────────────┬───────────────┘
│
▼
┌──────────────────────────────┐
│ 5. Summarisation (SA) │ ──► Abstractive Synthesis across 17 Repurposing Sections with inline citations [1]
└──────────────┬───────────────┘
│
▼
┌──────────────────────────────┐
│ 6. Response Generation (RGA) │ ──► Assembles response, evidence cards & pre-PDF export validation
└──────────────┬───────────────┘
│
▼
Flutter App (Renders Chat, Cards, Alerts & BibTeX)
-
Agent 1: Query Understanding Agent (QUA) (
backend/agents/qua/agent.py)- Classifies intent (
drug_repurposing,evidence_retrieval,drug_interaction,clinical_trial,contradiction_check,drug_comparison,general_summary). - Extracts
MoleculeGrounding(primary_molecule,target_indication,patient_population,therapy_area,geography,time_horizon). - Expands MeSH terms and constructs formatted PubMed query strings.
- Classifies intent (
-
Agent 2: Retrieval Agent (RA) (
backend/agents/retrieval/agent.py)- Executes parallel multi-source document retrieval across PubMed (Entrez XML API), ClinicalTrials.gov v2 REST API, and DrugBank API.
- Tracks source health statuses (
SourceStatus.SUCCESS,UNAVAILABLE,EMPTY,ERROR). - Normalises documents into a unified schema and marks provenance (
is_simulated).
-
Agent 3: Evidence Ranking Agent (ERA) (
backend/agents/ranking/agent.py)- Re-ranks candidate documents using the composite Evidence Quality Score (EQS) formula.
- Evaluates semantic vector similarity, journal impact factor, publication recency, citation count, and study design quality.
-
Agent 4: Contradiction Detection Agent (CDA) (
backend/agents/contradiction/agent.py)- Extracts claim sentences containing pharmaceutical entities and outcome keywords.
- Groups claims by shared entities across documents.
- Performs Natural Language Inference (NLI) pairwise comparisons to calculate
ContraScore. Flags contradictions exceeding threshold$\theta = 0.72$ and generates AI explanations.
-
Agent 5: Summarisation Agent (SA) (
backend/agents/summarisation/agent.py)- Synthesises evidence across all 17 drug repurposing sections with inline citations
[1],[2]. - Extracts key findings and evaluates overall evidence strength.
- Synthesises evidence across all 17 drug repurposing sections with inline citations
-
Agent 6: Response Generation Agent (RGA) (
backend/agents/response/agent.py)- Assembles final
QueryResponsepayload. - Executes pre-PDF export validation checks (
validate_report_for_export). - Formats evidence cards for Flutter rendering, contradiction alerts, suggested follow-up queries, and BibTeX/CSV citations.
- Assembles final
The Evidence Quality Score
Default Component Weights:
-
$\alpha = 0.35$ — Semantic Similarity$\text{Sim}(q,d) = \cos(\mathbf{e}_q, \mathbf{e}_d) \in [0,1]$ -
$\beta = 0.20$ — Normalised Journal Impact Factor$\text{IF}(d) \in [0,1]$ -
$\gamma = 0.15$ — Exponential Publication Recency Decay$\text{Rec}(d) = \exp(-0.1 \times (2025 - \text{year})) \in [0,1]$ -
$\delta = 0.15$ — Normalised Citation Impact$\text{Cite}(d) = \frac{\log(1 + c_d)}{\log(1 + c_{\max})} \in [0,1]$ -
$\varepsilon = 0.15$ — Study Methodology Type Quality Weight$\text{StudyType}(d) \in [0.15, 1.0]$
Study Methodology Hierarchy Weights (
- Meta-Analysis:
$1.0$ - Systematic Review:
$0.9$ - Randomised Controlled Trial (RCT):
$0.8$ - Cohort Study:
$0.6$ - Case-Control Study:
$0.5$ - Cross-Sectional Study:
$0.4$ - Narrative Review:
$0.35$ - In Vitro Laboratory:
$0.3$ - Computational / AI:
$0.25$ - Case Report:
$0.2$
Contradictions between research claims
Threshold: Flag contradiction alert if
Every comprehensive drug-repurposing intelligence report generates insights across 17 structured sections:
- Executive Summary: High-level overview of repurposing potential.
- Molecule Overview: Mechanism of action, drug class, target pathways, and pharmacokinetics.
- Current Approved Uses: Approved indications, dosage forms, and global approvals.
- Target Indication Analysis: Pathophysiology, disease burden, and current standard of care.
- Unmet Medical Need: Gaps in existing therapy that the molecule addresses.
- Clinical Evidence Synthesis: Published studies, efficacy endpoints, and safety with citations.
- Ongoing / Completed Relevant Trials: Active and completed trial summaries from ClinicalTrials.gov.
- Patent / IP Landscape: Primary patent expiry dates, secondary formulation patents, exclusivity timeline.
- Freedom-to-Operate (FTO) Considerations: FTO assessment and potential patent thickets/barriers.
- Market Opportunity: Target market size, growth trajectory, patient population, pricing dynamics.
- Competitive Landscape: Direct and indirect competitors in the target indication.
- Regulatory Feasibility: Regulatory pathway (FDA 505(b)(2) vs 505(j) vs 351(a)), required studies, and timeline.
- Evidence Strength: Rating (Strong / Moderate / Weak / Insufficient) with justification.
- Contradictions & Uncertainties: Summary of conflicting evidence and opposing trial outcomes.
- Risks and Limitations: Safety risks, off-target toxicity, recruitment risks, and evidence gaps.
- Repurposing Opportunity Assessment: Technical, clinical, IP, and commercial viability synthesis.
- Final Decision & Recommendation: Strategic GO / GO-WITH-CAUTION / NO-GO recommendation.
Pharmalyx supports switching between Google Gemini and Groq (Llama-3.3-70b-versatile) LLM providers via environment variables or config toggles.
# LLM Provider Toggles (Set one or both)
USE_GEMINI=true
USE_GROQ=false
# API Keys
GEMINI_API_KEY=your_gemini_api_key
GROQ_API_KEY=your_groq_api_key
# Models
GEMINI_MODEL=gemini-2.5-flash
GROQ_MODEL=llama-3.3-70b-versatile- When
USE_GROQ=true, all LLM generation requests route to Groq's high-speed API. - When
USE_GEMINI=true(default), requests route to Google Gemini API. - Automatic fallback ensures seamless operation if one provider API is unconfigured or rate-limited.
- NCBI PubMed Entrez API (
backend/agents/retrieval/connectors/pubmed.py):- Uses
esearch.fcgito search PMIDs andefetch.fcgito fetch XML abstracts.
- Uses
- ClinicalTrials.gov v2 REST API (
backend/agents/retrieval/connectors/clinicaltrials.py):- Queries
/studiesendpoint by condition and intervention.
- Queries
- DrugBank API (
backend/agents/retrieval/connectors/drugbank.py):- Queries drug indications, mechanisms of action, pharmacokinetics, and drug-drug interactions.
If a data source fails, times out, or returns empty results, the system does NOT crash. The Retrieval Agent records status metrics (source_statuses: { "pubmed": "success", "clinicaltrials": "empty", "drugbank": "unavailable" }), and downstream agents continue with available evidence.
Before generating downloadable PDF research reports, the backend executes strict pre-validation (/api/v1/export/validate):
- Verifies
primary_moleculeis identified and non-empty. - Verifies
target_indicationis specified. - Verifies non-empty evidence cards exist.
- Verifies executive summary is complete.
- Checks that citations point to valid retrieved documents.
If validation fails, the UI blocks PDF export and displays a warning listing missing or incomplete sections, preventing incomplete or scientifically misleading reports.
📌 For a detailed file-by-file reference explaining every file in the project, see PROJECT_FILE_MAP.md.
Cureonix/ (Pharmalyx Platform)
├── README.md # Master product & architecture documentation
├── PROJECT_FILE_MAP.md # Complete file-by-file technical reference
├── pubspec.yaml # Flutter package dependencies
├── start_backend.sh # One-command backend startup script
│
├── backend/ # Python FastAPI 6-Agent AI Pipeline
│ ├── main.py # FastAPI entry point & CORS
│ ├── config.py # Settings & provider flags
│ ├── requirements.txt # Python backend dependencies
│ ├── models/schemas.py # Pydantic schemas (Grounding, 17 sections, validation)
│ ├── services/
│ │ ├── gemini_service.py # Unified LLM Service (Gemini & Groq)
│ │ ├── session_service.py # SQLite session persistence
│ │ └── cache_service.py # Response caching service
│ ├── agents/
│ │ ├── qua/agent.py # Agent 1: QUA (Molecule Grounding)
│ │ ├── retrieval/agent.py # Agent 2: RA (Multi-source + status map)
│ │ ├── retrieval/connectors/ # PubMed, ClinicalTrials, DrugBank connectors
│ │ ├── ranking/agent.py # Agent 3: ERA (EQS Score)
│ │ ├── contradiction/agent.py # Agent 4: CDA (NLI Contradictions)
│ │ ├── summarisation/agent.py # Agent 5: SA (17 Repurposing Sections)
│ │ └── response/agent.py # Agent 6: RGA (Assembly & PDF Validation)
│ ├── orchestrator/pipeline.py # 6-Agent sequential pipeline manager
│ ├── routes/
│ │ ├── query.py # FastAPI research query & session routes
│ │ └── export.py # BibTeX, CSV & PDF pre-validation export endpoints
│ └── tests/test_api.py # Pytest suite (6 integration tests)
│
└── lib/ # Flutter Mobile & Web Application
├── main.dart # App entry point & routes
├── theme/app_theme.dart # Medical light design system
├── models/research_models.dart # Flutter Dart response models
├── services/pharmalyx_api_service.dart # HTTP client to FastAPI backend
├── providers/app_state.dart # State manager (Pharmalyx + Legacy)
└── screens/
├── command_center_screen.dart # Main Intelligence Hub dashboard
├── research_chat_screen.dart # Conversational research chat screen
├── evidence_results_screen.dart# Sortable Evidence Cards screen with EQS
├── contradiction_detail_screen.dart # Contradiction analysis screen
├── main_shell_screen.dart # 5-tab main navigation shell
└── settings_screen.dart # API key & settings
- Python 3.10+
- Flutter 3.19+
git clone https://github.com/sohan10012/Cureonix.git
cd Cureonix
# Copy environment template
cp backend/.env.example backend/.envEdit backend/.env with your API keys:
GEMINI_API_KEY=your_actual_gemini_api_key
PUBMED_API_KEY=your_pubmed_api_key./start_backend.shThe backend server will start on http://localhost:8000.
- OpenAPI Docs:
http://localhost:8000/docs - Health Check:
http://localhost:8000/api/v1/health
In a separate terminal:
flutter pub get
flutter runsource backend/venv/bin/activate
pytest backend/tests/test_api.py -vcurl -X POST "http://localhost:8000/api/v1/query" \
-H "Content-Type: application/json" \
-d '{
"raw_query": "Evaluate the repurposing potential of Montelukast for pediatric asthma, including unmet medical need, clinical trials, patent feasibility, regulatory considerations, and market opportunity.",
"user_preferences": {"verbosity": "standard"}
}'Pharmalyx Platform — Production-Grade AI Pharmaceutical Research Intelligence.