Joey / README_MODULAR.md
Joey Callanan
Creating new Space
43e7ae4

A newer version of the Gradio SDK is available: 6.2.0

Upgrade

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 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