# 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) ```bash python main.py ``` ### Option 2: Legacy Monolithic Version ```bash python app.py ``` ## ๐Ÿ“ Module Descriptions ### `src/molecules/` - **`analysis.py`**: Molecular property calculations, SMILES validation, drug-likeness assessment - **`variations.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 interface - **`handlers.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 1. **Maintainability**: Each module has a single responsibility 2. **Testability**: Individual modules can be tested in isolation 3. **Scalability**: Easy to add new features without affecting existing code 4. **Readability**: Clear separation of concerns 5. **Reusability**: Components can be reused across different parts of the app 6. **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