feat: add API Dashboard + filled icons + pipeline improvements

- Add /api-dashboard page with API connection status, env var checker,
  pipeline flow diagram, and cost estimator
- Add 15 new filled SVG icons (Shield, Database, Server, Bolt, Eye,
  Copy, Check, Cross, Warning, Refresh, Flow, Coin, LinkExternal etc.)
- Follow INFINITH design system: no emoji, no line icons, semantic
  status colors, diagonal shadows, brand gradients, font-serif headings
- Improve Vision Analysis with base64 encoding fix
- Add SectionErrorBoundary for graceful section-level error handling
- Add Google Places API utility (prepared for future migration)
- Fix Edge Function auth headers and report generation pipeline

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-06 14:59:31 +09:00
1 parent 2ca9ec0306
commit ec991057e6
20 files changed
+1397 -109

No files matched your search

+9 -7
View File
@@ -17,7 +17,7 @@ export default function Hero() {
{/* Background Gradient */}
<div className="absolute inset-0 -z-10 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-indigo-100 via-purple-50 to-pink-50 opacity-70"></div>
<div className="max-w-4xl mx-auto">
<div className="max-w-4xl mx-auto relative isolate">
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
@@ -45,7 +45,7 @@ export default function Hero() {
className="text-lg md:text-xl text-slate-600 mb-10 max-w-3xl mx-auto leading-relaxed"
>
Marketing that learns, improves, and accelerates — automatically. <br className="hidden md:block"/>
쓸수록 더 정교해지는 AI 마케팅 엔진. 콘텐츠 기획, 생성, 영상 제작, 채널 배포, 데이터 분석까지 하나로.
<span className="whitespace-nowrap">쓸수록 더 정교해지는</span>{' '}<span className="whitespace-nowrap">AI 마케팅 엔진.</span>{' '}<span className="whitespace-nowrap">콘텐츠 기획,</span>{' '}<span className="whitespace-nowrap">생성,</span>{' '}<span className="whitespace-nowrap">영상 제작,</span>{' '}<span className="whitespace-nowrap">채널 배포,</span>{' '}<span className="whitespace-nowrap">데이터 분석까지</span>{' '}<span className="whitespace-nowrap">하나로.</span>
</motion.p>
<motion.div
@@ -64,7 +64,7 @@ export default function Hero() {
className="w-full px-8 py-5 text-base font-medium bg-white/80 backdrop-blur-sm border border-slate-200 rounded-2xl focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent/40 shadow-sm text-center text-primary-900 placeholder:text-slate-400 transition-all group-hover:border-slate-300"
/>
</div>
<button onClick={handleAnalyze} className={`w-full px-8 py-5 text-base font-bold text-white rounded-2xl transition-all shadow-xl hover:shadow-2xl flex items-center justify-center gap-3 group hover:scale-[1.02] active:scale-[0.98] ${url.trim() ? 'bg-gradient-to-r from-accent to-[#021341]' : 'bg-slate-300 cursor-not-allowed'}`} disabled={!url.trim()}>
<button onClick={handleAnalyze} className={`relative z-10 w-full px-8 py-5 text-base font-bold rounded-2xl transition-all flex items-center justify-center gap-3 group ${url.trim() ? 'bg-gradient-to-r from-accent to-[#8B5CF6] text-white shadow-xl hover:shadow-2xl hover:scale-[1.02] active:scale-[0.98]' : 'bg-gradient-to-r from-[#4F1DA1] to-[#021341] text-white shadow-sm'}`} disabled={!url.trim()}>
Analyze Marketing Performance
<ArrowRight className="w-5 h-5 group-hover:translate-x-1 transition-transform" />
</button>
@@ -74,10 +74,12 @@ export default function Hero() {
</motion.div>
</div>
{/* Decorative elements */}
<div className="absolute top-1/4 left-10 w-64 h-64 bg-purple-300 rounded-full mix-blend-multiply filter blur-3xl opacity-30 animate-blob"></div>
<div className="absolute top-1/3 right-10 w-64 h-64 bg-pink-300 rounded-full mix-blend-multiply filter blur-3xl opacity-30 animate-blob animation-delay-2000"></div>
<div className="absolute -bottom-8 left-1/2 -translate-x-1/2 w-64 h-64 bg-indigo-300 rounded-full mix-blend-multiply filter blur-3xl opacity-30 animate-blob animation-delay-4000"></div>
{/* Decorative elements — isolate prevents mix-blend-multiply from bleeding into content */}
<div className="absolute inset-0 -z-[5] isolate pointer-events-none">
<div className="absolute top-1/4 left-10 w-64 h-64 bg-purple-300 rounded-full mix-blend-multiply filter blur-3xl opacity-30 animate-blob"></div>
<div className="absolute top-1/3 right-10 w-64 h-64 bg-pink-300 rounded-full mix-blend-multiply filter blur-3xl opacity-30 animate-blob animation-delay-2000"></div>
<div className="absolute -bottom-8 left-1/2 -translate-x-1/2 w-64 h-64 bg-indigo-300 rounded-full mix-blend-multiply filter blur-3xl opacity-30 animate-blob animation-delay-4000"></div>
</div>
</section>
);
}
+142
View File
@@ -134,6 +134,148 @@ export function MusicFilled({ size = 20, className = '' }: IconProps) {
);
}
/* ─── Dashboard / Utility Icons ─── */
export function ShieldFilled({ size = 20, className = '' }: IconProps) {
return (
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" className={className}>
<path d="M12 2L3 7V12C3 17.5 6.8 22.7 12 24C17.2 22.7 21 17.5 21 12V7L12 2Z" fill="currentColor" opacity="0.25" />
<path d="M12 2L3 7V12C3 17.5 6.8 22.7 12 24C17.2 22.7 21 17.5 21 12V7L12 2Z" fill="currentColor" opacity="0.3" />
<path d="M10 14L8.5 12.5L7.5 13.5L10 16L16.5 9.5L15.5 8.5L10 14Z" fill="currentColor" />
</svg>
);
}
export function DatabaseFilled({ size = 20, className = '' }: IconProps) {
return (
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" className={className}>
<ellipse cx="12" cy="6" rx="8" ry="3" fill="currentColor" opacity="0.35" />
<path d="M4 6V12C4 13.66 7.58 15 12 15C16.42 15 20 13.66 20 12V6" fill="currentColor" opacity="0.25" />
<path d="M4 12V18C4 19.66 7.58 21 12 21C16.42 21 20 19.66 20 18V12" fill="currentColor" opacity="0.35" />
<ellipse cx="12" cy="18" rx="8" ry="3" fill="currentColor" opacity="0.5" />
</svg>
);
}
export function ServerFilled({ size = 20, className = '' }: IconProps) {
return (
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" className={className}>
<rect x="3" y="2" width="18" height="8" rx="2" fill="currentColor" opacity="0.3" />
<rect x="3" y="14" width="18" height="8" rx="2" fill="currentColor" opacity="0.3" />
<circle cx="7" cy="6" r="1.5" fill="currentColor" />
<circle cx="7" cy="18" r="1.5" fill="currentColor" />
<rect x="11" y="5" width="6" height="2" rx="1" fill="currentColor" opacity="0.5" />
<rect x="11" y="17" width="6" height="2" rx="1" fill="currentColor" opacity="0.5" />
</svg>
);
}
export function BoltFilled({ size = 20, className = '' }: IconProps) {
return (
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" className={className}>
<path d="M13 2L4 14H11L10 22L20 10H13L13 2Z" fill="currentColor" opacity="0.25" />
<path d="M13 2L4 14H11L10 22L20 10H13L13 2Z" fill="currentColor" />
</svg>
);
}
export function EyeFilled({ size = 20, className = '' }: IconProps) {
return (
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" className={className}>
<path d="M12 4.5C7 4.5 2.73 7.61 1 12C2.73 16.39 7 19.5 12 19.5C17 19.5 21.27 16.39 23 12C21.27 7.61 17 4.5 12 4.5Z" fill="currentColor" opacity="0.2" />
<circle cx="12" cy="12" r="4" fill="currentColor" />
</svg>
);
}
export function EyeOffFilled({ size = 20, className = '' }: IconProps) {
return (
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" className={className}>
<path d="M12 4.5C7 4.5 2.73 7.61 1 12C2.73 16.39 7 19.5 12 19.5C17 19.5 21.27 16.39 23 12C21.27 7.61 17 4.5 12 4.5Z" fill="currentColor" opacity="0.15" />
<circle cx="12" cy="12" r="4" fill="currentColor" opacity="0.3" />
<line x1="4" y1="4" x2="20" y2="20" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" />
</svg>
);
}
export function CopyFilled({ size = 20, className = '' }: IconProps) {
return (
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" className={className}>
<rect x="8" y="8" width="12" height="14" rx="2" fill="currentColor" opacity="0.25" />
<rect x="4" y="2" width="12" height="14" rx="2" fill="currentColor" opacity="0.5" />
</svg>
);
}
export function CheckFilled({ size = 20, className = '' }: IconProps) {
return (
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" className={className}>
<circle cx="12" cy="12" r="10" fill="currentColor" opacity="0.25" />
<path d="M8 12L11 15L16 9" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" />
</svg>
);
}
export function CrossFilled({ size = 20, className = '' }: IconProps) {
return (
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" className={className}>
<circle cx="12" cy="12" r="10" fill="currentColor" opacity="0.25" />
<path d="M8 8L16 16M16 8L8 16" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" />
</svg>
);
}
export function WarningFilled({ size = 20, className = '' }: IconProps) {
return (
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" className={className}>
<path d="M12 2L1 21H23L12 2Z" fill="currentColor" opacity="0.25" />
<rect x="11" y="9" width="2" height="6" rx="1" fill="currentColor" />
<circle cx="12" cy="18" r="1.2" fill="currentColor" />
</svg>
);
}
export function RefreshFilled({ size = 20, className = '' }: IconProps) {
return (
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" className={className}>
<circle cx="12" cy="12" r="9" fill="currentColor" opacity="0.15" />
<path d="M17.65 6.35A7.95 7.95 0 0012 4C7.58 4 4 7.58 4 12C4 16.42 7.58 20 12 20C15.73 20 18.84 17.45 19.73 14H17.65C16.83 16.33 14.61 18 12 18C8.69 18 6 15.31 6 12C6 8.69 8.69 6 12 6C13.66 6 15.14 6.69 16.22 7.78L13 11H20V4L17.65 6.35Z" fill="currentColor" />
</svg>
);
}
export function FlowFilled({ size = 20, className = '' }: IconProps) {
return (
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" className={className}>
<rect x="2" y="3" width="6" height="6" rx="1.5" fill="currentColor" opacity="0.35" />
<rect x="9" y="9" width="6" height="6" rx="1.5" fill="currentColor" opacity="0.5" />
<rect x="16" y="15" width="6" height="6" rx="1.5" fill="currentColor" />
<path d="M8 6H9.5C10.33 6 11 6.67 11 7.5V9" stroke="currentColor" strokeWidth="1.5" opacity="0.4" />
<path d="M15 12H16.5C17.33 12 18 12.67 18 13.5V15" stroke="currentColor" strokeWidth="1.5" opacity="0.4" />
</svg>
);
}
export function CoinFilled({ size = 20, className = '' }: IconProps) {
return (
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" className={className}>
<circle cx="12" cy="12" r="10" fill="currentColor" opacity="0.25" />
<circle cx="12" cy="12" r="7" fill="currentColor" opacity="0.35" />
<text x="12" y="16" textAnchor="middle" fontSize="10" fontWeight="bold" fill="currentColor">$</text>
</svg>
);
}
export function LinkExternalFilled({ size = 20, className = '' }: IconProps) {
return (
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" className={className}>
<rect x="3" y="5" width="14" height="14" rx="2" fill="currentColor" opacity="0.2" />
<path d="M14 3H21V10" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" />
<path d="M21 3L10 14" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" />
</svg>
);
}
/**
* InfinityLoopFilled — Infinite Marketing loop icon.
* HubSpot-style infinity loop with gradient shading.
+8 -7
View File
@@ -10,22 +10,23 @@ interface KPIDashboardProps {
clinicName?: string;
}
function isNegativeValue(value: string): boolean {
const lower = value.toLowerCase();
function isNegativeValue(value: string | number): boolean {
const lower = String(value).toLowerCase();
return lower === '0' || lower.includes('없음') || lower.includes('불가') || lower === 'n/a' || lower === '-' || lower.includes('측정 불가');
}
/** Format large numbers for readability: 150000 → 150K, 1500000 → 1.5M */
function formatKpiValue(value: string): string {
function formatKpiValue(value: string | number): string {
const str = String(value ?? '');
// If already formatted (contains K, M, %, ~, 월, 건, etc.) return as-is
if (/[KkMm%~월건회개명/]/.test(value)) return value;
if (/[KkMm%~월건회개명/]/.test(str)) return str;
// Try to parse as pure number
const num = parseInt(value.replace(/,/g, ''), 10);
if (isNaN(num)) return value;
const num = parseInt(str.replace(/,/g, ''), 10);
if (isNaN(num)) return str;
if (num >= 1_000_000) return `${(num / 1_000_000).toFixed(1)}M`;
if (num >= 10_000) return `${Math.round(num / 1_000)}K`;
if (num >= 1_000) return `${(num / 1_000).toFixed(1)}K`;
return value;
return str;
}
export default function KPIDashboard({ metrics, clinicName }: KPIDashboardProps) {
+5 -2
View File
@@ -23,8 +23,8 @@ function clusterDiagnosis(items: DiagnosisItem[]): {
const funnelItems: string[] = [];
for (const item of items) {
const cat = item.category.toLowerCase();
const det = item.detail.toLowerCase();
const cat = String(item.category ?? '').toLowerCase();
const det = String(item.detail ?? '').toLowerCase();
// Brand identity / consistency issues
if (
@@ -91,6 +91,9 @@ function clusterDiagnosis(items: DiagnosisItem[]): {
}
export default function ProblemDiagnosis({ diagnosis }: ProblemDiagnosisProps) {
if (!diagnosis || !Array.isArray(diagnosis) || diagnosis.length === 0) {
return null;
}
const clusters = clusterDiagnosis(diagnosis);
return (
@@ -0,0 +1,33 @@
import { Component, type ReactNode } from 'react';
interface Props {
children: ReactNode;
fallback?: ReactNode;
}
interface State {
hasError: boolean;
}
export class SectionErrorBoundary extends Component<Props, State> {
state: State = { hasError: false };
static getDerivedStateFromError() {
return { hasError: true };
}
componentDidCatch(error: Error) {
console.error('[SectionErrorBoundary]', error.message, error.stack);
}
render() {
if (this.state.hasError) {
return this.props.fallback ?? (
<div className="px-6 py-4 bg-red-50 border border-red-200 rounded-xl my-4 mx-4">
<p className="text-xs font-mono text-red-600">섹션 렌더링 오류 (콘솔 확인)</p>
</div>
);
}
return this.props.children;
}
}
+16 -7
View File
@@ -124,10 +124,12 @@ function buildDiagnosis(report: ApiReport): DiagnosisItem[] {
// AI-generated per-channel diagnosis array (new format)
if (ch.diagnosis) {
for (const d of ch.diagnosis) {
if (d.issue) {
const issue = typeof d.issue === 'string' ? d.issue : typeof d === 'string' ? d : JSON.stringify(d.issue ?? d);
if (issue) {
const rec = typeof d.recommendation === 'string' ? d.recommendation : '';
items.push({
category: CHANNEL_ICONS[channel] ? channel : channel,
detail: d.recommendation ? `${d.issue} — ${d.recommendation}` : d.issue,
detail: rec ? `${issue} — ${rec}` : issue,
severity: (d.severity as Severity) || 'warning',
});
}
@@ -143,7 +145,7 @@ function buildDiagnosis(report: ApiReport): DiagnosisItem[] {
}
if (ch.issues) {
for (const issue of ch.issues) {
items.push({ category: channel, detail: issue, severity: 'warning' });
items.push({ category: channel, detail: typeof issue === 'string' ? issue : JSON.stringify(issue), severity: 'warning' });
}
}
}
@@ -274,6 +276,13 @@ function buildTransformation(r: ApiReport): import('../types/report').Transforma
return { brandIdentity, contentStrategy, platformStrategies, websiteImprovements, newChannelProposals };
}
/** Safely format KPI values — handles numbers, strings, and nulls from AI output */
function fmtKpi(v: unknown): string {
if (v == null) return '-';
if (typeof v === 'number') return fmt(v);
return String(v);
}
function fmt(n: number): string {
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;
if (n >= 1_000) return `${(n / 1_000).toFixed(n >= 10_000 ? 0 : 1)}K`;
@@ -468,15 +477,15 @@ function buildKpiDashboard(r: ApiReport): import('../types/report').KPIMetric[]
// Use AI's gangnamunni data — update existing or add
const guIdx = metrics.findIndex(m => m.metric.includes('강남언니'));
if (guIdx >= 0) {
metrics[guIdx] = { metric: k.metric, current: k.current || '-', target3Month: k.target3Month || '-', target12Month: k.target12Month || '-' };
metrics[guIdx] = { metric: k.metric, current: fmtKpi(k.current), target3Month: fmtKpi(k.target3Month), target12Month: fmtKpi(k.target12Month) };
continue;
}
}
metrics.push({
metric: k.metric,
current: k.current || '-',
target3Month: k.target3Month || '-',
target12Month: k.target12Month || '-',
current: fmtKpi(k.current),
target3Month: fmtKpi(k.target3Month),
target12Month: fmtKpi(k.target12Month),
});
}
}
+2
View File
@@ -12,6 +12,7 @@ import DistributionPage from './pages/DistributionPage.tsx';
import PerformancePage from './pages/PerformancePage.tsx';
import DataValidationPage from './pages/DataValidationPage.tsx';
import ClinicProfilePage from './pages/ClinicProfilePage.tsx';
import ApiDashboardPage from './pages/ApiDashboardPage.tsx';
import './index.css';
createRoot(document.getElementById('root')!).render(
@@ -30,6 +31,7 @@ createRoot(document.getElementById('root')!).render(
<Route path="performance" element={<PerformancePage />} />
<Route path="data-validation" element={<DataValidationPage />} />
<Route path="clinic/:id" element={<ClinicProfilePage />} />
<Route path="api-dashboard" element={<ApiDashboardPage />} />
</Route>
</Routes>
</BrowserRouter>
+621
View File
@@ -0,0 +1,621 @@
import { useState, useEffect, type ReactNode } from 'react';
import { motion } from 'motion/react';
import { ArrowRight } from 'lucide-react';
import {
ShieldFilled, DatabaseFilled, ServerFilled, BoltFilled,
EyeFilled, EyeOffFilled, CopyFilled, CheckFilled, CrossFilled,
WarningFilled, RefreshFilled, FlowFilled, CoinFilled,
LinkExternalFilled, GlobeFilled, PrismFilled,
YoutubeFilled, VideoFilled, MegaphoneFilled,
} from '../components/icons/FilledIcons';
/* ───────────────────────────── Types ───────────────────────────── */
type ApiStatus = 'connected' | 'missing' | 'error';
type ApiLayer = 'frontend' | 'edge-function' | 'both';
interface ApiConfig {
id: string;
name: string;
description: string;
envKeys: string[];
layer: ApiLayer;
docsUrl: string;
IconComponent: (props: { size?: number; className?: string }) => ReactNode;
category: 'ai' | 'scraping' | 'social' | 'platform';
pricingModel: string;
usedInPhases: string[];
estimatedCostPerRun?: string;
rateLimit?: string;
notes?: string;
}
interface ApiStatusInfo extends ApiConfig {
status: ApiStatus;
keyPresent: Record<string, boolean>;
}
/* ──────────────────── API Registry (source of truth) ──────────── */
const API_REGISTRY: ApiConfig[] = [
{
id: 'supabase',
name: 'Supabase',
description: 'PostgreSQL DB + Auth + Edge Functions 호스팅',
envKeys: ['VITE_SUPABASE_URL', 'VITE_SUPABASE_ANON_KEY'],
layer: 'both',
docsUrl: 'https://supabase.com/docs',
IconComponent: BoltFilled,
category: 'platform',
pricingModel: 'Free tier → Pro $25/mo',
usedInPhases: ['All phases'],
rateLimit: 'Edge Functions: 500K invocations/mo (free)',
notes: '모든 데이터 저장 및 Edge Function 실행 플랫폼',
},
{
id: 'perplexity',
name: 'Perplexity AI',
description: 'LLM 기반 시장 분석 및 리포트 생성',
envKeys: ['PERPLEXITY_API_KEY'],
layer: 'edge-function',
docsUrl: 'https://docs.perplexity.ai',
IconComponent: PrismFilled,
category: 'ai',
pricingModel: 'Sonar: $1/1K requests',
usedInPhases: ['Phase 1: discover', 'Phase 2: collect', 'Phase 3: generate'],
estimatedCostPerRun: '~$0.05-0.15',
rateLimit: '50 RPM (rate limit)',
notes: 'discover(2회) + collect(4회 병렬) + generate(1회) = 분석당 ~7회 호출',
},
{
id: 'firecrawl',
name: 'Firecrawl',
description: '웹 스크래핑, 스크린샷 캡처, 구조화 데이터 추출',
envKeys: ['FIRECRAWL_API_KEY'],
layer: 'edge-function',
docsUrl: 'https://docs.firecrawl.dev',
IconComponent: GlobeFilled,
category: 'scraping',
pricingModel: 'Free 500 credits → $19/mo',
usedInPhases: ['Phase 1: discover', 'Phase 2: collect'],
estimatedCostPerRun: '~5-10 credits',
rateLimit: '3 RPM (free), 20 RPM (paid)',
notes: 'scrape + map + search + fullPage screenshot',
},
{
id: 'apify',
name: 'Apify',
description: 'Instagram/Facebook/Google Places 데이터 수집',
envKeys: ['APIFY_API_TOKEN'],
layer: 'edge-function',
docsUrl: 'https://docs.apify.com',
IconComponent: ServerFilled,
category: 'scraping',
pricingModel: 'Free $5/mo → Starter $49/mo',
usedInPhases: ['Phase 1: discover', 'Phase 2: collect', 'Enrich'],
estimatedCostPerRun: '~$0.10-0.30',
rateLimit: 'Actor-dependent (30-120s timeout)',
notes: 'IG profile/posts/reels + FB pages + Google Places actors',
},
{
id: 'youtube',
name: 'YouTube Data API v3',
description: 'YouTube 채널 검색, 통계, 영상 데이터',
envKeys: ['YOUTUBE_API_KEY'],
layer: 'edge-function',
docsUrl: 'https://developers.google.com/youtube/v3',
IconComponent: YoutubeFilled,
category: 'social',
pricingModel: 'Free (10,000 units/day)',
usedInPhases: ['Phase 1: discover', 'Phase 2: collect'],
estimatedCostPerRun: '~200-400 units',
rateLimit: '10,000 units/day',
notes: 'search(100u) + channels(5u) + videos(5u each)',
},
{
id: 'naver',
name: 'Naver Search API',
description: '네이버 블로그/웹/플레이스 검색',
envKeys: ['NAVER_CLIENT_ID', 'NAVER_CLIENT_SECRET'],
layer: 'edge-function',
docsUrl: 'https://developers.naver.com/docs/serviceapi/search/blog/blog.md',
IconComponent: MegaphoneFilled,
category: 'social',
pricingModel: 'Free (25,000/day)',
usedInPhases: ['Phase 1: discover', 'Phase 2: collect'],
estimatedCostPerRun: 'Free',
rateLimit: '25,000 calls/day',
notes: 'blog.json + webkr.json + local.json',
},
{
id: 'gemini',
name: 'Google Gemini',
description: 'AI 이미지 생성 + Vision 분석 (스크린샷 OCR)',
envKeys: ['GEMINI_API_KEY'],
layer: 'both',
docsUrl: 'https://ai.google.dev/docs',
IconComponent: DatabaseFilled,
category: 'ai',
pricingModel: 'Free tier → Pay-as-you-go',
usedInPhases: ['Phase 2: collect (Vision)', 'Studio (Image Gen)'],
estimatedCostPerRun: '~$0.01-0.05',
rateLimit: '15 RPM (free), 1000 RPM (paid)',
notes: 'gemini-2.5-flash-image 모델 사용',
},
{
id: 'creatomate',
name: 'Creatomate',
description: '마케팅 영상 자동 생성 (템플릿 기반)',
envKeys: ['VITE_CREATOMATE_API_KEY'],
layer: 'frontend',
docsUrl: 'https://creatomate.com/docs/api/introduction',
IconComponent: VideoFilled,
category: 'ai',
pricingModel: 'Free 5 renders → Pro $39/mo',
usedInPhases: ['Studio'],
estimatedCostPerRun: '1 render credit',
rateLimit: '2 concurrent renders (free)',
notes: 'POST /renders → poll until complete',
},
];
/* ────────────────── Environment Variable Checker ─────────────── */
function checkEnvVars(): ApiStatusInfo[] {
return API_REGISTRY.map((api) => {
const keyPresent: Record<string, boolean> = {};
for (const key of api.envKeys) {
if (key.startsWith('VITE_')) {
const val = (import.meta.env as Record<string, string | undefined>)[key];
keyPresent[key] = !!val && val.length > 0;
} else {
keyPresent[key] = true;
}
}
const allPresent = Object.values(keyPresent).every(Boolean);
const nonePresent = Object.values(keyPresent).every((v) => !v);
return {
...api,
status: nonePresent ? 'missing' : allPresent ? 'connected' : 'error',
keyPresent,
};
});
}
/* ──────────────────────── Sub-components ──────────────────────── */
function StatusDot({ status }: { status: ApiStatus }) {
const styles = {
connected: 'bg-status-good-dot',
missing: 'bg-status-critical-dot',
error: 'bg-status-warning-dot',
};
return (
<span className="relative flex h-3 w-3">
{status === 'connected' && (
<span className={`animate-ping absolute inline-flex h-full w-full rounded-full opacity-40 ${styles[status]}`} />
)}
<span className={`relative inline-flex rounded-full h-3 w-3 ${styles[status]}`} />
</span>
);
}
function StatusBadge({ status }: { status: ApiStatus }) {
const config = {
connected: { bg: 'bg-status-good-bg', text: 'text-status-good-text', border: 'border-status-good-border', label: 'Connected', Icon: CheckFilled },
missing: { bg: 'bg-status-critical-bg', text: 'text-status-critical-text', border: 'border-status-critical-border', label: 'Missing Key', Icon: CrossFilled },
error: { bg: 'bg-status-warning-bg', text: 'text-status-warning-text', border: 'border-status-warning-border', label: 'Partial', Icon: WarningFilled },
};
const c = config[status];
return (
<span className={`inline-flex items-center gap-1.5 px-2.5 py-1 text-xs font-semibold rounded-full border ${c.bg} ${c.text} ${c.border}`}>
<c.Icon size={12} className={c.text} />
{c.label}
</span>
);
}
function LayerBadge({ layer }: { layer: ApiLayer }) {
const config = {
frontend: { bg: 'bg-status-info-bg', text: 'text-status-info-text', border: 'border-status-info-border', label: 'Frontend', Icon: GlobeFilled },
'edge-function': { bg: 'bg-status-good-bg', text: 'text-status-good-text', border: 'border-status-good-border', label: 'Edge Function', Icon: ServerFilled },
both: { bg: 'bg-status-warning-bg', text: 'text-status-warning-text', border: 'border-status-warning-border', label: 'Both', Icon: BoltFilled },
};
const c = config[layer];
return (
<span className={`inline-flex items-center gap-1 px-2 py-0.5 text-[11px] font-medium rounded-md border ${c.bg} ${c.text} ${c.border}`}>
<c.Icon size={12} className={c.text} />
{c.label}
</span>
);
}
function CategoryBadge({ category }: { category: ApiConfig['category'] }) {
const config = {
ai: { bg: 'bg-status-good-bg', text: 'text-status-good-text', label: 'AI' },
scraping: { bg: 'bg-status-warning-bg', text: 'text-status-warning-text', label: 'Scraping' },
social: { bg: 'bg-status-info-bg', text: 'text-status-info-text', label: 'Social' },
platform: { bg: 'bg-primary-50', text: 'text-primary-800', label: 'Platform' },
};
const c = config[category];
return (
<span className={`px-2 py-0.5 text-[11px] font-medium rounded-md ${c.bg} ${c.text}`}>
{c.label}
</span>
);
}
function EnvKeyRow({ envKey, present, isServerSide }: { envKey: string; present: boolean; isServerSide: boolean }) {
const [showKey, setShowKey] = useState(false);
const [copied, setCopied] = useState(false);
const value = isServerSide
? '(Edge Function 환경변수 — 프론트엔드에서 확인 불가)'
: showKey
? (import.meta.env as Record<string, string | undefined>)[envKey] || ''
: '••••••••••••••••';
const handleCopy = () => {
if (!isServerSide) {
navigator.clipboard.writeText((import.meta.env as Record<string, string | undefined>)[envKey] || '');
setCopied(true);
setTimeout(() => setCopied(false), 1500);
}
};
return (
<div className="flex items-center gap-2 py-1.5 px-3 rounded-lg bg-primary-50 text-xs font-mono group">
<StatusDot status={present ? 'connected' : 'missing'} />
<span className="text-slate-500 min-w-[200px]">{envKey}</span>
<span className="text-slate-400 flex-1 truncate">{value}</span>
{!isServerSide && (
<div className="flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
<button onClick={() => setShowKey(!showKey)} className="p-1 hover:bg-slate-200 rounded">
{showKey
? <EyeOffFilled size={14} className="text-slate-400" />
: <EyeFilled size={14} className="text-slate-400" />}
</button>
<button onClick={handleCopy} className="p-1 hover:bg-slate-200 rounded">
{copied
? <CheckFilled size={14} className="text-status-good-dot" />
: <CopyFilled size={14} className="text-slate-400" />}
</button>
</div>
)}
</div>
);
}
function ApiCard({ api, index }: { api: ApiStatusInfo; index: number }) {
const [expanded, setExpanded] = useState(false);
return (
<motion.div
initial={{ opacity: 0, y: 16 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.3, delay: index * 0.05 }}
className="bg-white rounded-2xl border border-slate-100 shadow-[3px_4px_12px_rgba(0,0,0,0.06)] hover:shadow-[4px_6px_16px_rgba(0,0,0,0.09)] transition-shadow overflow-hidden"
>
{/* Header */}
<button
onClick={() => setExpanded(!expanded)}
className="w-full px-6 py-5 flex items-center gap-4 text-left"
>
<div className="flex-shrink-0 w-10 h-10 rounded-xl bg-accent/10 flex items-center justify-center">
<api.IconComponent size={20} className="text-accent" />
</div>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2 mb-1">
<h3 className="font-serif font-bold text-primary-900 text-base">{api.name}</h3>
<StatusDot status={api.status} />
</div>
<p className="text-xs text-slate-500 truncate">{api.description}</p>
</div>
<div className="flex items-center gap-2 flex-shrink-0">
<CategoryBadge category={api.category} />
<LayerBadge layer={api.layer} />
<StatusBadge status={api.status} />
</div>
</button>
{/* Expandable detail */}
{expanded && (
<motion.div
initial={{ height: 0, opacity: 0 }}
animate={{ height: 'auto', opacity: 1 }}
transition={{ duration: 0.2 }}
className="border-t border-slate-100 px-6 py-4 space-y-4"
>
{/* Env Keys */}
<div>
<h4 className="text-xs font-semibold text-slate-400 uppercase tracking-wider mb-2">Environment Variables</h4>
<div className="space-y-1.5">
{api.envKeys.map((key) => (
<EnvKeyRow
key={key}
envKey={key}
present={api.keyPresent[key]}
isServerSide={!key.startsWith('VITE_')}
/>
))}
</div>
</div>
{/* Info Grid */}
<div className="grid grid-cols-2 md:grid-cols-4 gap-3">
<div className="bg-primary-50 rounded-xl p-3">
<div className="text-[11px] text-slate-400 font-medium mb-1">Pricing</div>
<div className="text-xs font-semibold text-slate-700">{api.pricingModel}</div>
</div>
{api.estimatedCostPerRun && (
<div className="bg-primary-50 rounded-xl p-3">
<div className="text-[11px] text-slate-400 font-medium mb-1">Cost / Run</div>
<div className="text-xs font-semibold text-slate-700">{api.estimatedCostPerRun}</div>
</div>
)}
{api.rateLimit && (
<div className="bg-primary-50 rounded-xl p-3">
<div className="text-[11px] text-slate-400 font-medium mb-1">Rate Limit</div>
<div className="text-xs font-semibold text-slate-700">{api.rateLimit}</div>
</div>
)}
<div className="bg-primary-50 rounded-xl p-3">
<div className="text-[11px] text-slate-400 font-medium mb-1">Used In</div>
<div className="text-xs font-semibold text-slate-700">{api.usedInPhases.join(', ')}</div>
</div>
</div>
{/* Notes + Docs link */}
<div className="flex items-center justify-between">
{api.notes && (
<p className="text-xs text-slate-500 italic">{api.notes}</p>
)}
<a
href={api.docsUrl}
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline flex-shrink-0"
>
API Docs <LinkExternalFilled size={12} className="text-accent" />
</a>
</div>
</motion.div>
)}
</motion.div>
);
}
/* ──────────────────── Pipeline Flow Diagram ───────────────────── */
function PipelineFlow({ apis }: { apis: ApiStatusInfo[] }) {
const phases = [
{ name: 'Phase 1', label: 'Discover Channels', apis: ['firecrawl', 'youtube', 'naver', 'perplexity', 'apify'] },
{ name: 'Phase 2', label: 'Collect Data', apis: ['apify', 'youtube', 'firecrawl', 'naver', 'perplexity', 'gemini'] },
{ name: 'Phase 3', label: 'Generate Report', apis: ['perplexity'] },
{ name: 'Studio', label: 'Content Creation', apis: ['gemini', 'creatomate'] },
];
const apiMap = Object.fromEntries(apis.map((a) => [a.id, a]));
return (
<div className="bg-white rounded-2xl border border-slate-100 shadow-[3px_4px_12px_rgba(0,0,0,0.06)] p-6">
<h3 className="font-serif font-bold text-primary-900 text-base mb-5 flex items-center gap-2">
<FlowFilled size={18} className="text-accent" />
Pipeline API Flow
</h3>
<div className="grid grid-cols-1 md:grid-cols-4 gap-4">
{phases.map((phase, idx) => (
<div key={phase.name} className="relative">
<div className="bg-gradient-to-r from-[#4F1DA1] to-[#021341] text-white text-xs font-bold px-3 py-1.5 rounded-t-xl">
{phase.name}: {phase.label}
</div>
<div className="border border-t-0 border-slate-200 rounded-b-xl p-3 space-y-1.5 min-h-[100px]">
{phase.apis.map((apiId) => {
const api = apiMap[apiId];
if (!api) return null;
return (
<div key={apiId} className="flex items-center gap-2 text-xs">
<StatusDot status={api.status} />
<api.IconComponent size={14} className="text-slate-400" />
<span className="text-slate-600">{api.name}</span>
</div>
);
})}
</div>
{idx < phases.length - 1 && (
<div className="hidden md:flex absolute -right-3 top-1/2 transform -translate-y-1/2 z-10">
<ArrowRight className="w-4 h-4 text-slate-300" />
</div>
)}
</div>
))}
</div>
</div>
);
}
/* ────────────────────── Cost Estimator ────────────────────────── */
function CostEstimator({ apis }: { apis: ApiStatusInfo[] }) {
const costItems = apis
.filter((a) => a.estimatedCostPerRun)
.map((a) => ({
name: a.name,
IconComponent: a.IconComponent,
cost: a.estimatedCostPerRun!,
}));
return (
<div className="bg-white rounded-2xl border border-slate-100 shadow-[3px_4px_12px_rgba(0,0,0,0.06)] p-6">
<h3 className="font-serif font-bold text-primary-900 text-base mb-4 flex items-center gap-2">
<CoinFilled size={18} className="text-accent" />
Estimated Cost per Analysis Run
</h3>
<div className="space-y-2">
{costItems.map((item) => (
<div key={item.name} className="flex items-center justify-between py-2 px-3 bg-primary-50 rounded-xl">
<span className="text-sm text-slate-700 flex items-center gap-2">
<item.IconComponent size={16} className="text-slate-400" />
{item.name}
</span>
<span className="text-sm font-bold text-primary-900">{item.cost}</span>
</div>
))}
<div className="flex items-center justify-between py-3 px-3 bg-accent/5 rounded-xl border border-accent/20 mt-3">
<span className="text-sm font-bold text-primary-900">Total (estimated)</span>
<span className="text-sm font-black text-accent">~$0.26-0.80 / run</span>
</div>
</div>
</div>
);
}
/* ──────────────────────── Main Page ───────────────────────────── */
export default function ApiDashboardPage() {
const [apis, setApis] = useState<ApiStatusInfo[]>([]);
const [lastChecked, setLastChecked] = useState<Date | null>(null);
const [filter, setFilter] = useState<'all' | 'connected' | 'missing'>('all');
const refreshStatus = () => {
setApis(checkEnvVars());
setLastChecked(new Date());
};
useEffect(() => {
refreshStatus();
}, []);
const connectedCount = apis.filter((a) => a.status === 'connected').length;
const missingCount = apis.filter((a) => a.status === 'missing').length;
const errorCount = apis.filter((a) => a.status === 'error').length;
const filteredApis = filter === 'all' ? apis : apis.filter((a) => a.status === filter);
return (
<div className="min-h-screen bg-slate-50 pt-28 pb-16 px-6">
<div className="max-w-7xl mx-auto space-y-8">
{/* Page Header */}
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.5 }}
>
<div className="flex items-center gap-3 mb-2">
<div className="p-2.5 bg-accent/10 rounded-xl">
<ShieldFilled size={24} className="text-accent" />
</div>
<div>
<h1 className="font-serif text-3xl font-bold text-primary-900">API Dashboard</h1>
<p className="text-sm text-slate-500">API 연결 상태, 환경변수, 사용량, 비용 현황</p>
</div>
</div>
</motion.div>
{/* Summary Cards */}
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.5, delay: 0.1 }}
className="grid grid-cols-2 md:grid-cols-4 gap-4"
>
<div className="bg-white rounded-2xl border border-slate-100 shadow-[3px_4px_12px_rgba(0,0,0,0.06)] p-5">
<div className="flex items-center gap-2 mb-2">
<DatabaseFilled size={16} className="text-slate-400" />
<span className="text-xs font-medium text-slate-400 uppercase tracking-wider">Total APIs</span>
</div>
<div className="text-3xl font-black text-primary-900">{apis.length}</div>
</div>
<div className="bg-white rounded-2xl border border-slate-100 shadow-[3px_4px_12px_rgba(0,0,0,0.06)] p-5">
<div className="flex items-center gap-2 mb-2">
<CheckFilled size={16} className="text-status-good-dot" />
<span className="text-xs font-medium text-slate-400 uppercase tracking-wider">Connected</span>
</div>
<div className="text-3xl font-black text-status-good-text">{connectedCount}</div>
</div>
<div className="bg-white rounded-2xl border border-slate-100 shadow-[3px_4px_12px_rgba(0,0,0,0.06)] p-5">
<div className="flex items-center gap-2 mb-2">
<CrossFilled size={16} className="text-status-critical-dot" />
<span className="text-xs font-medium text-slate-400 uppercase tracking-wider">Missing</span>
</div>
<div className="text-3xl font-black text-status-critical-text">{missingCount}</div>
</div>
<div className="bg-white rounded-2xl border border-slate-100 shadow-[3px_4px_12px_rgba(0,0,0,0.06)] p-5">
<div className="flex items-center gap-2 mb-2">
<WarningFilled size={16} className="text-status-warning-dot" />
<span className="text-xs font-medium text-slate-400 uppercase tracking-wider">Partial</span>
</div>
<div className="text-3xl font-black text-status-warning-text">{errorCount}</div>
</div>
</motion.div>
{/* Pipeline Flow */}
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.5, delay: 0.15 }}
>
<PipelineFlow apis={apis} />
</motion.div>
{/* Filter + Refresh */}
<div className="flex items-center justify-between">
<div className="flex gap-2">
{(['all', 'connected', 'missing'] as const).map((f) => (
<button
key={f}
onClick={() => setFilter(f)}
className={`px-5 py-2.5 text-xs font-semibold rounded-full transition-all ${
filter === f
? 'bg-gradient-to-r from-[#4F1DA1] to-[#021341] text-white shadow-[3px_4px_12px_rgba(0,0,0,0.06)]'
: 'bg-white text-slate-500 border border-slate-200 hover:bg-slate-50'
}`}
>
{f === 'all' ? 'All' : f === 'connected' ? 'Connected' : 'Missing'}
</button>
))}
</div>
<div className="flex items-center gap-3">
{lastChecked && (
<span className="text-xs text-slate-400">
Last checked: {lastChecked.toLocaleTimeString('ko-KR')}
</span>
)}
<button
onClick={refreshStatus}
className="inline-flex items-center gap-1.5 px-5 py-2.5 text-xs font-semibold bg-white border border-slate-200 rounded-full hover:bg-slate-50 transition-all text-slate-600"
>
<RefreshFilled size={14} className="text-slate-500" />
Refresh
</button>
</div>
</div>
{/* API Cards */}
<div className="space-y-3">
{filteredApis.map((api, idx) => (
<ApiCard key={api.id} api={api} index={idx} />
))}
</div>
{/* Cost Estimator */}
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.5, delay: 0.2 }}
>
<CostEstimator apis={apis} />
</motion.div>
{/* Footer note */}
<div className="text-center text-xs text-slate-400 pt-4">
<PrismFilled size={14} className="text-slate-300 inline mr-1" />
VITE_ 접두사 키만 프론트엔드에서 확인 가능합니다. Edge Function 키는 Supabase Dashboard에서 확인하세요.
</div>
</div>
</div>
);
}
+12 -11
View File
@@ -6,6 +6,7 @@ import { ReportNav } from '../components/report/ReportNav';
import { ScreenshotProvider } from '../contexts/ScreenshotContext';
// Report section components
import { SectionErrorBoundary } from '../components/report/ui/SectionErrorBoundary';
import ReportHeader from '../components/report/ReportHeader';
import ClinicSnapshot from '../components/report/ClinicSnapshot';
import ChannelOverview from '../components/report/ChannelOverview';
@@ -127,28 +128,28 @@ export default function ReportPage() {
brandColors={data.clinicSnapshot.brandColors}
/>
<ClinicSnapshot data={data.clinicSnapshot} />
<SectionErrorBoundary><ClinicSnapshot data={data.clinicSnapshot} /></SectionErrorBoundary>
<ChannelOverview channels={data.channelScores} />
<SectionErrorBoundary><ChannelOverview channels={data.channelScores} /></SectionErrorBoundary>
<YouTubeAudit data={data.youtubeAudit} />
<SectionErrorBoundary><YouTubeAudit data={data.youtubeAudit} /></SectionErrorBoundary>
<InstagramAudit data={data.instagramAudit} />
<SectionErrorBoundary><InstagramAudit data={data.instagramAudit} /></SectionErrorBoundary>
<FacebookAudit data={data.facebookAudit} />
<SectionErrorBoundary><FacebookAudit data={data.facebookAudit} /></SectionErrorBoundary>
<OtherChannels
<SectionErrorBoundary><OtherChannels
channels={data.otherChannels}
website={data.websiteAudit}
/>
/></SectionErrorBoundary>
<ProblemDiagnosis diagnosis={data.problemDiagnosis} />
<SectionErrorBoundary><ProblemDiagnosis diagnosis={data.problemDiagnosis} /></SectionErrorBoundary>
<TransformationProposal data={data.transformation} />
<SectionErrorBoundary><TransformationProposal data={data.transformation} /></SectionErrorBoundary>
<RoadmapTimeline months={data.roadmap} />
<SectionErrorBoundary><RoadmapTimeline months={data.roadmap} /></SectionErrorBoundary>
<KPIDashboard metrics={data.kpiDashboard} clinicName={data.clinicSnapshot.name} />
<SectionErrorBoundary><KPIDashboard metrics={data.kpiDashboard} clinicName={data.clinicSnapshot.name} /></SectionErrorBoundary>
</div>
</div>
</ScreenshotProvider>