Spaces:
Sleeping
Sleeping
Initial commit of the Ad Generator Lite project, including backend services, frontend components, and configuration files. Added core functionalities for ad generation, user management, and image processing, along with a structured matrix system for ad testing.
f201243 | """ | |
| Affiliate Marketing Angles Framework (Lite Version) | |
| 100 angles organized into 10 categories. | |
| Angles answer: "Why should I care?" (Psychological WHY) | |
| """ | |
| from typing import Dict, List, Any, Optional | |
| from enum import Enum | |
| import random | |
| class AngleCategory(str, Enum): | |
| """Angle categories.""" | |
| EMOTIONAL = "emotional" | |
| FINANCIAL = "financial" | |
| CONVENIENCE = "convenience" | |
| IDENTITY = "identity" | |
| AUTHORITY = "authority" | |
| SOCIAL_PROOF = "social_proof" | |
| URGENCY = "urgency" | |
| INTELLECTUAL = "intellectual" | |
| CURIOSITY = "curiosity" | |
| PROBLEM_SOLUTION = "problem_solution" | |
| # Complete angles framework - 100 angles (10 per category) | |
| ANGLES = { | |
| AngleCategory.EMOTIONAL: { | |
| "name": "Emotional & Psychological", | |
| "angles": [ | |
| {"key": "fear_loss", "name": "Fear / Loss Prevention", "trigger": "Fear", "example": "Don't lose your home to disaster"}, | |
| {"key": "anxiety_reduction", "name": "Anxiety Reduction", "trigger": "Relief", "example": "Sleep better knowing you're protected"}, | |
| {"key": "security_safety", "name": "Security / Safety", "trigger": "Security", "example": "Your family's safety is our priority"}, | |
| {"key": "peace_of_mind", "name": "Peace of Mind", "trigger": "Relief", "example": "Peace of mind for just $X/month"}, | |
| {"key": "stress_relief", "name": "Stress Relief", "trigger": "Relief", "example": "End the stress of [problem]"}, | |
| {"key": "relief_escape", "name": "Relief / Escape", "trigger": "Relief", "example": "Finally escape [problem]"}, | |
| {"key": "confidence_boost", "name": "Confidence Boost", "trigger": "Pride", "example": "Feel confident about your future"}, | |
| {"key": "hope_optimism", "name": "Hope / Optimism", "trigger": "Hope", "example": "A brighter future starts today"}, | |
| {"key": "guilt_responsibility", "name": "Guilt (Family)", "trigger": "Guilt", "example": "Do it for your family"}, | |
| {"key": "pride_self_worth", "name": "Pride / Self-worth", "trigger": "Pride", "example": "You deserve the best"}, | |
| {"key": "emotional_connection", "name": "Emotional Connection", "trigger": "Belonging", "example": "Feel connected to what matters"}, | |
| {"key": "nostalgia", "name": "Nostalgia", "trigger": "Emotion", "example": "Remember when things were simpler"}, | |
| {"key": "empowerment", "name": "Empowerment", "trigger": "Pride", "example": "Take control of your future"}, | |
| ] | |
| }, | |
| AngleCategory.FINANCIAL: { | |
| "name": "Financial", | |
| "angles": [ | |
| {"key": "save_money", "name": "Save Money", "trigger": "Greed", "example": "Save $600/year"}, | |
| {"key": "cut_hidden_costs", "name": "Cut Hidden Costs", "trigger": "Anger", "example": "Stop paying hidden fees"}, | |
| {"key": "avoid_overpaying", "name": "Avoid Overpaying", "trigger": "Anger", "example": "Stop overpaying for [service]"}, | |
| {"key": "financial_freedom", "name": "Financial Freedom", "trigger": "Desire", "example": "Achieve financial freedom"}, | |
| {"key": "budget_control", "name": "Budget Control", "trigger": "Control", "example": "Take control of your budget"}, | |
| {"key": "price_comparison", "name": "Price Comparison", "trigger": "Greed", "example": "Compare prices in 30 seconds"}, | |
| {"key": "smart_spending", "name": "Smart Spending", "trigger": "Pride", "example": "Make smart financial choices"}, | |
| {"key": "long_term_value", "name": "Long-Term Value", "trigger": "Greed", "example": "Invest in your future"}, | |
| {"key": "roi_investment", "name": "ROI / Investment", "trigger": "Greed", "example": "Get 3x return on investment"}, | |
| {"key": "cost_transparency", "name": "Cost Transparency", "trigger": "Trust", "example": "100% transparent pricing"}, | |
| {"key": "hidden_fees_exposed", "name": "Hidden Fees Exposed", "trigger": "Anger", "example": "No hidden fees, ever"}, | |
| {"key": "money_back", "name": "Money-Back Guarantee", "trigger": "Security", "example": "Get your money back if not satisfied"}, | |
| {"key": "payment_flexibility", "name": "Payment Flexibility", "trigger": "Convenience", "example": "Pay your way, when you want"}, | |
| ] | |
| }, | |
| AngleCategory.CONVENIENCE: { | |
| "name": "Convenience & Ease", | |
| "angles": [ | |
| {"key": "fast_instant", "name": "Fast / Instant", "trigger": "Convenience", "example": "Get a quote in 30 seconds"}, | |
| {"key": "simple_easy", "name": "Simple / Easy", "trigger": "Convenience", "example": "It's that simple"}, | |
| {"key": "no_paperwork", "name": "No Paperwork", "trigger": "Convenience", "example": "No paperwork required"}, | |
| {"key": "no_phone_calls", "name": "No Phone Calls", "trigger": "Convenience", "example": "No phone calls needed"}, | |
| {"key": "one_click", "name": "One-Click / Few Steps", "trigger": "Convenience", "example": "Get started in 3 steps"}, | |
| {"key": "beginner_friendly", "name": "Beginner-Friendly", "trigger": "Security", "example": "Perfect for beginners"}, | |
| {"key": "done_for_you", "name": "Done-For-You", "trigger": "Convenience", "example": "We handle everything"}, | |
| {"key": "hassle_free", "name": "Hassle-Free", "trigger": "Convenience", "example": "100% hassle-free"}, | |
| {"key": "low_effort", "name": "Low Effort", "trigger": "Convenience", "example": "Minimal effort, maximum results"}, | |
| {"key": "time_saving", "name": "Time Saving", "trigger": "Convenience", "example": "Save 10 hours per week"}, | |
| {"key": "automated_process", "name": "Automated Process", "trigger": "Convenience", "example": "Fully automated, zero work"}, | |
| {"key": "instant_access", "name": "Instant Access", "trigger": "Convenience", "example": "Get instant access now"}, | |
| {"key": "no_waiting", "name": "No Waiting", "trigger": "Convenience", "example": "No waiting, start immediately"}, | |
| ] | |
| }, | |
| AngleCategory.IDENTITY: { | |
| "name": "Identity & Personalization", | |
| "angles": [ | |
| {"key": "age_based", "name": "Age-Based", "trigger": "Personalization", "example": "Special rates for seniors 65+"}, | |
| {"key": "location_based", "name": "Location-Based", "trigger": "Personalization", "example": "Best rates in [location]"}, | |
| {"key": "profession_specific", "name": "Profession-Specific", "trigger": "Personalization", "example": "Special rates for teachers"}, | |
| {"key": "life_stage", "name": "Life Stage", "trigger": "Personalization", "example": "Perfect for new homeowners"}, | |
| {"key": "lifestyle_match", "name": "Lifestyle Match", "trigger": "Personalization", "example": "Fits your lifestyle"}, | |
| {"key": "people_like_you", "name": "People Like You", "trigger": "Social Proof", "example": "Join thousands like you"}, | |
| {"key": "custom_fit", "name": "Custom Fit", "trigger": "Personalization", "example": "Customized just for you"}, | |
| {"key": "personal_relevance", "name": "Personal Relevance", "trigger": "Personalization", "example": "Built specifically for you"}, | |
| {"key": "niche_targeting", "name": "Niche Targeting", "trigger": "Personalization", "example": "Designed for [niche]"}, | |
| {"key": "localized_offer", "name": "Localized Offer", "trigger": "Personalization", "example": "Best deals in [city]"}, | |
| {"key": "behavioral_match", "name": "Behavioral Match", "trigger": "Personalization", "example": "Fits your lifestyle perfectly"}, | |
| {"key": "preference_based", "name": "Preference-Based", "trigger": "Personalization", "example": "Tailored to your preferences"}, | |
| {"key": "demographic_specific", "name": "Demographic-Specific", "trigger": "Personalization", "example": "Made for people like you"}, | |
| ] | |
| }, | |
| AngleCategory.AUTHORITY: { | |
| "name": "Authority & Trust", | |
| "angles": [ | |
| {"key": "expert_backed", "name": "Expert-Backed", "trigger": "Authority", "example": "Recommended by experts"}, | |
| {"key": "industry_standard", "name": "Industry Standard", "trigger": "Authority", "example": "The industry standard"}, | |
| {"key": "government_related", "name": "Government-Related", "trigger": "Authority", "example": "Government-approved program"}, | |
| {"key": "trusted_millions", "name": "Trusted by Millions", "trigger": "Social Proof", "example": "Trusted by 2M+ customers"}, | |
| {"key": "years_experience", "name": "Years of Experience", "trigger": "Authority", "example": "20+ years of experience"}, | |
| {"key": "certified_verified", "name": "Certified / Verified", "trigger": "Authority", "example": "Certified and verified"}, | |
| {"key": "brand_reputation", "name": "Brand Reputation", "trigger": "Authority", "example": "Trusted brand name"}, | |
| {"key": "compliance", "name": "Compliance / Regulation", "trigger": "Authority", "example": "Fully compliant and regulated"}, | |
| {"key": "awards_recognition", "name": "Awards / Recognition", "trigger": "Authority", "example": "Award-winning service"}, | |
| {"key": "risk_free", "name": "Risk-Free", "trigger": "Security", "example": "100% risk-free guarantee"}, | |
| {"key": "industry_leader", "name": "Industry Leader", "trigger": "Authority", "example": "The industry leader"}, | |
| {"key": "proven_track_record", "name": "Proven Track Record", "trigger": "Authority", "example": "Proven results over decades"}, | |
| ] | |
| }, | |
| AngleCategory.SOCIAL_PROOF: { | |
| "name": "Social Proof & Validation", | |
| "angles": [ | |
| {"key": "testimonials", "name": "Testimonials", "trigger": "Social Proof", "example": "See what customers say"}, | |
| {"key": "reviews_ratings", "name": "Reviews / Ratings", "trigger": "Social Proof", "example": "4.8/5 stars from 10K+ reviews"}, | |
| {"key": "mass_adoption", "name": "Mass Adoption", "trigger": "Social Proof", "example": "Join 2M+ users"}, | |
| {"key": "case_studies", "name": "Case Studies", "trigger": "Social Proof", "example": "See real success stories"}, | |
| {"key": "word_of_mouth", "name": "Word of Mouth", "trigger": "Social Proof", "example": "Recommended by friends"}, | |
| {"key": "community_trust", "name": "Community Trust", "trigger": "Social Proof", "example": "Trusted by our community"}, | |
| {"key": "real_stories", "name": "Real Stories", "trigger": "Social Proof", "example": "Real stories from real customers"}, | |
| {"key": "viral_popularity", "name": "Viral Popularity", "trigger": "FOMO", "example": "Going viral on [platform]"}, | |
| {"key": "trending_now", "name": "Trending Now", "trigger": "FOMO", "example": "Trending now"}, | |
| {"key": "most_chosen", "name": "Most Chosen", "trigger": "Social Proof", "example": "The most chosen option"}, | |
| {"key": "peer_recommendation", "name": "Peer Recommendation", "trigger": "Social Proof", "example": "Recommended by your peers"}, | |
| {"key": "success_rate", "name": "High Success Rate", "trigger": "Social Proof", "example": "95% success rate"}, | |
| ] | |
| }, | |
| AngleCategory.URGENCY: { | |
| "name": "Urgency & Scarcity", | |
| "angles": [ | |
| {"key": "limited_time", "name": "Limited Time", "trigger": "FOMO", "example": "Limited time offer - ends Friday"}, | |
| {"key": "ending_soon", "name": "Ending Soon", "trigger": "FOMO", "example": "Offer ending in 48 hours"}, | |
| {"key": "price_increase", "name": "Price Increase Warning", "trigger": "FOMO", "example": "Prices increasing on [date]"}, | |
| {"key": "seasonal_change", "name": "Seasonal Change", "trigger": "FOMO", "example": "Spring special - ends soon"}, | |
| {"key": "renewal_reminder", "name": "Policy Renewal", "trigger": "FOMO", "example": "Renew before [date] to save"}, | |
| {"key": "countdown", "name": "Countdown", "trigger": "FOMO", "example": "Only 24 hours left"}, | |
| {"key": "last_chance", "name": "Last Chance", "trigger": "FOMO", "example": "Last chance to save"}, | |
| {"key": "market_shift", "name": "Market Shift", "trigger": "FOMO", "example": "Market rates changing soon"}, | |
| {"key": "deadline_pressure", "name": "Deadline Pressure", "trigger": "FOMO", "example": "Deadline: [date]"}, | |
| {"key": "miss_out_avoidance", "name": "Miss-Out Avoidance", "trigger": "FOMO", "example": "Don't miss this opportunity"}, | |
| {"key": "early_bird", "name": "Early Bird Special", "trigger": "FOMO", "example": "Early bird pricing ends soon"}, | |
| {"key": "flash_sale", "name": "Flash Sale", "trigger": "FOMO", "example": "Flash sale - 24 hours only"}, | |
| ] | |
| }, | |
| AngleCategory.INTELLECTUAL: { | |
| "name": "Intellectual / Smart Choice", | |
| "angles": [ | |
| {"key": "insider_knowledge", "name": "Insider Knowledge", "trigger": "Curiosity", "example": "Insider tip: [secret]"}, | |
| {"key": "avoid_mistakes", "name": "Avoid Common Mistakes", "trigger": "Fear", "example": "Avoid these 5 common mistakes"}, | |
| {"key": "educated_decision", "name": "Educated Decision", "trigger": "Pride", "example": "Make an educated decision"}, | |
| {"key": "comparison_logic", "name": "Comparison Logic", "trigger": "Pride", "example": "Compare and choose wisely"}, | |
| {"key": "transparency", "name": "Transparency", "trigger": "Trust", "example": "100% transparent pricing"}, | |
| {"key": "informed_buyer", "name": "Informed Buyer", "trigger": "Pride", "example": "For informed buyers"}, | |
| {"key": "data_driven", "name": "Data-Driven", "trigger": "Authority", "example": "Backed by data"}, | |
| {"key": "rational_choice", "name": "Rational Choice", "trigger": "Pride", "example": "The rational choice"}, | |
| {"key": "what_experts_do", "name": "What Experts Do", "trigger": "Authority", "example": "What experts do"}, | |
| {"key": "optimization", "name": "Optimization", "trigger": "Pride", "example": "Optimize your [thing]"}, | |
| {"key": "smart_investment", "name": "Smart Investment", "trigger": "Pride", "example": "The smart investment choice"}, | |
| {"key": "evidence_based", "name": "Evidence-Based", "trigger": "Authority", "example": "Backed by research and data"}, | |
| ] | |
| }, | |
| AngleCategory.CURIOSITY: { | |
| "name": "Curiosity & Pattern Interrupt", | |
| "angles": [ | |
| {"key": "shocking_stats", "name": "Shocking Stats", "trigger": "Curiosity", "example": "Shocking stat: [number]"}, | |
| {"key": "did_you_know", "name": "Did You Know?", "trigger": "Curiosity", "example": "Did you know [fact]?"}, | |
| {"key": "open_loops", "name": "Open Loops", "trigger": "Curiosity", "example": "Thousands doing THIS instead"}, | |
| {"key": "contrarian", "name": "Contrarian Claims", "trigger": "Curiosity", "example": "Why everyone is wrong about [thing]"}, | |
| {"key": "myth_busting", "name": "Myth Busting", "trigger": "Curiosity", "example": "Myth busted: [myth]"}, | |
| {"key": "unexpected_truth", "name": "Unexpected Truth", "trigger": "Curiosity", "example": "The truth about [thing]"}, | |
| {"key": "hidden_secrets", "name": "Hidden Secrets", "trigger": "Curiosity", "example": "The hidden secret to [thing]"}, | |
| {"key": "scroll_stopper", "name": "Scroll Stopper", "trigger": "Curiosity", "example": "Stop scrolling - read this"}, | |
| {"key": "pattern_break", "name": "Pattern Break", "trigger": "Curiosity", "example": "This breaks all patterns"}, | |
| {"key": "curiosity_gap", "name": "Curiosity Gap", "trigger": "Curiosity", "example": "What is THIS?"}, | |
| {"key": "reveal_secret", "name": "Reveal Secret", "trigger": "Curiosity", "example": "The secret they don't want you to know"}, | |
| {"key": "unexpected_benefit", "name": "Unexpected Benefit", "trigger": "Curiosity", "example": "The benefit nobody talks about"}, | |
| ] | |
| }, | |
| AngleCategory.PROBLEM_SOLUTION: { | |
| "name": "Problem–Solution", | |
| "angles": [ | |
| {"key": "pain_point", "name": "Pain Point Highlight", "trigger": "Anger", "example": "Tired of [problem]?"}, | |
| {"key": "frustration_relief", "name": "Frustration Relief", "trigger": "Relief", "example": "End your frustration with [problem]"}, | |
| {"key": "complexity_simplified", "name": "Complexity Simplified", "trigger": "Convenience", "example": "We make [thing] simple"}, | |
| {"key": "confusion_clarity", "name": "Confusion → Clarity", "trigger": "Relief", "example": "From confusion to clarity"}, | |
| {"key": "overwhelm_reduction", "name": "Overwhelm Reduction", "trigger": "Relief", "example": "Stop feeling overwhelmed"}, | |
| {"key": "direct_fix", "name": "Direct Fix", "trigger": "Relief", "example": "The direct fix for [problem]"}, | |
| {"key": "shortcut", "name": "Shortcut", "trigger": "Convenience", "example": "The shortcut to [goal]"}, | |
| {"key": "better_alternative", "name": "Better Alternative", "trigger": "Desire", "example": "A better alternative to [current]"}, | |
| {"key": "replace_old_way", "name": "Replace Old Way", "trigger": "Desire", "example": "Replace the old way"}, | |
| {"key": "modern_solution", "name": "Modern Solution", "trigger": "Desire", "example": "The modern solution to [problem]"}, | |
| {"key": "pain_elimination", "name": "Pain Elimination", "trigger": "Relief", "example": "Eliminate [problem] forever"}, | |
| {"key": "simplified_complexity", "name": "Simplified Complexity", "trigger": "Convenience", "example": "We simplified the complex"}, | |
| {"key": "one_click_solution", "name": "One-Click Solution", "trigger": "Convenience", "example": "Solve it in one click"}, | |
| ] | |
| }, | |
| } | |
| def get_all_angles() -> List[Dict[str, Any]]: | |
| """Get all angles as a flat list.""" | |
| all_angles = [] | |
| for category, data in ANGLES.items(): | |
| for angle in data["angles"]: | |
| angle_copy = angle.copy() | |
| angle_copy["category"] = data["name"] | |
| angle_copy["category_key"] = category | |
| all_angles.append(angle_copy) | |
| return all_angles | |
| def get_angles_by_category(category: AngleCategory) -> List[Dict[str, Any]]: | |
| """Get angles for a specific category.""" | |
| return ANGLES.get(category, {}).get("angles", []) | |
| def get_angle_by_key(key: str) -> Optional[Dict[str, Any]]: | |
| """Get a specific angle by key.""" | |
| for category, data in ANGLES.items(): | |
| for angle in data["angles"]: | |
| if angle["key"] == key: | |
| angle_copy = angle.copy() | |
| angle_copy["category"] = data["name"] | |
| angle_copy["category_key"] = category | |
| return angle_copy | |
| return None | |
| def get_random_angles(count: int = 6, diverse: bool = True) -> List[Dict[str, Any]]: | |
| """Get random angles, optionally ensuring diversity across categories.""" | |
| if diverse: | |
| # Select one from each category first | |
| selected = [] | |
| categories = list(ANGLES.keys()) | |
| random.shuffle(categories) | |
| for category in categories[:count]: | |
| angles = ANGLES[category]["angles"] | |
| angle = random.choice(angles).copy() | |
| angle["category"] = ANGLES[category]["name"] | |
| angle["category_key"] = category | |
| selected.append(angle) | |
| return selected[:count] | |
| else: | |
| all_angles = get_all_angles() | |
| return random.sample(all_angles, min(count, len(all_angles))) | |
| def get_angles_for_niche(niche: str) -> List[Dict[str, Any]]: | |
| """Get angles best suited for a niche.""" | |
| niche_lower = niche.lower() | |
| # Niche-specific angle recommendations | |
| if "insurance" in niche_lower: | |
| recommended_keys = [ | |
| "fear_loss", "peace_of_mind", "save_money", "price_comparison", | |
| "trusted_millions", "limited_time", "avoid_mistakes", "pain_point" | |
| ] | |
| elif "glp" in niche_lower or "weight" in niche_lower: | |
| recommended_keys = [ | |
| "confidence_boost", "pride_self_worth", "before_after_shock", | |
| "testimonials", "trending_now", "modern_solution", "shortcut" | |
| ] | |
| else: | |
| # Default mix | |
| recommended_keys = [ | |
| "save_money", "fast_instant", "testimonials", "limited_time", | |
| "shocking_stats", "pain_point" | |
| ] | |
| angles = [] | |
| for key in recommended_keys: | |
| angle = get_angle_by_key(key) | |
| if angle: | |
| angles.append(angle) | |
| return angles | |
| # Top performing angles for initial testing | |
| TOP_ANGLES = [ | |
| "save_money", "fear_loss", "fast_instant", "expert_backed", | |
| "testimonials", "limited_time", "age_based", "pain_point" | |
| ] | |
| def get_top_angles() -> List[Dict[str, Any]]: | |
| """Get top performing angles for initial testing.""" | |
| return [get_angle_by_key(key) for key in TOP_ANGLES if get_angle_by_key(key)] | |