import { useState } from 'react'; import type { AnalysisResult, AppState } from './types'; import { API_BASE } from './api'; import Background from './components/Background'; import RadioNav from './components/RadioNav'; import HeroSection from './components/HeroSection'; import UploadSection from './components/UploadSection'; import ProcessingSection from './components/ProcessingSection'; import ResultSection from './components/ResultSection'; import ErrorSection from './components/ErrorSection'; import Modal from './components/Modal'; const AGENTS = [ { name: 'MetadataAgent', desc: 'Scans C2PA signatures and AI tool metadata in the first 512KB of the file.' }, { name: 'FrameAnalyzerAgent', desc: 'Extracts up to 40 frames uniformly across the video duration.' }, { name: 'FaceDetectorAgent', desc: 'Uses MediaPipe to detect and crop facial regions with 20% padding.' }, { name: 'DecisionAgent (ViT)', desc: 'Ensemble of two ViT models (99.3% + 92.1% accuracy) with early exit.' }, { name: 'AudioAuthenticator', desc: 'Wav2Vec2-based audio analysis with librosa heuristics for AV mismatch.' }, { name: 'ReportGeneratorAgent',desc: 'Adaptive threshold + confidence calibration to produce the final verdict.' }, ]; export default function App() { const [state, setState] = useState('hero'); const [result, setResult] = useState(null); const [error, setError] = useState(''); const [modal, setModal] = useState(null); async function handleAnalyze(file: File) { setState('processing'); const fd = new FormData(); fd.append('file', file); try { const res = await fetch(`${API_BASE}/analyze`, { method: 'POST', body: fd }); if (!res.ok) { const e = await res.json().catch(() => ({})); throw new Error((e as { detail?: string }).detail || `Server error ${res.status}`); } const data: AnalysisResult = await res.json(); setResult(data); setState('result'); } catch (err: unknown) { setError(err instanceof Error ? err.message : 'Connection to analysis engine failed.'); setState('error'); } } const activeNav = state === 'hero' ? 'dashboard' : state === 'upload' ? 'analyze' : state === 'processing' ? 'analyze' : state === 'result' ? 'analyze' : 'dashboard'; const handleNav = (id: string) => { if (id === 'dashboard') setState('hero'); else if (id === 'analyze') setState('upload'); else if (id === 'pricing') window.location.href = '/pricing'; else if (id === 'agents') setModal('agents'); else if (id === 'settings') setModal('network'); }; return (
{state === 'hero' && setState('upload')} />} {state === 'upload' && setState('hero')} />} {state === 'processing' && } {state === 'result' && result && setState('upload')} />} {state === 'error' && setState('upload')} />} {/* Agents Modal */} {modal === 'agents' && ( setModal(null)}>
{AGENTS.map((ag, i) => (
{i}
{ag.name}
{ag.desc}
))}
)} {/* Logs Modal */} {modal === 'logs' && ( setModal(null)}>
{[ '[BOOT] Authrix AI v2.2.0 initialized', '[SYS] ViT ensemble models loaded', '[SYS] MediaPipe face detector ready', '[SYS] Wav2Vec2 audio model ready', '[SYS] C2PA metadata scanner active', '[NET] FastAPI server listening on :8000', '[AUTH] API key validation enabled', '[CACHE] SHA256 result cache initialized', ].map((line, i) => (
{line}
))}
)} {/* Network Modal */} {modal === 'network' && ( setModal(null)}>
{[ { label: 'API Endpoint', value: window.location.origin }, { label: 'HF Space', value: 'aarav13-authrix.hf.space' }, { label: 'Max File Size', value: '100 MB' }, { label: 'Request Timeout', value: '120s' }, { label: 'Capture Duration', value: '8s' }, { label: 'Cache', value: 'SHA256 (1MB)' }, ].map(({ label, value }) => (
{label}
{value}
))}
)}
); }