Skip to content

ANJAN672/PharmaGEN

Repository files navigation

PharmaGEN

🧬 PharmaGEN is a production-ready multilingual medical assistant and hypothetical drug concept generator powered by Google's Gemini AI. It allows users to describe their symptoms and allergies in their preferred language, then generates a conceptual diagnosis and hypothetical drug treatment.

✨ Features

  • Multilingual Support: Communicate in 20+ languages including English, Hindi, Spanish, German, French, and more
  • AI-Powered Diagnosis: Analyze symptoms to generate conceptual medical diagnoses
  • Hypothetical Drug Generation: Create theoretical new drug concepts based on the diagnosis
  • PDF Report Generation: Download a formatted medical report in your preferred language
  • Production-Ready: Rate limiting, caching, error handling, and logging
  • Responsive UI: Modern, user-friendly interface with real-time translation
  • Docker Support: Easy deployment with Docker and Docker Compose

🐍 Python Version

Required (pyproject): Python 3.10+ β€” Recommended: Python 3.11.x

  • Performance: 10-60% faster than Python 3.10
  • Stability: Production-ready with long-term support until October 2027
  • Compatibility: Full support for all dependencies
  • Minimum: Python 3.10 (project metadata enforces ^3.10)

⚠️ Important Disclaimer

This application is for informational and conceptual purposes only.

  • AI-Generated Diagnosis: The diagnosis provided is AI-generated and may not be accurate. Always consult a qualified medical professional for any health concerns.
  • Hypothetical Drug Concepts: The drug compounds suggested are NEW, HYPOTHETICAL CONCEPTS generated by AI. They are not real, tested, safe, or approved medications.
  • Safety Notes: Allergy and side effect notes are theoretical AI assessments. They are not a substitute for professional medical advice.

πŸš€ Quick Start

Pick the workflow that matches your toolchain. All options share the same environment steps for configuring the Gemini API key.

Option A: ⚑ uv (Fastest install, works everywhere)

# 1. Make sure you're inside the project folder
cd /path/to/PharmaGEN

# 2. (Optional) Install/manage the Python runtime
uv python install 3.11

# 3. Create an isolated .venv managed by uv (safe for other projects)
uv venv --python 3.11 .venv               # reuse existing env
# If prompted about an existing .venv, rerun: uv venv --clear
.venv\Scripts\activate
# 4. Install requirements into that .venv
uv pip install -r requirements.txt

# 5. Prevent PyFPDF/fpdf2 namespace conflicts (safe to run even if PyFPDF isn't installed)
uv pip uninstall -y pyfpdf   # ignore message if package isn't installed

# 6. Copy the environment template and add your Gemini key
copy example.env .env        # Windows
cp example.env .env          # macOS / Linux

# 7. Run the production build using the new .venv
uv run pharmagen             # or: uv run python app_production.py

Option B: πŸͺ„ Poetry

cd /path/to/PharmaGEN
poetry env use 3.11
poetry install               # installs from poetry.lock

copy example.env .env        # Windows
cp example.env .env          # macOS / Linux

poetry run pharmagen         # or: poetry run python app_production.py

Option C: 🐍 Pip / Conda (legacy fallback)

# Create + activate an environment with Python β‰₯3.10 (3.11 preferred)
python -m venv .venv         # or: conda create -n pharmagen python=3.11 -y
.venv\Scripts\activate       # Windows
source .venv/bin/activate    # macOS / Linux / WSL

pip install -r requirements.txt
copy example.env .env        # Windows
cp example.env .env          # macOS / Linux

python app_production.py

Option D: 🐳 Docker

docker-compose up -d
# Access at http://localhost:7860

πŸ“¦ Dependency Management Cheat Sheet

  • Create/refresh .venv (uv): uv venv (add --clear to rebuild from scratch)
  • Install / update (uv): uv sync (add --extra redis for Redis features, --no-dev for runtime-only)
  • Install requirements only (uv): uv pip install -r requirements.txt
  • Install / update (Poetry): poetry install / poetry add <package>
  • Add a dependency: uv add <package> or poetry add <package> (both update pyproject.toml + poetry.lock)
  • Run the app without activating a venv: uv run pharmagen or poetry run pharmagen
  • Check the lockfile is current: uv lock --check or poetry lock --check

πŸ“š Documentation

🌐 Deployment Options

