async def _sync_sources(
    db: AsyncSession, sources: list[Type[BaseSource]], module_entity_map: Dict[str, dict]
) -> None:
    """Sync sources with the database.

    Args:
    -----
        db (AsyncSession): Database session
        sources (list[Type[BaseSource]]): List of source classes
        module_entity_map (Dict[str, dict]): Mapping of module names to entity definitions
    """
    sync_logger.info("Syncing sources to database.")

    source_definitions = []
    for source_class in sources:
        # Get the source's short name (e.g., "slack" for SlackSource)
        source_module_name = source_class._short_name

        # Get entity IDs for this module
        output_entity_ids = []
        if source_module_name in module_entity_map:
            output_entity_ids = [
                UUID(id) for id in module_entity_map[source_module_name].get("entity_ids", [])
            ]

        source_def = schemas.SourceCreate(
            name=source_class._name,
            description=source_class.__doc__,
            auth_type=source_class._auth_type,
            auth_config_class=source_class._auth_config_class,
            config_class=source_class._config_class,
            short_name=source_class._short_name,
            class_name=source_class.__name__,
            output_entity_definition_ids=output_entity_ids,
            labels=getattr(source_class, "_labels", []),
        )
        source_definitions.append(source_def)

    await crud.source.sync(db, source_definitions)
    sync_logger.info(f"Synced {len(source_definitions)} sources to database.")
Sync sources with the database.

    Args:
    -----
        db (AsyncSession): Database session
        sources (list[Type[BaseSource]]): List of source classes
        module_entity_map (Dict[str, dict]): Mapping of module names to entity definitions
    
backend/airweave/platform/db_sync.py