def _get_decorated_classes(directory: str) -> Dict[str, list[Type | Callable]]:
    """Scan directory for decorated classes and functions.

    Args:
        directory (str): The directory to scan.

    Returns:
        Dict[str, list[Type | Callable]]: Dictionary of decorated classes and functions by type.

    Raises:
        ImportError: If any module cannot be imported. This ensures the sync process fails if there
        are any issues.
    """
    components = {
        "sources": [],
        "destinations": [],
        "embedding_models": [],
        "transformers": [],
    }

    base_package = directory.replace("/", ".")

    for root, _, files in os.walk(directory):
        # Skip files in the root directory
        if root == directory:
            continue

        for filename in files:
            if not filename.endswith(".py") or filename.startswith("_"):
                continue

            relative_path = os.path.relpath(root, directory)
            module_path = os.path.join(relative_path, filename[:-3]).replace("/", ".")
            full_module_name = f"{base_package}.{module_path}"

            try:
                module = importlib.import_module(full_module_name)
                _process_module_classes(module, components)
                _process_module_functions(module, components)
            except ImportError as e:
                # Convert the warning into a fatal error to prevent silent failures
                error_msg = (
                    f"Failed to import {full_module_name}: {e}\n"
                    f"This is likely due to missing dependencies required by this module.\n"
                    f"If this module contains transformers, sources, or destinations, they will not"
                    f" be registered."
                )
                sync_logger.error(error_msg)
                # Re-raise the exception to fail the sync process
                raise ImportError(f"Module import failed: {full_module_name}") from e

    return components
Scan directory for decorated classes and functions.

    Args:
        directory (str): The directory to scan.

    Returns:
        Dict[str, list[Type | Callable]]: Dictionary of decorated classes and functions by type.

    Raises:
        ImportError: If any module cannot be imported. This ensures the sync process fails if there
        are any issues.
    
backend/airweave/platform/db_sync.py