"""Config for kg_ocr: graph traversal defaults and Neo4j credentials.

Environment variables: NEO4J_URI, NEO4J_USER, NEO4J_PASSWORD.
"""

from __future__ import annotations

import os
from dataclasses import dataclass, field


@dataclass(frozen=True)
class KgConfig:
    """Tunables for graph building/traversal plus Neo4j connection."""

    # Traversal
    expand_limit: int = 5
    related_limit: int = 10

    # Neo4j
    neo4j_uri: str = "bolt://localhost:7687"
    neo4j_user: str = "neo4j"
    neo4j_password: str = field(default="", repr=False)

    @classmethod
    def from_env(cls) -> KgConfig:
        return cls(
            neo4j_uri=os.environ.get("NEO4J_URI", cls.neo4j_uri),
            neo4j_user=os.environ.get("NEO4J_USER", cls.neo4j_user),
            neo4j_password=os.environ.get("NEO4J_PASSWORD", ""),
        )
