Skip to content

ML-dev-crypto/moleculeX

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

MoleculeX ๐Ÿงฌ# MoleculeX ๐Ÿงฌ

AI-powered pharmaceutical intelligence platform for discovering clinical trials, analyzing patent landscapes, and exploring scientific literature.AI-Driven Pharmaceutical Insight Discovery Platform

---MoleculeX is a sophisticated web application that leverages multi-agent AI systems to analyze pharmaceutical opportunities, clinical trials, patents, and market intelligence. Built with FastAPI and React, it provides real-time analysis with beautiful animations and downloadable PDF reports.

๐Ÿš€ Quick Start---

Backend## ๐ŸŽฏ Features

cd backend- **Multi-Agent Analysis**: Master agent orchestrates specialized workers (Clinical Trials, Patent, Web Intelligence)

python -m venv venv- **Real-Time Updates**: WebSocket-powered live progress tracking

venv\Scripts\activate  # Windows: venv\Scripts\activate | Mac/Linux: source venv/bin/activate- **Clinical Trial Data**: Live integration with ClinicalTrials.gov API

pip install -r requirements.txt- **Beautiful UI**: Smooth Framer Motion animations with TailwindCSS styling

uvicorn main:app --reload- **PDF Reports**: Comprehensive analysis reports with professional formatting

```- **No Database Required**: Simple JSON file-based job storage

Backend runs at: **http://localhost:8000**  - **No Docker Required**: Easy local setup and deployment

API docs: **http://localhost:8000/docs**

---

### Frontend

```bash## ๐Ÿ—๏ธ Architecture

cd frontend

npm install### Backend (FastAPI)

npm run dev```

```backend/

Frontend runs at: **http://localhost:5173**โ”œโ”€โ”€ main.py                 # FastAPI app entry point

โ”œโ”€โ”€ routes.py              # API endpoints

---โ”œโ”€โ”€ models.py              # Pydantic data models

โ”œโ”€โ”€ job_manager.py         # Job lifecycle management

## โœจ Featuresโ”œโ”€โ”€ master_agent.py        # Master orchestrator

โ”œโ”€โ”€ websocket_manager.py   # WebSocket connection handler

- ๐Ÿ”ฌ **Clinical Trials Search** - Live ClinicalTrials.gov integrationโ”œโ”€โ”€ report_generator.py    # PDF generation

- ๐Ÿ“„ **Patent Analysis** - Patent landscape insightsโ”œโ”€โ”€ agents/

- ๐ŸŒ **Web Intelligence** - Scientific literature analysisโ”‚   โ”œโ”€โ”€ clinical_trials_agent.py  # ClinicalTrials.gov integration

- ๐Ÿ“Š **Real-time Updates** - WebSocket-powered progress trackingโ”‚   โ”œโ”€โ”€ patent_agent.py           # Patent search (placeholder)

- ๐Ÿ“ˆ **PDF Reports** - Professional analysis reportsโ”‚   โ””โ”€โ”€ web_intel_agent.py        # Web intelligence (placeholder)

- ๐ŸŽจ **Beautiful UI** - Smooth animations with Framer Motionโ”œโ”€โ”€ templates/

โ”‚   โ””โ”€โ”€ report_template.html      # Jinja2 PDF template

---โ””โ”€โ”€ data/

    โ”œโ”€โ”€ jobs/              # Job state (JSON files)

## ๐Ÿ—๏ธ Project Structure    โ””โ”€โ”€ reports/           # Generated PDF reports

moleculeX/### Frontend (React + Vite)

โ”œโ”€โ”€ backend/              # FastAPI backend```

โ”‚   โ”œโ”€โ”€ main.py          # Application entryfrontend/

โ”‚   โ”œโ”€โ”€ agents/          # Specialized agentsโ”œโ”€โ”€ src/

โ”‚   โ”œโ”€โ”€ data/            # Jobs & reportsโ”‚   โ”œโ”€โ”€ App.jsx                    # Main application

โ”‚   โ””โ”€โ”€ templates/       # PDF templatesโ”‚   โ”œโ”€โ”€ components/

โ””โ”€โ”€ frontend/            # React frontendโ”‚   โ”‚   โ”œโ”€โ”€ QueryCard.jsx         # Query input with examples

    โ””โ”€โ”€ src/โ”‚   โ”‚   โ”œโ”€โ”€ AgentStatusRow.jsx    # Agent progress chips

        โ”œโ”€โ”€ components/  # UI componentsโ”‚   โ”‚   โ”œโ”€โ”€ ResultsPanel.jsx      # Results display

        โ”œโ”€โ”€ api/         # API clientโ”‚   โ”‚   โ””โ”€โ”€ ReportDownload.jsx    # PDF download button

        โ””โ”€โ”€ App.jsx      # Main appโ”‚   โ”œโ”€โ”€ api/

