"""Feature flags for the backend — reads content/features.json.""" import json from functools import lru_cache from pathlib import Path FEATURES_PATH = Path(__file__).resolve().parent.parent.parent / "content" / "features.json" @lru_cache def get_features() -> dict: if not FEATURES_PATH.exists(): return {} with open(FEATURES_PATH, encoding="utf-8") as f: return json.load(f) def is_enabled(path: str) -> bool: """Check a dot-separated feature path, e.g. 'payment.crypto.enabled'.""" obj = get_features() for key in path.split("."): if isinstance(obj, dict): obj = obj.get(key) else: return False return bool(obj)