A newer version of the Gradio SDK is available:
6.2.0
HITL Drug Discovery - Modular Architecture
ποΈ Project Structure
HITL_Drug_Discovery/
βββ main.py # Main entry point
βββ app.py # Legacy monolithic app (backup)
βββ requirements.txt # Dependencies
βββ README.md # Original README
βββ README_MODULAR.md # This file
βββ src/ # Modular source code
βββ __init__.py
βββ app.py # Main application orchestrator
βββ molecules/ # Molecular analysis and variations
β βββ __init__.py
β βββ analysis.py # Molecular property calculations
β βββ variations.py # Structure variation generation
βββ ai/ # AI services
β βββ __init__.py
β βββ services.py # AI chat and structure generation
βββ ui/ # UI components and handlers
β βββ __init__.py
β βββ components.py # UI component definitions
β βββ handlers.py # Event handlers and business logic
βββ config/ # Configuration and settings
βββ __init__.py
βββ settings.py # App configuration and constants
π Running the Application
Option 1: Modular Version (Recommended)
python main.py
Option 2: Legacy Monolithic Version
python app.py
π Module Descriptions
src/molecules/
analysis.py: Molecular property calculations, SMILES validation, drug-likeness assessmentvariations.py: Generation of multiple molecular structure visualizations
src/ai/
services.py: AI-powered chat responses and structure generation using OpenAI GPT-OSS-20B
src/ui/
components.py: Reusable UI component definitions for Gradio interfacehandlers.py: Event handlers, business logic, and state management
src/config/
settings.py: Application configuration, constants, and styling
src/app.py
- Main orchestrator: Ties all modules together and creates the Gradio interface
π§ Benefits of Modular Architecture
- Maintainability: Each module has a single responsibility
- Testability: Individual modules can be tested in isolation
- Scalability: Easy to add new features without affecting existing code
- Readability: Clear separation of concerns
- Reusability: Components can be reused across different parts of the app
- Professional: Industry-standard project structure
π§ͺ Key Features
- Molecular Analysis: SMILES validation, property calculations, drug-likeness assessment
- Chemical Variations: Multiple visualization styles and rendering options
- AI Structure Generation: AI-powered molecular structure suggestions
- Interactive UI: Clean, modern interface with real-time feedback
- Bookmarking: Save and manage favorite molecular structures
π Migration from Monolithic
The original app.py (1082 lines) has been refactored into:
- 6 focused modules with clear responsibilities
- ~200 lines per module for better maintainability
- Clean imports and dependencies
- Preserved functionality with improved organization
π Future Enhancements
With the modular structure, it's now easy to:
- Add new molecular analysis algorithms
- Implement additional AI models
- Create new UI components
- Add database integration
- Implement user authentication
- Add API endpoints
- Create unit tests for each module