"""Database package for the Aniworld web application.

This package provides SQLAlchemy models, database connection management,
and session handling for persistent storage.

Modules:
    - models: SQLAlchemy ORM models for anime series, episodes, download queue, and sessions
    - connection: Database engine and session factory configuration
    - base: Base class for all SQLAlchemy models

Usage:
    from src.server.database import get_db_session, init_db
    
    # Initialize database on application startup
    init_db()
    
    # Use in FastAPI endpoints
    @app.get("/anime")
    async def get_anime(db: AsyncSession = Depends(get_db_session)):
        result = await db.execute(select(AnimeSeries))
        return result.scalars().all()
"""

from src.server.database.base import Base
from src.server.database.connection import close_db, get_db_session, init_db
from src.server.database.init import (
    CURRENT_SCHEMA_VERSION,
    EXPECTED_TABLES,
    check_database_health,
    create_database_backup,
    create_database_schema,
    get_database_info,
    get_schema_version,
    initialize_database,
    seed_initial_data,
    validate_database_schema,
)
from src.server.database.models import (
    AnimeSeries,
    DownloadQueueItem,
    Episode,
    SystemSettings,
    UserSession,
)
from src.server.database.service import (
    AnimeSeriesService,
    DownloadQueueService,
    EpisodeService,
    UserSessionService,
)
from src.server.database.system_settings_service import SystemSettingsService

__all__ = [
    # Base and connection
    "Base",
    "get_db_session",
    "init_db",
    "close_db",
    # Initialization functions
    "initialize_database",
    "create_database_schema",
    "validate_database_schema",
    "get_schema_version",
    "seed_initial_data",
    "check_database_health",
    "create_database_backup",
    "get_database_info",
    "CURRENT_SCHEMA_VERSION",
    "EXPECTED_TABLES",
    # Models
    "AnimeSeries",
    "Episode",
    "DownloadQueueItem",
    "SystemSettings",
    "UserSession",
    # Services
    "AnimeSeriesService",
    "EpisodeService",
    "DownloadQueueService",
    "SystemSettingsService",
    "UserSessionService",
]
