generated from fahricansecer/boilerplate-be
This commit is contained in:
330
src/modules/content-generation/services/niche.service.ts
Normal file
330
src/modules/content-generation/services/niche.service.ts
Normal file
@@ -0,0 +1,330 @@
|
||||
// Niche Service - Niche selection and management
|
||||
// Path: src/modules/content-generation/services/niche.service.ts
|
||||
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
|
||||
export interface Niche {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
category: NicheCategory;
|
||||
description: string;
|
||||
targetAudience: string[];
|
||||
painPoints: string[];
|
||||
keywords: string[];
|
||||
contentAngles: string[];
|
||||
competitors: string[];
|
||||
monetization: string[];
|
||||
difficulty: 'beginner' | 'intermediate' | 'advanced';
|
||||
growthPotential: number; // 1-100
|
||||
engagement: {
|
||||
avgLikes: number;
|
||||
avgComments: number;
|
||||
avgShares: number;
|
||||
};
|
||||
}
|
||||
|
||||
export type NicheCategory =
|
||||
| 'business'
|
||||
| 'finance'
|
||||
| 'health'
|
||||
| 'tech'
|
||||
| 'lifestyle'
|
||||
| 'education'
|
||||
| 'entertainment'
|
||||
| 'creative'
|
||||
| 'personal_development'
|
||||
| 'relationships'
|
||||
| 'career'
|
||||
| 'parenting';
|
||||
|
||||
export interface NicheAnalysis {
|
||||
niche: Niche;
|
||||
saturation: 'low' | 'medium' | 'high';
|
||||
competition: number; // 1-100
|
||||
opportunity: number; // 1-100
|
||||
trendingTopics: string[];
|
||||
contentGaps: string[];
|
||||
recommendedPlatforms: string[];
|
||||
monetizationPotential: number; // 1-100
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class NicheService {
|
||||
private readonly logger = new Logger(NicheService.name);
|
||||
|
||||
// Popular niches database
|
||||
private readonly niches: Niche[] = [
|
||||
{
|
||||
id: 'personal-finance',
|
||||
name: 'Personal Finance',
|
||||
slug: 'personal-finance',
|
||||
category: 'finance',
|
||||
description: 'Money management, investing, budgeting, and financial freedom',
|
||||
targetAudience: ['millennials', 'young professionals', 'families', 'retirees'],
|
||||
painPoints: ['debt', 'saving money', 'investing confusion', 'retirement anxiety'],
|
||||
keywords: ['budgeting', 'investing', 'passive income', 'financial freedom', 'side hustle'],
|
||||
contentAngles: ['beginner guides', 'investment strategies', 'debt payoff stories', 'money mistakes'],
|
||||
competitors: ['The Financial Diet', 'Graham Stephan', 'Dave Ramsey'],
|
||||
monetization: ['affiliate marketing', 'courses', 'coaching', 'sponsored content'],
|
||||
difficulty: 'intermediate',
|
||||
growthPotential: 85,
|
||||
engagement: { avgLikes: 500, avgComments: 50, avgShares: 100 },
|
||||
},
|
||||
{
|
||||
id: 'productivity',
|
||||
name: 'Productivity & Time Management',
|
||||
slug: 'productivity',
|
||||
category: 'personal_development',
|
||||
description: 'Work efficiency, habits, systems, and getting more done',
|
||||
targetAudience: ['entrepreneurs', 'remote workers', 'students', 'executives'],
|
||||
painPoints: ['procrastination', 'overwhelm', 'work-life balance', 'focus issues'],
|
||||
keywords: ['productivity tips', 'time management', 'habits', 'morning routine', 'deep work'],
|
||||
contentAngles: ['system breakdowns', 'tool reviews', 'habit building', 'workflow optimization'],
|
||||
competitors: ['Ali Abdaal', 'Thomas Frank', 'Cal Newport'],
|
||||
monetization: ['digital products', 'consulting', 'affiliate marketing', 'memberships'],
|
||||
difficulty: 'intermediate',
|
||||
growthPotential: 80,
|
||||
engagement: { avgLikes: 800, avgComments: 80, avgShares: 200 },
|
||||
},
|
||||
{
|
||||
id: 'ai-tech',
|
||||
name: 'AI & Technology',
|
||||
slug: 'ai-tech',
|
||||
category: 'tech',
|
||||
description: 'Artificial intelligence, automation, and emerging technology',
|
||||
targetAudience: ['tech enthusiasts', 'developers', 'entrepreneurs', 'business owners'],
|
||||
painPoints: ['keeping up with change', 'implementation', 'job automation fears', 'tool overload'],
|
||||
keywords: ['AI tools', 'ChatGPT', 'automation', 'machine learning', 'future of work'],
|
||||
contentAngles: ['tool tutorials', 'trend analysis', 'use cases', 'predictions'],
|
||||
competitors: ['Matt Wolfe', 'Linus Tech Tips', 'Fireship'],
|
||||
monetization: ['sponsorships', 'affiliate marketing', 'consulting', 'SaaS products'],
|
||||
difficulty: 'advanced',
|
||||
growthPotential: 95,
|
||||
engagement: { avgLikes: 1200, avgComments: 150, avgShares: 400 },
|
||||
},
|
||||
{
|
||||
id: 'content-creation',
|
||||
name: 'Content Creation & Social Media',
|
||||
slug: 'content-creation',
|
||||
category: 'creative',
|
||||
description: 'Growing on social media, creating content, and building an audience',
|
||||
targetAudience: ['aspiring creators', 'small businesses', 'influencers', 'marketers'],
|
||||
painPoints: ['algorithm changes', 'consistency', 'monetization', 'growth plateaus'],
|
||||
keywords: ['grow on Instagram', 'content strategy', 'viral content', 'engagement tips'],
|
||||
contentAngles: ['platform strategies', 'case studies', 'tool recommendations', 'growth hacks'],
|
||||
competitors: ['Vanessa Lau', 'Jade Darmawangsa', 'Roberto Blake'],
|
||||
monetization: ['courses', 'coaching', 'agency services', 'brand deals'],
|
||||
difficulty: 'intermediate',
|
||||
growthPotential: 75,
|
||||
engagement: { avgLikes: 600, avgComments: 100, avgShares: 150 },
|
||||
},
|
||||
{
|
||||
id: 'mental-health',
|
||||
name: 'Mental Health & Wellness',
|
||||
slug: 'mental-health',
|
||||
category: 'health',
|
||||
description: 'Mental wellness, anxiety, stress management, and self-care',
|
||||
targetAudience: ['young adults', 'stressed professionals', 'students', 'parents'],
|
||||
painPoints: ['anxiety', 'burnout', 'depression', 'overwhelm', 'self-doubt'],
|
||||
keywords: ['mental health tips', 'anxiety relief', 'self-care', 'therapy', 'mindfulness'],
|
||||
contentAngles: ['personal stories', 'coping strategies', 'professional insights', 'resources'],
|
||||
competitors: ['Therapy in a Nutshell', 'Dr. Julie Smith', 'The Holistic Psychologist'],
|
||||
monetization: ['books', 'courses', 'therapy referrals', 'speaking'],
|
||||
difficulty: 'advanced',
|
||||
growthPotential: 90,
|
||||
engagement: { avgLikes: 2000, avgComments: 300, avgShares: 500 },
|
||||
},
|
||||
{
|
||||
id: 'entrepreneurship',
|
||||
name: 'Entrepreneurship & Startups',
|
||||
slug: 'entrepreneurship',
|
||||
category: 'business',
|
||||
description: 'Starting and growing businesses, startup culture, and business strategy',
|
||||
targetAudience: ['founders', 'aspiring entrepreneurs', 'small business owners', 'investors'],
|
||||
painPoints: ['funding', 'scaling', 'finding customers', 'team building', 'failure fear'],
|
||||
keywords: ['startup tips', 'business ideas', 'entrepreneurship', 'funding', 'growth strategies'],
|
||||
contentAngles: ['founder stories', 'business frameworks', 'failure lessons', 'growth strategies'],
|
||||
competitors: ['GaryVee', 'Alex Hormozi', 'My First Million'],
|
||||
monetization: ['coaching', 'events', 'investments', 'courses'],
|
||||
difficulty: 'advanced',
|
||||
growthPotential: 85,
|
||||
engagement: { avgLikes: 1500, avgComments: 200, avgShares: 350 },
|
||||
},
|
||||
{
|
||||
id: 'fitness',
|
||||
name: 'Fitness & Exercise',
|
||||
slug: 'fitness',
|
||||
category: 'health',
|
||||
description: 'Workouts, gym routines, home fitness, and physical health',
|
||||
targetAudience: ['beginners', 'fitness enthusiasts', 'athletes', 'busy professionals'],
|
||||
painPoints: ['motivation', 'time constraints', 'plateau', 'injuries', 'gym intimidation'],
|
||||
keywords: ['workout routine', 'home workout', 'weight loss', 'muscle building', 'fitness tips'],
|
||||
contentAngles: ['workout demos', 'transformation stories', 'nutrition tips', 'myth busting'],
|
||||
competitors: ['Jeff Nippard', 'Athlean-X', 'Whitney Simmons'],
|
||||
monetization: ['programs', 'supplements', 'apparel', 'coaching'],
|
||||
difficulty: 'beginner',
|
||||
growthPotential: 70,
|
||||
engagement: { avgLikes: 3000, avgComments: 200, avgShares: 400 },
|
||||
},
|
||||
{
|
||||
id: 'parenting',
|
||||
name: 'Parenting & Family',
|
||||
slug: 'parenting',
|
||||
category: 'parenting',
|
||||
description: 'Raising children, family life, and parenting strategies',
|
||||
targetAudience: ['new parents', 'expecting parents', 'parents of teens', 'grandparents'],
|
||||
painPoints: ['sleep deprivation', 'discipline', 'education', 'work-life balance', 'screen time'],
|
||||
keywords: ['parenting tips', 'baby care', 'toddler', 'teen parenting', 'family activities'],
|
||||
contentAngles: ['age-specific tips', 'product reviews', 'real-life stories', 'expert advice'],
|
||||
competitors: ['Janet Lansbury', 'Dr. Becky', 'Big Little Feelings'],
|
||||
monetization: ['affiliate marketing', 'books', 'courses', 'brand partnerships'],
|
||||
difficulty: 'beginner',
|
||||
growthPotential: 75,
|
||||
engagement: { avgLikes: 1000, avgComments: 250, avgShares: 300 },
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Get all niches
|
||||
*/
|
||||
getAllNiches(): Niche[] {
|
||||
return this.niches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get niche by ID or slug
|
||||
*/
|
||||
getNiche(idOrSlug: string): Niche | null {
|
||||
return this.niches.find((n) => n.id === idOrSlug || n.slug === idOrSlug) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get niches by category
|
||||
*/
|
||||
getNichesByCategory(category: NicheCategory): Niche[] {
|
||||
return this.niches.filter((n) => n.category === category);
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyze a niche
|
||||
*/
|
||||
analyzeNiche(nicheId: string): NicheAnalysis | null {
|
||||
const niche = this.getNiche(nicheId);
|
||||
if (!niche) return null;
|
||||
|
||||
const saturation = niche.growthPotential < 60 ? 'high' : niche.growthPotential < 80 ? 'medium' : 'low';
|
||||
const competition = 100 - niche.growthPotential + Math.random() * 20;
|
||||
|
||||
return {
|
||||
niche,
|
||||
saturation,
|
||||
competition: Math.min(100, Math.round(competition)),
|
||||
opportunity: niche.growthPotential,
|
||||
trendingTopics: this.getTrendingTopics(niche),
|
||||
contentGaps: this.findContentGaps(niche),
|
||||
recommendedPlatforms: this.recommendPlatforms(niche),
|
||||
monetizationPotential: this.calculateMonetizationPotential(niche),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Recommend niches based on interests
|
||||
*/
|
||||
recommendNiches(interests: string[]): Niche[] {
|
||||
const scored = this.niches.map((niche) => {
|
||||
let score = 0;
|
||||
const nicheText = [
|
||||
niche.name,
|
||||
niche.description,
|
||||
...niche.keywords,
|
||||
...niche.contentAngles,
|
||||
].join(' ').toLowerCase();
|
||||
|
||||
for (const interest of interests) {
|
||||
if (nicheText.includes(interest.toLowerCase())) {
|
||||
score += 10;
|
||||
}
|
||||
}
|
||||
score += niche.growthPotential / 10;
|
||||
|
||||
return { niche, score };
|
||||
});
|
||||
|
||||
return scored
|
||||
.sort((a, b) => b.score - a.score)
|
||||
.slice(0, 5)
|
||||
.map((s) => s.niche);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content ideas for a niche
|
||||
*/
|
||||
getContentIdeas(nicheId: string, count: number = 10): string[] {
|
||||
const niche = this.getNiche(nicheId);
|
||||
if (!niche) return [];
|
||||
|
||||
const ideas: string[] = [];
|
||||
const templates = [
|
||||
`${count} things nobody tells you about {keyword}`,
|
||||
`How to {keyword} without {pain_point}`,
|
||||
`Why most people fail at {keyword}`,
|
||||
`The complete guide to {keyword} for beginners`,
|
||||
`{keyword} mistakes I made (so you don't have to)`,
|
||||
`How I {keyword} in {time_period}`,
|
||||
`Stop doing this if you want to {keyword}`,
|
||||
`The truth about {keyword} that experts won't tell you`,
|
||||
`{keyword} tips that actually work in 2024`,
|
||||
`My {keyword} system that changed everything`,
|
||||
];
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
const template = templates[i % templates.length];
|
||||
const keyword = niche.keywords[i % niche.keywords.length];
|
||||
const painPoint = niche.painPoints[i % niche.painPoints.length];
|
||||
|
||||
let idea = template
|
||||
.replace('{keyword}', keyword)
|
||||
.replace('{pain_point}', painPoint)
|
||||
.replace('{time_period}', '30 days')
|
||||
.replace('{count}', String(Math.floor(Math.random() * 7 + 3)));
|
||||
|
||||
ideas.push(idea);
|
||||
}
|
||||
|
||||
return ideas;
|
||||
}
|
||||
|
||||
// Private helper methods
|
||||
|
||||
private getTrendingTopics(niche: Niche): string[] {
|
||||
// Mock trending topics
|
||||
return niche.keywords.slice(0, 3).map((k) => `${k} 2024`);
|
||||
}
|
||||
|
||||
private findContentGaps(niche: Niche): string[] {
|
||||
return [
|
||||
`Advanced ${niche.keywords[0]} strategies`,
|
||||
`${niche.name} for complete beginners`,
|
||||
`Common ${niche.keywords[1]} mistakes`,
|
||||
`${niche.name} case studies`,
|
||||
];
|
||||
}
|
||||
|
||||
private recommendPlatforms(niche: Niche): string[] {
|
||||
const platforms: string[] = [];
|
||||
|
||||
if (niche.engagement.avgLikes > 1000) platforms.push('instagram', 'tiktok');
|
||||
if (niche.category === 'business' || niche.category === 'career') platforms.push('linkedin');
|
||||
if (niche.engagement.avgShares > 200) platforms.push('twitter');
|
||||
if (niche.difficulty === 'advanced') platforms.push('youtube');
|
||||
|
||||
return platforms.length > 0 ? platforms : ['instagram', 'twitter'];
|
||||
}
|
||||
|
||||
private calculateMonetizationPotential(niche: Niche): number {
|
||||
const monetizationScore = niche.monetization.length * 15;
|
||||
const difficultyBonus = niche.difficulty === 'advanced' ? 20 : niche.difficulty === 'intermediate' ? 10 : 0;
|
||||
return Math.min(100, monetizationScore + difficultyBonus);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user