system-prompts-and-models-o.../salesflow-saas/backend/app/models/call.py
Claude 84762f08ab
Add complete launch infrastructure: models, APIs, agents, compliance, docs, knowledge base
Phase 1 - Repo Hardening:
- README.md, LICENSE, SECURITY.md, CONTRIBUTING.md
- GitHub Actions repo-hygiene workflow
- docs/: ARCHITECTURE, DATA-MODEL, API-MAP, AGENT-MAP, DEPLOYMENT-NOTES

Phase 2 - Database Models (7 new):
- Company, Contact, Call, Commission, Payout, Dispute, GuaranteeClaim
- Consent, Complaint, Policy, KnowledgeArticle, SectorAsset
- Updated models/__init__.py with all 32+ models

Phase 3 - API Surfaces (16 new route files):
- companies, contacts, calls, meetings, commissions, payouts
- disputes, guarantees, consents, complaints, knowledge
- sectors, presentations, supervisor, admin, health
- Updated router.py with all 24 route groups

Phase 4 - AI Prompt Registry (18 agent contracts):
- Lead Qualification, Affiliate Recruitment Evaluator, Onboarding Coach
- Outreach Writer, Arabic WhatsApp, English Conversation, Voice Call
- Meeting Booking, Sector Strategist, Objection Handler
- Proposal Drafter, QA Reviewer, Compliance Reviewer
- Knowledge Retrieval, Revenue Attribution, Fraud Reviewer
- Guarantee Claim Reviewer, Management Summary

Phase 5 - Communication Templates:
- 15 production templates (WhatsApp, email, voice, internal)
- Arabic + English variants with variable interpolation

Phase 6 - Compliance Center (7 legal docs):
- Privacy policy, Terms of service, Refund policy
- Commission policy, Affiliate rules, Consent policy, Data protection
- All PDPL-compliant, Arabic

Phase 7 - Celery Workers (fully implemented):
- follow_up_tasks: automated lead follow-ups with workflow execution
- message_tasks: WhatsApp/email/SMS with retry logic
- notification_tasks: daily reports, meeting reminders, in-app notifications
- affiliate_tasks: target checking, commission calculation, weekly reports, AI outreach

Phase 8 - Knowledge Base OS (8 files):
- Services overview, Pricing policy, Channel policy, Meeting policy
- Identity rules, Escalation rules, Hiring path, Internal SOPs

https://claude.ai/code/session_01KnJgK7RwyeCvRZTRThHtfU
2026-03-31 07:57:48 +00:00

60 lines
2.0 KiB
Python

import enum
from datetime import datetime, timezone
from sqlalchemy import Column, String, Integer, Text, DateTime, Float, Enum, ForeignKey
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import relationship
from app.models.base import TenantModel
class CallDirection(str, enum.Enum):
INBOUND = "inbound"
OUTBOUND = "outbound"
class CallChannel(str, enum.Enum):
PHONE = "phone"
WHATSAPP_VOICE = "whatsapp_voice"
class CallStatus(str, enum.Enum):
INITIATED = "initiated"
RINGING = "ringing"
ANSWERED = "answered"
COMPLETED = "completed"
FAILED = "failed"
NO_ANSWER = "no_answer"
class CallOutcome(str, enum.Enum):
INTERESTED = "interested"
NOT_INTERESTED = "not_interested"
CALLBACK = "callback"
MEETING_BOOKED = "meeting_booked"
WRONG_NUMBER = "wrong_number"
class Call(TenantModel):
__tablename__ = "calls"
lead_id = Column(UUID(as_uuid=True), ForeignKey("leads.id"), nullable=True, index=True)
contact_id = Column(UUID(as_uuid=True), ForeignKey("contacts.id"), nullable=True, index=True)
affiliate_id = Column(UUID(as_uuid=True), ForeignKey("affiliate_marketers.id"), nullable=True)
user_id = Column(UUID(as_uuid=True), ForeignKey("users.id"), nullable=True)
direction = Column(Enum(CallDirection), nullable=False)
channel = Column(Enum(CallChannel), default=CallChannel.PHONE)
duration_seconds = Column(Integer, nullable=True)
status = Column(Enum(CallStatus), default=CallStatus.INITIATED)
outcome = Column(Enum(CallOutcome), nullable=True)
transcript = Column(Text, nullable=True)
summary = Column(Text, nullable=True)
sentiment_score = Column(Float, nullable=True)
recording_url = Column(String(500), nullable=True)
started_at = Column(DateTime(timezone=True), nullable=True)
ended_at = Column(DateTime(timezone=True), nullable=True)
notes = Column(Text, nullable=True)
lead = relationship("Lead")
contact = relationship("Contact")
affiliate = relationship("AffiliateMarketer")
user = relationship("User")