File size: 3,590 Bytes
43e7ae4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# 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
|