```โ”‚   โ”‚   โ””โ”€โ”€ client.js             # Axios API client

โ”‚   โ””โ”€โ”€ hooks/

---โ”‚       โ””โ”€โ”€ useWebSocket.js       # WebSocket hook

โ”œโ”€โ”€ index.html

## ๐Ÿ“– Usageโ”œโ”€โ”€ vite.config.js

โ”œโ”€โ”€ tailwind.config.js

1. **Enter Query**: Type your pharmaceutical research questionโ””โ”€โ”€ package.json

2. **Watch Progress**: Real-time agent status updates```

3. **Review Results**: Interactive results with detailed insights

4. **Download Report**: Get professionally formatted PDF---



### Example Queries## ๐Ÿš€ Quick Start

- "Which respiratory diseases show low competition but high patient burden in India?"

- "What are emerging opportunities in cardiovascular drug development?"### Prerequisites

- "Find unmet medical needs in oncology with recent patent activity"- Python 3.9+

- Node.js 18+

---- npm or yarn



## ๐Ÿ”Œ Key API Endpoints### Backend Setup



```http1. **Navigate to backend directory:**

POST /api/query          # Submit new query   ```bash

GET  /api/status/{id}    # Get job status   cd backend

GET  /api/result/{id}    # Get results   ```

WS   /ws/jobs/{id}       # Real-time updates

GET  /api/reports/{id}   # Download PDF2. **Create virtual environment:**

```   ```bash

   python -m venv venv

Full API documentation: **http://localhost:8000/docs**   ```



---3. **Activate virtual environment:**

   - Windows:

## ๐Ÿ› ๏ธ Tech Stack     ```cmd

     venv\Scripts\activate

- **Backend**: FastAPI, Python 3.11, WebSockets     ```

- **Frontend**: React 18, Vite 5, TailwindCSS 3, Framer Motion   - Mac/Linux:

- **APIs**: ClinicalTrials.gov     ```bash

- **Storage**: JSON-based job storage     source venv/bin/activate

     ```

---

4. **Install dependencies:**

## ๐Ÿ› Troubleshooting   ```bash

   pip install -r requirements.txt

**Port already in use:**   ```

```bash

# Windows5. **Run the FastAPI server:**

netstat -ano | findstr :8000   ```bash

taskkill /PID <PID> /F   python main.py

Mac/Linux

lsof -ti:8000 | xargs kill -9 The API will be available at http://localhost:8000

``` - API docs: http://localhost:8000/docs

  • Health check: http://localhost:8000/

Module not found:


# Activate venv and reinstall

pip install -r requirements.txt1. **Navigate to frontend directory:**

```   ```bash

   cd frontend

**WebSocket issues:**   ```

- Ensure backend is running on port 8000

- Check browser console for errors2. **Install dependencies:**

   ```bash

---   npm install

๐Ÿ“ License

  1. Run the development server:

ยฉ 2025 MoleculeX. All rights reserved. ```bash

npm run dev

--- ```

Built for pharmaceutical researchers with โค๏ธ The app will be available at http://localhost:5173


๐Ÿ“– Usage

1. Enter Your Query

Type a pharmaceutical research question, such as:

  • "Which respiratory diseases show low competition but high patient burden in India?"
  • "What are the emerging opportunities in cardiovascular drug development in Asia?"
  • "Find unmet medical needs in oncology with recent patent activity"

2. Watch Agent Progress

Real-time status updates show each agent's progress:

  • ๐ŸŽฏ Master Agent: Query analysis and orchestration
  • ๐Ÿ”ฌ Clinical Trials Agent: Fetching live data from ClinicalTrials.gov
  • ๐Ÿ“„ Patent Agent: Patent landscape analysis
  • ๐ŸŒ Web Intel Agent: Market intelligence gathering

3. Review Results

Interactive results panel with:

  • Executive summary
  • Key findings
  • Clinical trials table
  • Patent landscape
  • Web intelligence sources

4. Download Report

Get a professionally formatted PDF report with all findings.


๐Ÿ”Œ API Endpoints

Query Submission

POST /api/query
Content-Type: application/json

{
  "query": "Your pharmaceutical research question"
}

Response: {
  "job_id": "uuid",
  "status": "queued",
  "message": "Query submitted successfully",
  "created_at": "2024-01-01T00:00:00"
}

Job Status

GET /api/status/{job_id}

