import { Activity, Server, Zap, Shield, Brain } from 'lucide-react' interface GatewayStats { status: 'online' | 'offline' providers: string[] metrics: { total_requests: number successful: number errors: number } } interface MemoryStats { journal_entries: number context_keys: number total_session_calls: number session_calls: Record } const GATEWAY_URL = process.env.NEXT_PUBLIC_GATEWAY_URL || 'http://127.0.0.1:8787' async function getGatewayData(): Promise<{ stats: GatewayStats | null; memory: MemoryStats | null; providers: string[] }> { try { const [statsResp, memResp, provResp] = await Promise.allSettled([ fetch(`${GATEWAY_URL}/metrics`, { next: { revalidate: 10 } }), fetch(`${GATEWAY_URL}/v1/memory`, { next: { revalidate: 10 } }), fetch(`${GATEWAY_URL}/v1/providers`, { next: { revalidate: 60 } }), ]) const stats = statsResp.status === 'fulfilled' && statsResp.value.ok ? { status: 'online' as const, providers: [], metrics: (await statsResp.value.json()).metrics || {} } : null const memory = memResp.status === 'fulfilled' && memResp.value.ok ? (await memResp.value.json()).memory : null const providers = provResp.status === 'fulfilled' && provResp.value.ok ? (await provResp.value.json()).providers || [] : ['ollama', 'openai', 'anthropic', 'gemini', 'deepseek', 'groq', 'mistral'] return { stats, memory, providers } } catch { return { stats: null, memory: null, providers: ['ollama', 'openai', 'anthropic', 'gemini', 'deepseek', 'groq', 'mistral'] } } } export default async function GatewayPage() { const { stats, memory, providers } = await getGatewayData() const isOnline = stats !== null const providerIcons: Record = { ollama: '🦙', openai: '🤖', anthropic: '🧬', claude: '🧬', gemini: '💎', deepseek: '🔭', groq: '⚡', mistral: '💨' } return (
{/* Header */}

Gateway

BlackRoad Core AI Gateway — tokenless provider routing

{isOnline ? 'Online' : 'Offline'}
{/* Metrics Row */}
{[ { label: 'Total Requests', value: stats?.metrics?.total_requests ?? '—', icon: Activity }, { label: 'Successful', value: stats?.metrics?.successful ?? '—', icon: Zap }, { label: 'Errors', value: stats?.metrics?.errors ?? '—', icon: Shield }, ].map(({ label, value, icon: Icon }) => (
{value}
{label}
))}
{/* Providers */}

AI Providers ({providers.length})

{providers.map(p => (
{providerIcons[p] || '🔌'} {p}
))}
{/* Memory */} {memory && (

PS-SHA∞ Memory Journal

{memory.journal_entries}
Journal Entries
{memory.total_session_calls}
Session Calls
{memory.context_keys}
Context Keys
{memory.session_calls && Object.keys(memory.session_calls).length > 0 && (
By Agent
{Object.entries(memory.session_calls) .sort(([,a], [,b]) => b - a) .map(([agent, count]) => (
{agent}
{count}
))}
)}
)} {/* Offline state */} {!isOnline && (

Gateway is offline

Run br gateway start to start the gateway

)}
) }