import React, { useState } from 'react';
import { marked } from 'marked';
import {
FileText, Shield, Layers, HelpCircle, HardDrive,
Terminal, Download, Eye, Play, ListFilter,
AlertTriangle, Network, ChevronDown, ChevronRight, Database
} from 'lucide-react';
import GraphViewer from './GraphViewer';
import RepositoryAssistant from './RepositoryAssistant';
import KnowledgeExplorer from './KnowledgeExplorer';
import { apiUrl } from '../api';
const TABS = [
{ id: 'report', icon: , label: 'Intelligence Report' },
{ id: 'summary', icon: , label: 'Knowledge Summary' },
{ id: 'profile', icon: , label: 'Repository Profile' },
{ id: 'graph', icon: , label: 'Architecture Graph' },
{ id: 'assistant', icon: , label: 'AI Assistant' },
{ id: 'knowledge', icon: , label: 'Knowledge Explorer' },
];
export default function Dashboard({ analysisResult }) {
const [activeTab, setActiveTab] = useState('report');
const [showFullJson, setShowFullJson] = useState(false);
const { repo_id, project_name, data } = analysisResult;
const { report, profile, summary, graph } = data;
const renderedReportHtml = React.useMemo(() => {
try { return { __html: marked.parse(report || '') }; }
catch (e) { return { __html: `
Failed to render: ${e.message}
` }; }
}, [report]);
const getDownloadUrl = (type) => apiUrl(`/api/download/${repo_id}/${type}`);
return (
{/* ── Header Bar ── */}
Intelligence Dashboard
{project_name}
{profile.architecture_pattern}
{[
['report', 'Report.md'],
['profile', 'Profile.json'],
['summary', 'Summary.json'],
['graph', 'Graph.json'],
].map(([type, label]) => (
{label}
))}
{/* ── Tab Navigation ── */}
{TABS.map(t => (
))}
{/* ── Tab Content ── */}
{/* ── REPORT ── */}
{activeTab === 'report' && (
)}
{/* ── SUMMARY ── */}
{activeTab === 'summary' && (
{/* Elevator pitch */}
Project Purpose
"{summary.elevator_pitch}"
{/* Core Features */}
{summary.core_features?.map((f, i) => (
-
✓
{f}
))}
{/* Workflows */}
User Workflows
{summary.main_workflows?.map((w, i) => (
-
⚡
{w}
))}
{/* Key Components */}
Key Components
{summary.key_components?.map((c, i) => (
-
⚙
{c}
))}
{/* Risks */}
{summary.key_risks?.map((r, i) => (
-
⚠
{r}
))}
{/* Start Points */}
Where to Start Reading Code
{summary.developer_start_points?.map((pt, i) => (
{pt}
))}
)}
{/* ── PROFILE ── */}
{activeTab === 'profile' && (
Languages
{profile.languages?.map((l, i) => (
{l}
))}
Frameworks
{profile.frameworks?.map((f, i) => (
{f}
))}
Databases
{profile.databases?.map((d, i) => (
{d}
))}
Security & Auth
{profile.authentication_methods?.map((a, i) => (
{a}
))}
API Endpoints
{profile.api_endpoints?.map((ep, i) => (
{ep}
))}
Core Modules
{profile.major_modules?.map((m, i) => (
{m}
))}
Raw repository_profile.json
{showFullJson && (
{JSON.stringify(profile, null, 2)}
)}
)}
{/* ── GRAPH ── */}
{activeTab === 'graph' && (
Code Topology Graph
)}
{/* ── AI ASSISTANT ── */}
{activeTab === 'assistant' && (
)}
{/* ── KNOWLEDGE EXPLORER ── */}
{activeTab === 'knowledge' && (
)}
);
}