feat: build Onyx SSR shell and plan hero with mock data

This commit is contained in:
Noel Sabia committed 2026-11-14 05:17:36 +01:00
1 parent 84c20992f9
commit 2db494fb10
34 files changed
+3197 -2

No files matched your search

+143
View File
@@ -0,0 +1,143 @@
<script setup lang="ts">
import { iconCircleInformation, iconShieldUser, iconTriangleWarning } from '@sit-onyx/icons'
import type { MetaResponse } from '#shared/types'
import { formatDate, formatDateTime, formatPercent } from '~/utils/format'
useHead({ title: 'About the data and limits — PulseCast' })
const { data: meta } = await useFetch<MetaResponse>('/api/meta')
</script>
<template>
<div class="page page-stack">
<header class="page-header">
<div>
<p class="eyebrow">About · method, data and limits</p>
<OnyxHeadline is="h1">A decision aid, not a city-wide truth.</OnyxHeadline>
<p class="lede">
PulseCast turns a footfall forecast into a next-week staffing plan. The forecast is a model output; the
staffing rule is a transparent heuristic. Both are shown, editable, and bounded.
</p>
</div>
<OnyxBadge color="warning">Hackathon prototype</OnyxBadge>
</header>
<div class="summary-grid">
<MetricCard
label="Sensors"
:value="String(meta?.coverage.sensors ?? 8)"
hint="Fixed points in a 580 m inner-city cluster."
:icon="iconCircleInformation"
/>
<MetricCard
label="Model WAPE"
:value="meta ? formatPercent(meta.metrics.wape, 1) : '—'"
:badge="meta ? `baseline ${formatPercent(meta.metrics.baseline_wape, 1)}` : undefined"
badge-color="success"
hint="Time-based holdout, not a random split."
/>
<MetricCard
label="R²"
:value="meta ? meta.metrics.r2.toFixed(3) : '—'"
:hint="meta ? `MAE ${meta.metrics.mae} devices/hour` : undefined"
/>
<MetricCard
label="Cadence"
:value="meta ? `${meta.coverage.cadence_min} min` : '—'"
:hint="meta ? `${formatDate(meta.coverage.from)} → ${formatDate(meta.coverage.to)}` : undefined"
/>
</div>
<div class="split-grid">
<div class="card-stack">
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h2">How the plan is made</OnyxHeadline>
<OnyxBadge color="info" density="compact">transparent heuristic</OnyxBadge>
</div>
<ol class="small" style="margin: 0; padding-left: 1.2rem; display: grid; gap: var(--onyx-density-sm)">
<li>Forecast estimated devices per hour for the next 7 days.</li>
<li>Divide by visitors per staff-hour, multiply by a safety factor, round up, apply minimum staff.</li>
<li>Cover 10:00–20:00 with consecutive shift blocks; a block gets the peak requirement inside it.</li>
<li>Score coverage, cost, over/understaffed hours and compare with a flat schedule.</li>
<li>Show the weather, holiday and assumption drivers; let the manager edit and regenerate.</li>
</ol>
<div class="callout" style="margin-top: var(--onyx-density-md)">
<p class="small" style="margin: 0">
There is no POS, sales, queue, payroll or labour-cost feed. Cost is an assumption. The coverage score
is high by construction because shift blocks cover their local peak; overstaffed hours are the honest
trade-off.
</p>
</div>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h2">Model and data coverage</OnyxHeadline>
</div>
<OnyxTable striped :table-attrs="{ style: 'min-width: 34rem' }">
<template #head>
<tr><th scope="col">Field</th><th scope="col">Value</th></tr>
</template>
<tr><th scope="row" style="text-align: left; font-weight: 600">Data version</th><td class="mono">{{ meta?.data_version ?? '—' }}</td></tr>
<tr><th scope="row" style="text-align: left; font-weight: 600">Model version</th><td class="mono">{{ meta?.model_version ?? '—' }}</td></tr>
<tr><th scope="row" style="text-align: left; font-weight: 600">Context version</th><td class="mono">{{ meta?.context_version ?? '—' }}</td></tr>
<tr><th scope="row" style="text-align: left; font-weight: 600">Coverage</th><td>{{ meta ? `${formatDate(meta.coverage.from)} → ${formatDate(meta.coverage.to)}` : '—' }}</td></tr>
<tr><th scope="row" style="text-align: left; font-weight: 600">Validation</th><td>{{ meta ? `WAPE ${formatPercent(meta.metrics.wape, 1)} · baseline ${formatPercent(meta.metrics.baseline_wape, 1)} · R² ${meta.metrics.r2}` : '—' }}</td></tr>
<tr><th scope="row" style="text-align: left; font-weight: 600">Weather source</th><td>Open-Meteo archive + forecast (mock context)</td></tr>
<tr><th scope="row" style="text-align: left; font-weight: 600">Holidays</th><td>Baden-Württemberg 2025–2026 public holidays</td></tr>
</OnyxTable>
<p class="small muted table-note">Meta is rendered from <code>web-nuxt/mock/meta.json</code> until the Go API exists.</p>
</OnyxCard>
<TrainModelCard />
</div>
<aside class="card-stack">
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h2">Limits</OnyxHeadline>
<OnyxIcon :icon="iconTriangleWarning" size="24px" color="warning" />
</div>
<ul class="why-list">
<li v-for="limit in meta?.limits ?? []" :key="limit">
<OnyxIcon :icon="iconTriangleWarning" size="16px" color="warning" />
<span>{{ limit }}</span>
</li>
</ul>
<p class="small muted table-note">
Eight sensors in one pedestrian cluster cannot rank commercial zones across Heilbronn. There is no
city-wide heatmap claim here.
</p>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h2">Privacy</OnyxHeadline>
<OnyxIcon :icon="iconShieldUser" size="24px" color="primary" />
</div>
<ul class="small" style="margin: 0; padding-left: 1.1rem; display: grid; gap: var(--onyx-density-xs)">
<li>No PII, MAC addresses or geolocation permission.</li>
<li>Audience sessions use a random ID only.</li>
<li>Public read-only screens; control actions are authenticated separately.</li>
<li>Raw challenge CSV and secrets stay out of this repository.</li>
</ul>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h3">Mock status</OnyxHeadline>
</div>
<p class="small muted" style="margin-top: 0">
Mock data renders the full app before the API exists. Nitro routes in <code>server/api</code> mirror the
contract. Versions and metrics are sample values; the plan heuristic is implemented once in
<code>shared/staffing.ts</code> and reused by the mock API.
</p>
<p class="small muted" style="margin: 0">
Last context update: {{ meta ? formatDateTime(meta.context_version) : '—' }}
</p>
</OnyxCard>
</aside>
</div>
</div>
</template>