Add feature-profile endpoint and env-driven optional router profiles

- Add ALWRITY_FEATURE_PROFILE env var (precedence over ALWRITY_ROUTER_PROFILE)
- Add OPTIONAL_MODULE_MATRIX defining 'all' and 'default' profiles
- Add get_feature_profile_status() to RouterManager
- Add GET /api/feature-profile/status endpoint in main.py and app.py
- Returns active profile and enabled optional modules
This commit is contained in:
ajaysi
2026-03-31 15:15:50 +05:30
parent c7013a71df
commit dee4387b0b
3 changed files with 27 additions and 1 deletions

View File

@@ -66,6 +66,11 @@ OPTIONAL_ROUTER_REGISTRY = [
{"name": "today_workflow", "module": "api.today_workflow", "attr": "router", "profiles": {"all", "default"}},
]
OPTIONAL_MODULE_MATRIX = {
"all": [entry["name"] for entry in OPTIONAL_ROUTER_REGISTRY],
"default": [entry["name"] for entry in OPTIONAL_ROUTER_REGISTRY],
}
class RouterManager:
"""Manages FastAPI router inclusion and organization."""
@@ -79,7 +84,7 @@ class RouterManager:
return os.getenv("ALWRITY_VERBOSE", "false").lower() == "true"
def _get_profile(self) -> str:
return os.getenv("ALWRITY_ROUTER_PROFILE", os.getenv("ALWRITY_FEATURE_TO_ENABLE", "all")).strip().lower() or "all"
return os.getenv("ALWRITY_FEATURE_PROFILE", os.getenv("ALWRITY_ROUTER_PROFILE", os.getenv("ALWRITY_FEATURE_TO_ENABLE", "all"))).strip().lower() or "all"
def _should_include_router(self, registry_entry: Dict[str, Any], profile: str) -> bool:
profiles = registry_entry.get("profiles", {"all", "default"})
@@ -154,3 +159,14 @@ class RouterManager:
"total_included": len(self.included_routers),
"total_failed": len(self.failed_routers)
}
def get_feature_profile_status(self) -> Dict[str, Any]:
"""Get feature profile status and enabled modules."""
profile = self._get_profile()
enabled_modules = OPTIONAL_MODULE_MATRIX.get(profile, OPTIONAL_MODULE_MATRIX.get("all", []))
return {
"active_profile": profile,
"enabled_modules": enabled_modules,
"available_profiles": list(OPTIONAL_MODULE_MATRIX.keys())
}

View File

@@ -290,6 +290,11 @@ async def router_status():
)
return status
@app.get("/api/feature-profile/status")
async def feature_profile_status():
"""Get feature profile status and enabled modules."""
return router_manager.get_feature_profile_status()
# Onboarding management endpoints
@app.get("/api/onboarding/status")
async def onboarding_status():

View File

@@ -236,6 +236,11 @@ async def router_status():
"""Get router inclusion status."""
return router_manager.get_router_status()
@app.get("/api/feature-profile/status")
async def feature_profile_status():
"""Get feature profile status and enabled modules."""
return router_manager.get_feature_profile_status()
# Onboarding management endpoints
@app.get("/api/onboarding/status")
async def onboarding_status():