Response: {
  "job_id": "uuid",
  "status": "running",
  "query": "...",
  "agents": [...],
  "progress": 45,
  "created_at": "...",
  "updated_at": "..."
}

Job Results

GET /api/result/{job_id}

Response: {
  "job_id": "uuid",
  "query": "...",
  "executive_summary": "...",
  "key_findings": [...],
  "clinical_trials": [...],
  "patents": [...],
  "web_intel": [...],
  "report_url": "/api/reports/job_{id}.pdf"
}

WebSocket

ws://localhost:8000/ws/jobs/{job_id}

Messages: {
  "job_id": "uuid",
  "event_type": "agent_update",
  "data": {...},
  "timestamp": "..."
}

Download Report

GET /api/reports/job_{job_id}.pdf

๐ŸŽจ UI Components

QueryCard

  • Large textarea for query input
  • 4 example queries with click-to-fill
  • Animated submit button with loading state

AgentStatusRow

  • 4 agent status chips with icons
  • Color-coded status (idle/running/completed/failed)
  • Pulse animation for running agents
  • Result count display

ResultsPanel

  • Slide-in animation from right
  • Collapsible sections
  • Interactive data tables
  • Color-coded trial statuses

ReportDownload

  • Pulsing download button
  • Animated PDF icon
  • One-click report download

๐Ÿ”ง Configuration

Backend Configuration

Edit backend/main.py:

# CORS origins
allow_origins=["http://localhost:5173", "http://localhost:3000"]

# Server port
uvicorn.run("main:app", host="0.0.0.0", port=8000)

Frontend Configuration

Edit frontend/vite.config.js:

server: {
  port: 5173,
  proxy: {
    '/api': 'http://localhost:8000',
    '/ws': 'ws://localhost:8000'
  }
}

๐Ÿงช Testing Example Queries

  1. Competition Analysis:

    Which respiratory diseases show low competition but high patient burden in India?
    
  2. Opportunity Detection:

    What are the emerging opportunities in cardiovascular drug development?
    
  3. Clinical Trial Analysis:

    Show me clinical trials for diabetes treatments with less than 5 active competitors
    
  4. Market Research:

    Find unmet medical needs in oncology with recent patent activity
    

๐Ÿ“Š Data Sources

Phase 1 (Current)

  • โœ… ClinicalTrials.gov API: Live clinical trial data (no API key required)
  • ๐Ÿ”„ Patent Agent: Placeholder with dummy data
  • ๐Ÿ”„ Web Intel Agent: Placeholder with dummy data

Future Enhancements

  • ๐Ÿ”ฎ USPTO Patent API integration
  • ๐Ÿ”ฎ PubMed/NIH research paper analysis
  • ๐Ÿ”ฎ WHO disease burden statistics
  • ๐Ÿ”ฎ FDA drug approval databases

๐Ÿ› Troubleshooting

Backend Issues

"Module not found" error:

# Ensure virtual environment is activated
# Then reinstall dependencies
pip install -r requirements.txt

"Port 8000 already in use":

# Find and kill the process
# Windows:
netstat -ano | findstr :8000
taskkill /PID <PID> /F

# Mac/Linux:
lsof -ti:8000 | xargs kill -9

PDF generation fails:

# Install WeasyPrint dependencies (Windows)
# WeasyPrint requires GTK3
# Fallback to xhtml2pdf will be used automatically

Frontend Issues

"npm install" fails:

# Clear npm cache
npm cache clean --force
# Delete node_modules and package-lock.json
rm -rf node_modules package-lock.json
# Reinstall
npm install

WebSocket connection fails:

  • Ensure backend is running on port 8000
  • Check browser console for CORS errors
  • Verify WebSocket URL in useWebSocket.js

๐Ÿšข Deployment

Backend Deployment

# Production server
pip install gunicorn
gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000

Frontend Deployment

# Build for production
npm run build

# Serve static files
npm install -g serve
serve -s dist -p 5173

๐Ÿ“ License

MIT License - feel free to use this for your pharmaceutical research projects!


๐Ÿค Contributing

Contributions welcome! Areas for improvement:

  • Additional worker agents (Patent API, PubMed integration)
  • Enhanced NLP for query parsing
  • Database integration for job persistence
  • User authentication and history
  • Export to multiple formats (Excel, CSV)
  • Advanced data visualization charts

๐Ÿ“ง Support

For issues and questions:

  • Open an issue on GitHub
  • Check API documentation at /docs
  • Review logs in backend console

Built with โค๏ธ for pharmaceutical researchers

MoleculeX - Discovering pharmaceutical insights through AI-powered multi-agent analysis

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 66.9%
  • Python 30.0%
  • HTML 2.4%
  • CSS 0.7%