from .infrastructure import initialize_infrastructure
from .demo_school import initialize_demo_school
from .demo_users import initialize_demo_users
from .gais_data import import_gais_data
from modules.logger_tool import initialise_logger
import os

logger = initialise_logger(__name__, os.getenv("LOG_LEVEL"), os.getenv("LOG_PATH"), 'default', True)

def initialize_infrastructure_mode() -> None:
    """Initialize infrastructure: Neo4j schema, calendar, and Supabase buckets"""
    logger.info("Starting infrastructure initialization...")
    
    # 1. Initialize Neo4j database, schema, and calendar structure
    logger.info("Step 1: Initializing Neo4j infrastructure...")
    from .neo4j import initialize_neo4j
    neo4j_result = initialize_neo4j()
    
    if not neo4j_result["success"]:
        logger.error(f"Neo4j infrastructure initialization failed: {neo4j_result['message']}")
        return
    
    # 2. Initialize Supabase storage buckets
    logger.info("Step 2: Initializing Supabase storage buckets...")
    from .buckets import initialize_buckets
    buckets_result = initialize_buckets()
    
    if not buckets_result["success"]:
        logger.error(f"Storage buckets initialization failed: {buckets_result['message']}")
        return
    
    logger.info("Infrastructure initialization completed successfully!")
    logger.info(f"Neo4j: {neo4j_result['message']}")
    logger.info(f"Buckets: {buckets_result['message']}")

def initialize_demo_school_mode() -> None:
    """Initialize demo school (KevlarAI)"""
    logger.info("Starting demo school initialization...")
    result = initialize_demo_school()
    
    if result["success"]:
        logger.info("Demo school initialization completed successfully")
    else:
        logger.error(f"Demo school initialization failed: {result['message']}")

def initialize_demo_users_mode() -> None:
    """Initialize demo users"""
    logger.info("Starting demo users initialization...")
    result = initialize_demo_users()
    
    if result["success"]:
        logger.info("Demo users initialization completed successfully")
    else:
        logger.error(f"Demo users initialization failed: {result['message']}")

def initialize_gais_data_mode() -> None:
    """Initialize GAIS data import (Edubase, etc.)"""
    logger.info("Starting GAIS data import...")
    result = import_gais_data()
    
    if result["success"]:
        logger.info("GAIS data import completed successfully")
    else:
        logger.error(f"GAIS data import failed: {result['message']}")

__all__ = [
    'initialize_infrastructure_mode',
    'initialize_demo_school_mode',
    'initialize_demo_users_mode',
    'initialize_gais_data_mode',
    'initialize_infrastructure',
    'initialize_demo_school',
    'initialize_demo_users',
    'import_gais_data'
] 