Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
302 changes: 211 additions & 91 deletions src/pages/examples/AiGatewayDashboardExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { AreaChart } from '../../dashkit/AreaChart/AreaChart';
import { ProgressBar } from '../../dashkit/ProgressBar/ProgressBar';
import { Avatar } from '../../dashkit/Avatar/Avatar';
import { Button } from '../../dashkit/Button/Button';
import { Badge } from '../../dashkit/Badge/Badge';
import { Tabs, TabsList, TabsTrigger } from '../../dashkit/Tabs';
import {
Dropdown,
Expand Down Expand Up @@ -727,58 +728,60 @@ export const AiGatewayDashboardExample = () => {
<CardHeader
leftIcon={<FiKey size={18} />}
action={
<div className="flex items-center gap-1.5 text-xs font-medium text-muted-foreground">
<span className="size-1.5 rounded-full bg-emerald-500 shrink-0" />
<span>{apiKeys.length} Active Keys</span>
</div>
<Badge color="success" variant="soft" dot content={`${apiKeys.length} Active Keys`} />
}
>
<CardTitle as="h2">API Gateway Credentials</CardTitle>
<CardDescription>Bearer token authentication and RPM throttles</CardDescription>
</CardHeader>
<CardContent className="flex-1 flex flex-col justify-between divide-y divide-border/60 pt-1">
{apiKeys.map((key) => (
<div key={key.id} className="flex items-center justify-between gap-4 py-2.5 first:pt-0 last:pb-0">
<div className="flex items-center gap-3 min-w-0">
<div className="size-8 rounded-lg bg-muted flex items-center justify-center text-muted-foreground shrink-0">
<FiKey size={15} />
</div>
<div className="flex flex-col min-w-0 gap-0.5">
<span className="font-semibold text-sm text-foreground truncate">{key.name}</span>
<div className="flex items-center gap-2 text-xs text-muted-foreground">
<span className="text-muted-foreground/90 font-mono font-medium">{key.prefix}</span>
<span className="text-muted-foreground/30 text-[10px]">•</span>
<span>{key.rpmLimit}</span>
<span className="text-muted-foreground/30 text-[10px]">•</span>
<span>Created {key.created}</span>
<CardContent className="flex-1 flex flex-col justify-between pt-1">
<div className="divide-y divide-border/60">
{apiKeys.map((key) => (
<div key={key.id} className="flex items-center justify-between gap-4 py-3 first:pt-0 last:pb-0">
<div className="flex items-center gap-3 min-w-0">
<div className="size-9 rounded-lg bg-muted/70 border border-border/50 flex items-center justify-center text-muted-foreground shrink-0">
<FiKey size={15} />
</div>
<div className="flex items-center gap-1.5 text-xs font-medium text-emerald-500 pt-0.5">
<span className="size-1.5 rounded-full bg-emerald-500 shrink-0" />
<span>{key.status}</span>
<div className="flex flex-col min-w-0 gap-1">
<div className="flex items-center gap-2 min-w-0">
<span className="font-semibold text-sm text-foreground truncate">{key.name}</span>
<span className="inline-flex items-center gap-1 text-[11px] font-medium text-emerald-600 dark:text-emerald-400 shrink-0">
<span className="size-1.5 rounded-full bg-emerald-500 shrink-0" />
{key.status}
</span>
</div>
<div className="flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground">
<code className="font-mono text-[11px] font-medium px-1.5 py-0.5 rounded bg-muted text-foreground/80">
{key.prefix}
</code>
<span className="font-medium text-foreground/80 tabular-nums">{key.rpmLimit}</span>
<span className="text-muted-foreground/40">•</span>
<span>Created {key.created}</span>
</div>
</div>
</div>
<Button
variant="outlined"
size="sm"
leftIcon={<FiCopy size={13} />}
onClick={() => {
navigator.clipboard?.writeText(key.prefix);
toast({
title: 'Key Copied',
description: `${key.name} token prefix copied.`,
type: 'success',
});
}}
>
Copy
</Button>
</div>
<Button
variant="ghost"
size="sm"
leftIcon={<FiCopy size={13} />}
onClick={() => {
navigator.clipboard?.writeText(key.prefix);
toast({
title: 'Key Copied',
description: `${key.name} token prefix copied.`,
type: 'success',
});
}}
>
Copy
</Button>
</div>
))}
))}
</div>

<div className="flex items-center justify-between text-xs pt-3">
<div className="flex items-center justify-between text-xs border-t border-border/60 pt-3 mt-4">
<span className="text-muted-foreground font-medium">Automatic Key Rotation</span>
<div className="flex items-center gap-1.5 font-medium text-emerald-500">
<div className="flex items-center gap-1.5 font-medium text-emerald-600 dark:text-emerald-400">
<span className="size-1.5 rounded-full bg-emerald-500 shrink-0" />
<span>90d Policy Enforced</span>
</div>
Expand All @@ -791,74 +794,191 @@ export const AiGatewayDashboardExample = () => {
<CardHeader
leftIcon={<FiShield size={18} />}
action={
<div className="flex items-center gap-1.5 text-xs font-medium text-emerald-500">
<span className="size-1.5 rounded-full bg-emerald-500 shrink-0" />
<span>Protected</span>
</div>
<Badge color="success" variant="soft" dot content="Protected" />
}
>
<CardTitle as="h2">Safety Guardrails & Compliance</CardTitle>
<CardDescription>Real-time PII anonymization and injection protection</CardDescription>
</CardHeader>
<CardContent className="flex-1 flex flex-col justify-between divide-y divide-border/60 pt-1">
{[
{
icon: <FiShield size={15} />,
label: 'PII Redaction Engine',
detail: 'Masking SSNs, credit cards, and emails on ingress',
status: 'Active',
stat: '142 masked today',
},
{
icon: <FiLock size={15} />,
label: 'Prompt Injection Defense',
detail: 'Heuristic & embedding-based jailbreak blocking',
status: 'Clean',
stat: '0 breaches',
},
{
icon: <FiCheckCircle size={15} />,
label: 'Content Safety Moderation',
detail: 'Hate speech, harassment, and toxicity filter',
status: 'Passed',
stat: '100% compliant',
},
{
icon: <FiDollarSign size={15} />,
label: 'Cost Budget Caps',
detail: 'Hard circuit breaker at $250.00 / day threshold',
status: 'Strict',
stat: 'Usage at 24%',
},
].map((sec) => (
<div key={sec.label} className="flex items-center justify-between gap-4 py-2.5 first:pt-0 last:pb-0">
<div className="flex items-center gap-3 min-w-0">
<div className="size-8 rounded-lg bg-muted flex items-center justify-center text-muted-foreground shrink-0">
{sec.icon}
<CardContent className="flex-1 flex flex-col justify-between pt-1">
<div className="divide-y divide-border/60">
{[
{
icon: <FiShield size={15} />,
label: 'PII Redaction Engine',
detail: 'Masking SSNs, credit cards, and emails on ingress',
status: 'Active',
stat: '142 masked today',
},
{
icon: <FiLock size={15} />,
label: 'Prompt Injection Defense',
detail: 'Heuristic & embedding-based jailbreak blocking',
status: 'Clean',
stat: '0 breaches',
},
{
icon: <FiCheckCircle size={15} />,
label: 'Content Safety Moderation',
detail: 'Hate speech, harassment, and toxicity filter',
status: 'Passed',
stat: '100% compliant',
},
{
icon: <FiDollarSign size={15} />,
label: 'Cost Budget Caps',
detail: 'Hard circuit breaker at $250.00 / day threshold',
status: 'Strict',
stat: 'Usage at 24%',
},
].map((sec) => (
<div key={sec.label} className="flex items-center justify-between gap-4 py-3 first:pt-0 last:pb-0">
<div className="flex items-center gap-3 min-w-0">
<div className="size-9 rounded-lg bg-muted/70 border border-border/50 flex items-center justify-center text-muted-foreground shrink-0">
{sec.icon}
</div>
<div className="flex flex-col min-w-0 gap-0.5">
<span className="font-semibold text-foreground text-sm truncate">{sec.label}</span>
<span className="text-xs text-muted-foreground truncate">{sec.detail}</span>
</div>
</div>
<div className="flex flex-col min-w-0 gap-0.5">
<span className="font-semibold text-foreground text-sm truncate">{sec.label}</span>
<span className="text-xs text-muted-foreground truncate">{sec.detail}</span>
<div className="flex items-center gap-1.5 text-xs font-medium text-emerald-500 pt-0.5">
<div className="flex flex-col items-end shrink-0 gap-0.5 text-right">
<span className="text-xs font-semibold text-foreground tabular-nums">{sec.stat}</span>
<span className="inline-flex items-center gap-1 text-[11px] font-medium text-emerald-600 dark:text-emerald-400">
<span className="size-1.5 rounded-full bg-emerald-500 shrink-0" />
<span>{sec.status}</span>
</div>
{sec.status}
</span>
</div>
</div>
<span className="text-[11px] text-muted-foreground shrink-0">{sec.stat}</span>
</div>
))}
))}
</div>

<div className="flex items-center justify-between text-xs pt-3">
<div className="flex items-center justify-between text-xs border-t border-border/60 pt-3 mt-4">
<span className="text-muted-foreground font-medium">Enterprise Audit Trail</span>
<div className="flex items-center gap-1.5 font-medium text-emerald-500">
<div className="flex items-center gap-1.5 font-medium text-emerald-600 dark:text-emerald-400">
<span className="size-1.5 rounded-full bg-emerald-500 shrink-0" />
<span>SOC2 & HIPAA Compliant</span>
</div>
</div>
</CardContent>
</Card>
</div>

{/* ROUTING & FAILOVER POLICY (FULL WIDTH) */}
<Card>
<CardHeader
leftIcon={<FiSliders size={18} />}
action={
<div className="flex items-center gap-2.5">
<Badge color="info" variant="soft" dot content="Latency-First Routing" />
<Button
variant="outlined"
size="sm"
leftIcon={<FiRefreshCw size={13} />}
onClick={() =>
toast({
title: 'Failover Health Check Passed',
description: 'All 3 upstream providers responded within SLA (<220ms).',
type: 'success',
})
}
>
Test Failover
</Button>
</div>
}
>
<CardTitle as="h2">Routing & Failover Policy</CardTitle>
<CardDescription>
Multi-provider load balancing, semantic caching, and automatic fallback order
</CardDescription>
</CardHeader>
<CardContent className="pt-1">
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
{[
{
priority: 'Primary',
provider: 'Anthropic',
model: 'claude-3-5-sonnet',
traffic: 62,
latency: '184ms p95',
uptime: '99.98%',
badgeColor: 'primary' as const,
},
{
priority: 'Secondary',
provider: 'OpenAI',
model: 'gpt-4o',
traffic: 28,
latency: '215ms p95',
uptime: '99.95%',
badgeColor: 'base' as const,
},
{
priority: 'Fallback',
provider: 'Google',
model: 'gemini-2.5-pro',
traffic: 10,
latency: '168ms p95',
uptime: '99.99%',
badgeColor: 'base' as const,
},
].map((route) => (
<div
key={route.model}
className="flex flex-col gap-3 rounded-xl border border-border/70 bg-muted/20 p-4"
>
<div className="flex items-center justify-between gap-2">
<div className="flex items-center gap-2 min-w-0">
<Badge color={route.badgeColor} variant="soft" content={route.priority} />
<span className="text-xs font-medium text-muted-foreground truncate">
{route.provider}
</span>
</div>
<span className="text-xs font-semibold text-foreground tabular-nums">
{route.traffic}% traffic
</span>
</div>

<div className="flex flex-col gap-1">
<span className="text-sm font-semibold font-sans text-foreground truncate">
{route.model}
</span>
<div className="flex items-center gap-3 text-xs text-muted-foreground tabular-nums">
<span>{route.latency}</span>
<span className="text-muted-foreground/40">•</span>
<span className="text-emerald-600 dark:text-emerald-400 font-medium">
{route.uptime} uptime
</span>
</div>
</div>

<ProgressBar value={route.traffic} size="sm" />
</div>
))}
</div>

<div className="flex flex-wrap items-center justify-between gap-3 text-xs border-t border-border/60 pt-3 mt-4">
<div className="flex flex-wrap items-center gap-x-4 gap-y-1 text-muted-foreground">
<span>
Semantic Cache Hit: <strong className="text-foreground tabular-nums">34.8%</strong>
</span>
<span className="text-muted-foreground/40">•</span>
<span>
Circuit Breaker: <strong className="text-foreground">&lt; 2% 5xx / 60s</strong>
</span>
<span className="text-muted-foreground/40">•</span>
<span>
Retries: <strong className="text-foreground">2x exponential backoff</strong>
</span>
</div>
<div className="flex items-center gap-1.5 font-medium text-emerald-600 dark:text-emerald-400">
<span className="size-1.5 rounded-full bg-emerald-500 shrink-0" />
<span>Multi-Region Active</span>
</div>
</div>
</CardContent>
</Card>
</div>
</main>
</div>
Expand Down
Loading