async def sync_platform_components(platform_dir: str, db: AsyncSession) -> None:
    """Sync all platform components with the database.

    Args:
        platform_dir (str): Directory containing platform components
        db (AsyncSession): Database session

    Raises:
        Exception: If any part of the sync process fails, with detailed error messages to help
        diagnose the issue
    """
    sync_logger.info("Starting platform components sync...")

    try:
        components = _get_decorated_classes(platform_dir)
        c = components

        # Log component counts to help diagnose issues
        sync_logger.info(
            f"Found {len(c['sources'])} sources, {len(c['destinations'])} destinations, "
            f"{len(c['embedding_models'])} embedding models, {len(c['transformers'])} transformers."
        )

        # First sync entities to get their IDs
        module_entity_map = await _sync_entity_definitions(db)

        await _sync_embedding_models(db, components["embedding_models"])
        await _sync_sources(db, components["sources"], module_entity_map)
        await _sync_destinations(db, components["destinations"])
        await _sync_transformers(db, components["transformers"], module_entity_map)

        sync_logger.info("Platform components sync completed successfully.")
    except ImportError as e:
        sync_logger.error(f"Platform sync failed due to import error: {e}")
        sync_logger.error(
            "Check that all required dependencies are installed and all modules can be imported."
        )
        raise
    except Exception as e:
        sync_logger.error(f"Platform sync failed with error: {e}")
        sync_logger.error("Check for detailed error messages above to identify the specific issue.")
        raise
Sync all platform components with the database.

    Args:
        platform_dir (str): Directory containing platform components
        db (AsyncSession): Database session

    Raises:
        Exception: If any part of the sync process fails, with detailed error messages to help
        diagnose the issue
    
backend/airweave/platform/db_sync.py