feat: prototype gap closure — enrichment diagnosis + brand extraction + plan assets

Phase 1: Data Pipeline Fixes
- Plan page: connect enrichment data for Asset Collection + YouTube Repurpose
- mergeEnrichment: generate 15-20 data-driven diagnosis items from enrichment
  (YouTube Shorts check, IG engagement, FB activity, 강남언니 ratings, GMaps)
- ClinicSnapshot: fill staffCount, nearestStation, certifications from enrichment

Phase 2: AI + Brand Enhancement
- AI prompt: per-channel diagnosis[] array (5-7 items), established, nameEn, newChannelProposals
- scrape-website: Firecrawl branding extraction (colors, fonts, logo, tagline)
- transformPlan: BrandGuide colors/fonts from scraped branding data
- transformPlan: cross-channel brand consistency analysis (name, phone mismatches)
- transformPlan: channel branding rules from enrichment (YT, IG, FB profiles)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Haewon KamandClaude Opus 4.6 committed 2026-04-03 17:09:15 +09:00
1 parent a7d8aeeddc
commit e32b8766de
4 files changed
+380 -31

No files matched your search

+143 -12
View File
@@ -7,11 +7,14 @@ import type { MarketingReport, Severity, ChannelScore, DiagnosisItem, TopVideo }
interface ApiReport {
clinicInfo?: {
name?: string;
nameEn?: string;
established?: string;
address?: string;
phone?: string;
services?: string[];
doctors?: { name: string; specialty: string }[];
};
newChannelProposals?: { channel?: string; priority?: string; rationale?: string }[];
executiveSummary?: string;
overallScore?: number;
channelAnalysis?: Record<string, {
@@ -24,6 +27,7 @@ interface ApiReport {
reviews?: number;
issues?: string[];
recommendation?: string;
diagnosis?: { issue?: string; severity?: string; recommendation?: string }[];
trackingPixels?: { name: string; installed: boolean }[];
snsLinksOnSite?: boolean;
additionalDomains?: { domain: string; purpose: string }[];
@@ -117,7 +121,20 @@ function buildDiagnosis(report: ApiReport): DiagnosisItem[] {
// Extract issues from channel analysis
if (report.channelAnalysis) {
for (const [channel, ch] of Object.entries(report.channelAnalysis)) {
if (ch.status === 'inactive' || ch.status === 'weak') {
// AI-generated per-channel diagnosis array (new format)
if (ch.diagnosis) {
for (const d of ch.diagnosis) {
if (d.issue) {
items.push({
category: CHANNEL_ICONS[channel] ? channel : channel,
detail: d.recommendation ? `${d.issue} — ${d.recommendation}` : d.issue,
severity: (d.severity as Severity) || 'warning',
});
}
}
}
// Fallback: single recommendation (old format)
else if (ch.status === 'inactive' || ch.status === 'weak') {
items.push({
category: channel,
detail: ch.recommendation || `${channel} 채널이 ${ch.status === 'inactive' ? '비활성' : '약함'} 상태입니다`,
@@ -169,9 +186,9 @@ export function transformApiReport(
clinicSnapshot: {
name: clinic.name || metadata.clinicName || '',
nameEn: '',
established: '',
yearsInBusiness: 0,
nameEn: clinic.nameEn || '',
established: clinic.established || '',
yearsInBusiness: clinic.established ? new Date().getFullYear() - parseInt(clinic.established) : 0,
staffCount: 0,
leadDoctor: {
name: doctor?.name || '',
@@ -303,7 +320,13 @@ export function transformApiReport(
asIs: issue,
toBe: '개선 필요',
})),
newChannelProposals: [],
newChannelProposals: (r.newChannelProposals || [])
.filter((p): p is { channel?: string; priority?: string; rationale?: string } => !!p?.channel)
.map(p => ({
channel: p.channel || '',
priority: p.priority || 'P2',
rationale: p.rationale || '',
})),
},
roadmap: [1, 2, 3].map(month => ({
@@ -455,6 +478,100 @@ export interface EnrichmentData {
};
}
/**
* Generate data-driven diagnosis items from enrichment data.
*/
function generateEnrichmentDiagnosis(enrichment: EnrichmentData): DiagnosisItem[] {
const items: DiagnosisItem[] = [];
// YouTube diagnosis
if (enrichment.youtube) {
const yt = enrichment.youtube;
const videos = yt.videos || [];
const shorts = videos.filter(v => v.duration && parseInt(v.duration) < 60);
const shortsRatio = videos.length > 0 ? (shorts.length / videos.length) * 100 : 0;
if (shortsRatio === 0) {
items.push({ category: 'YouTube', detail: 'Shorts 콘텐츠가 없습니다. 숏폼 영상은 신규 유입에 가장 효과적인 포맷입니다.', severity: 'warning' });
}
if (!yt.description || yt.description.length < 50) {
items.push({ category: 'YouTube', detail: '채널 설명이 미비합니다. SEO와 채널 신뢰도를 위해 키워드 포함 설명을 작성하세요.', severity: 'warning' });
}
if (yt.totalVideos && yt.totalViews) {
const avgViews = yt.totalViews / yt.totalVideos;
if (avgViews < 500) {
items.push({ category: 'YouTube', detail: `영상당 평균 조회수 ${Math.round(avgViews)}회로 낮습니다. 썸네일과 제목 최적화가 필요합니다.`, severity: 'warning' });
}
}
if (yt.subscribers && yt.subscribers < 10000) {
items.push({ category: 'YouTube', detail: `구독자 ${yt.subscribers.toLocaleString()}명으로 성장 여지가 큽니다. 일관된 업로드 스케줄을 권장합니다.`, severity: 'good' });
}
}
// Instagram diagnosis
const igAccounts = enrichment.instagramAccounts || (enrichment.instagram ? [enrichment.instagram] : []);
for (const ig of igAccounts) {
const handle = ig.username || 'Instagram';
if (!ig.bio) {
items.push({ category: 'Instagram', detail: `@${handle} 바이오가 비어있습니다. CTA 링크와 소개를 추가하세요.`, severity: 'warning' });
}
if (!ig.externalUrl) {
items.push({ category: 'Instagram', detail: `@${handle} 외부 링크(웹사이트/예약)가 설정되지 않았습니다.`, severity: 'warning' });
}
if (!ig.isBusinessAccount) {
items.push({ category: 'Instagram', detail: `@${handle} 비즈니스 계정이 아닙니다. 인사이트 분석을 위해 비즈니스 계정 전환을 권장합니다.`, severity: 'critical' });
}
if (ig.followers && ig.followers > 1000 && ig.posts && ig.posts < 30) {
items.push({ category: 'Instagram', detail: `@${handle} 팔로워 대비 게시물이 적습니다 (${ig.posts}개). 콘텐츠 업로드 빈도를 높이세요.`, severity: 'warning' });
}
}
// Facebook diagnosis
if (enrichment.facebook) {
const fb = enrichment.facebook;
if ((fb.followers ?? 0) < 500) {
items.push({ category: 'Facebook', detail: `팔로워 ${fb.followers?.toLocaleString() ?? 0}명으로 페이지 활성화가 필요합니다.`, severity: 'warning' });
}
if (!fb.intro) {
items.push({ category: 'Facebook', detail: 'Facebook 페이지 소개글이 없습니다. 병원 정보와 CTA를 추가하세요.', severity: 'warning' });
}
}
// 강남언니 diagnosis
if (enrichment.gangnamUnni) {
const gu = enrichment.gangnamUnni;
if (gu.rating && gu.rating < 9.0) {
items.push({ category: '강남언니', detail: `평점 ${gu.rating}/10 — 업계 상위권(9.5+) 대비 개선 여지가 있습니다.`, severity: 'warning' });
}
if (gu.doctors && gu.doctors.length < 3) {
items.push({ category: '강남언니', detail: `등록 의사 ${gu.doctors.length}명 — 의료진 프로필을 더 등록하면 신뢰도가 높아집니다.`, severity: 'good' });
}
if (gu.totalReviews && gu.totalReviews > 5000) {
items.push({ category: '강남언니', detail: `리뷰 ${gu.totalReviews.toLocaleString()}건 — 우수한 리뷰 수입니다. 리뷰 관리와 답변에 집중하세요.`, severity: 'excellent' });
}
}
// Google Maps diagnosis
if (enrichment.googleMaps) {
const gm = enrichment.googleMaps;
if (gm.rating && gm.rating < 4.5) {
items.push({ category: 'Google Maps', detail: `평점 ${gm.rating}/5 — 부정 리뷰 대응과 만족도 개선이 필요합니다.`, severity: 'warning' });
}
if (gm.reviewCount && gm.reviewCount < 100) {
items.push({ category: 'Google Maps', detail: `리뷰 ${gm.reviewCount}건 — 더 많은 환자 리뷰를 유도하세요.`, severity: 'warning' });
}
}
// Naver diagnosis
if (enrichment.naverBlog) {
if (enrichment.naverBlog.totalResults && enrichment.naverBlog.totalResults < 100) {
items.push({ category: '네이버 블로그', detail: `블로그 검색 노출 ${enrichment.naverBlog.totalResults}건 — SEO 최적화 블로그 포스팅을 늘리세요.`, severity: 'warning' });
}
}
return items;
}
/**
* Merge enrichment data into an existing MarketingReport.
* Returns a new object — does not mutate the original.
@@ -590,13 +707,21 @@ export function mergeEnrichment(
const gu = enrichment.gangnamUnni;
// Update clinic snapshot with real gangnamUnni data
if (gu.rating) {
merged.clinicSnapshot = {
...merged.clinicSnapshot,
overallRating: gu.rating,
totalReviews: gu.totalReviews ?? merged.clinicSnapshot.totalReviews,
certifications: gu.badges?.length ? gu.badges : merged.clinicSnapshot.certifications,
};
merged.clinicSnapshot = {
...merged.clinicSnapshot,
overallRating: gu.rating ?? merged.clinicSnapshot.overallRating,
totalReviews: gu.totalReviews ?? merged.clinicSnapshot.totalReviews,
certifications: gu.badges?.length ? gu.badges : merged.clinicSnapshot.certifications,
staffCount: gu.doctors?.length ?? merged.clinicSnapshot.staffCount,
};
// Extract nearest station from address (Korean station name pattern)
const addressToSearch = gu.address || merged.clinicSnapshot.location;
if (addressToSearch && !merged.clinicSnapshot.nearestStation) {
const stationMatch = addressToSearch.match(/(\S+역)/);
if (stationMatch) {
merged.clinicSnapshot = { ...merged.clinicSnapshot, nearestStation: stationMatch[1] };
}
}
// Update lead doctor with gangnamUnni doctor data
@@ -694,5 +819,11 @@ export function mergeEnrichment(
}
}
// Generate data-driven diagnosis from enrichment data
const enrichDiagnosis = generateEnrichmentDiagnosis(enrichment);
if (enrichDiagnosis.length > 0) {
merged.problemDiagnosis = [...merged.problemDiagnosis, ...enrichDiagnosis];
}
return merged;
}