from __future__ import annotations

from app.core.database import is_db_ready
from app.core.redis_client import is_redis_ready
from app.qdrant.health import is_qdrant_ready


async def readiness_payload() -> tuple[dict, int]:
    mongo_ok = await is_db_ready()
    redis_ok = await is_redis_ready()
    qdrant_ok = await is_qdrant_ready()
    checks = {"mongo": mongo_ok, "redis": redis_ok, "qdrant": qdrant_ok}
    all_ok = all(checks.values())
    body = {
        "status": "ready" if all_ok else "not_ready",
        "checks": checks,
    }
    return body, 200 if all_ok else 503
