mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-06-18 07:19:35 +00:00
CI Fix:
All 8 Tier-1 API routes now use fully lazy imports — no module-level
imports of app.database, app.services, or app.models. Every import
happens inside the function body. This prevents pytest collection
failure (exit code 4) caused by import chain side effects during
test discovery.
Pattern: _get_db() async generator wraps app.database.get_db lazily.
Service/model imports are inside each route handler function.
Revenue Activation System (3 phases):
revenue-activation/FIRST_3_CLIENTS_PLAN.md
— ICP definition, outreach scripts (WhatsApp/LinkedIn/Email),
demo strategy, pricing (15K-50K SAR pilot), closing playbook,
objection handling, referral scripts, pipeline KPIs
revenue-activation/deployment/LIVE_DEPLOYMENT_GUIDE.md
— Step-by-step client installation in 48h, data import,
training agenda, pilot monitoring, post-pilot conversion
revenue-activation/AUTOMATED_REVENUE_ENGINE.md
— Self-generating pipeline: outreach→demo→pilot→case study→referral,
auto-sequences, AI response classification, upsell triggers,
90-day revenue targets (100K+ SAR MRR)
revenue-activation/outreach/whatsapp-sequences.json
— 3 ready-to-use sequences: cold B2B, warm referral, post-pilot convert
revenue-activation/demo/seed_demo_tenant.py
— Seeds demo tenant with 15 leads, 8 deals, 3 approvals with SLA,
4 connectors, 1 evidence pack for executive simulation demos
https://claude.ai/code/session_01W1rJthWDkasijTdXCfxVHs
70 lines
3.2 KiB
Python
70 lines
3.2 KiB
Python
"""Executive Room API — unified executive decision surface with real data."""
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from typing import Any, Dict
|
|
|
|
router = APIRouter(prefix="/executive-room", tags=["Executive Room"])
|
|
|
|
|
|
async def _get_db():
|
|
from app.database import get_db
|
|
async for session in get_db():
|
|
yield session
|
|
|
|
|
|
@router.get("/snapshot")
|
|
async def executive_snapshot(
|
|
tenant_id: str = "00000000-0000-0000-0000-000000000000",
|
|
db=Depends(_get_db),
|
|
) -> Dict[str, Any]:
|
|
from app.services.executive_roi_service import executive_room_service
|
|
return await executive_room_service.build_snapshot(db, tenant_id)
|
|
|
|
|
|
@router.get("/risks")
|
|
async def executive_risks(
|
|
tenant_id: str = "00000000-0000-0000-0000-000000000000",
|
|
db=Depends(_get_db),
|
|
) -> Dict[str, Any]:
|
|
from app.services.executive_roi_service import executive_room_service
|
|
snapshot = await executive_room_service.build_snapshot(db, tenant_id)
|
|
risks = []
|
|
if snapshot["approvals"]["breach"] > 0:
|
|
risks.append({"type": "sla_breach", "severity": "high", "count": snapshot["approvals"]["breach"], "description_ar": "خرق SLA في الموافقات"})
|
|
if snapshot["contradictions"]["critical"] > 0:
|
|
risks.append({"type": "contradiction", "severity": "critical", "count": snapshot["contradictions"]["critical"], "description_ar": "تناقضات حرجة نشطة"})
|
|
if snapshot["compliance"]["non_compliant"] > 0:
|
|
risks.append({"type": "compliance", "severity": "high", "count": snapshot["compliance"]["non_compliant"], "description_ar": "ضوابط غير ممتثلة"})
|
|
if snapshot["connectors"]["error"] > 0:
|
|
risks.append({"type": "connector_error", "severity": "medium", "count": snapshot["connectors"]["error"], "description_ar": "موصلات معطلة"})
|
|
return {"risks": risks, "total": len(risks)}
|
|
|
|
|
|
@router.get("/decisions-pending")
|
|
async def pending_decisions(
|
|
tenant_id: str = "00000000-0000-0000-0000-000000000000",
|
|
db=Depends(_get_db),
|
|
) -> Dict[str, Any]:
|
|
from app.services.executive_roi_service import executive_room_service
|
|
snapshot = await executive_room_service.build_snapshot(db, tenant_id)
|
|
decisions = []
|
|
if snapshot["approvals"]["pending"] > 0:
|
|
decisions.append({"type": "approval", "count": snapshot["approvals"]["pending"], "description_ar": "موافقات معلقة"})
|
|
if snapshot["contradictions"]["active"] > 0:
|
|
decisions.append({"type": "contradiction", "count": snapshot["contradictions"]["active"], "description_ar": "تناقضات تحتاج مراجعة"})
|
|
return {"decisions": decisions, "total": len(decisions)}
|
|
|
|
|
|
@router.get("/forecast-vs-actual")
|
|
async def forecast_vs_actual(
|
|
tenant_id: str = "00000000-0000-0000-0000-000000000000",
|
|
db=Depends(_get_db),
|
|
) -> Dict[str, Any]:
|
|
from app.services.executive_roi_service import executive_room_service
|
|
snapshot = await executive_room_service.build_snapshot(db, tenant_id)
|
|
rev = snapshot["revenue"]
|
|
return {
|
|
"tracks": {"revenue": {"actual": rev["actual"], "forecast": rev["forecast"], "variance_percent": rev["variance_percent"]}, "strategic_deals": snapshot["strategic_deals"]},
|
|
"overall_health": "on_track" if rev["variance_percent"] >= -10 else "at_risk",
|
|
}
|