Cloud Platforms (Easy)

  • Hugging Face Spaces - Free, easiest option
  • Railway.app - Simple deployment with free tier
  • Google Cloud Run - Scalable, pay-per-use
  • AWS / Azure - Enterprise-grade
  • DigitalOcean - VPS with full control

Docker (Recommended)

# Build and run with Docker Compose
docker-compose up -d

# View logs
docker-compose logs -f

# Stop
docker-compose down

See DEPLOYMENT.md for detailed instructions.

🎯 Usage

  1. Select Language: Type your preferred language (e.g., "English", "Hindi", "Spanish")
  2. Describe Symptoms: Enter your symptoms when prompted
  3. Mention Allergies: Provide any allergies or type "None"
  4. View Results: Get AI-generated diagnosis and drug concept
  5. Ask Questions: Continue conversation for more details
  6. Download Report: Click "Download PDF Report" button

πŸ”§ Configuration

Key environment variables in .env:

# Required
GEMINI_API_KEY=your-api-key-here

# Optional - Production Features
RATE_LIMIT_ENABLED=True
RATE_LIMIT_PER_MINUTE=10
REDIS_ENABLED=False
CACHE_ENABLED=True
LOG_LEVEL=INFO
SERVER_PORT=7860

πŸ†• What's New in Production Version

app_production.py Features:

  • βœ… Rate Limiting: Prevent abuse (10 req/min, 100 req/hour)
  • βœ… Caching: 50-70% reduction in API calls
  • βœ… Error Handling: Graceful degradation
  • βœ… Logging: Comprehensive activity logs
  • βœ… Security: Input sanitization, API key protection
  • βœ… Redis Support: Distributed caching (optional)
  • βœ… Session Management: Per-user tracking
  • βœ… Health Checks: Docker health monitoring

See IMPROVEMENTS.md for complete list.

πŸ“¦ Project Structure

PharmaGEN/
β”œβ”€β”€ app.py                 # Original application
β”œβ”€β”€ app_production.py      # Production-ready version
β”œβ”€β”€ config.py              # Configuration management
β”œβ”€β”€ pyproject.toml        # Project metadata (Poetry / uv)
β”œβ”€β”€ poetry.lock           # Resolved dependency lockfile
β”œβ”€β”€ requirements.txt      # Legacy pip fallback dependencies
β”œβ”€β”€ example.env           # Environment template
β”œβ”€β”€ Dockerfile            # Container configuration
β”œβ”€β”€ docker-compose.yml    # Multi-container setup
β”œβ”€β”€ QUICKSTART.md         # 5-minute setup guide
β”œβ”€β”€ DEPLOYMENT.md         # Full deployment guide
β”œβ”€β”€ IMPROVEMENTS.md       # What's new
└── README.md            # This file

πŸ”’ Security Best Practices

  1. βœ… Never commit .env file to Git
  2. βœ… Use environment variables for API keys
  3. βœ… Enable rate limiting in production
  4. βœ… Use HTTPS for public deployments
  5. βœ… Keep dependencies updated
  6. βœ… Monitor logs regularly

πŸ› Troubleshooting

Common Issues

API Key Error:

# Check .env file
cat .env | grep GEMINI_API_KEY

Port Already in Use:

# Change port in .env
SERVER_PORT=8080

Module Not Found:

# Reinstall dependencies inside the uv-managed .venv
uv pip install -r requirements.txt

PDF conflict warning (PyFPDF vs fpdf2):

uv pip uninstall -y pyfpdf
uv pip install --upgrade fpdf2

See DEPLOYMENT.md for more troubleshooting.

πŸ“Š Performance

With Production Features:

  • Response Time: 40-60% faster (with caching)
  • API Costs: 50-70% reduction
  • Uptime: 99%+ (with proper deployment)
  • Concurrent Users: 100+ (with Redis)

🀝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

See CONTRIBUTING.md for guidelines.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support

  • Documentation: See QUICKSTART.md and DEPLOYMENT.md
  • Issues: Open an issue on GitHub
  • Discussions: Use GitHub Discussions

πŸ—ΊοΈ Roadmap

  • User authentication
  • Database integration for history
  • Advanced analytics dashboard
  • Multi-model support (GPT-4, Claude)
  • Voice input/output
  • Mobile app
  • API endpoints

Ready to deploy? See DEPLOYMENT.md for step-by-step instructions!

About

Gemini x Medical AI Assistant

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors