# Admin performance review (draft)

Drafts only: [API642](https://github.com/CoDuckAI/api-v5/pull/642) and [frontend676](https://github.com/CoDuckAI/frontend-v2/pull/676). No merge or production deployment. [Paired HTTPS app](https://feat-admin-page-performance.pr.coduck.ai/admin); [real-browser proof](../proof/admin-page-performance/REPORT.md); [per-endpoint authorization](../proof/admin-page-performance/AUTHORIZATION.md).

## Measurement

Before application edits: API9452bfa4/frontend16dd0c9dd have identical `src/` to main f9e406a3/7ea47af2b. After: API83827b18/frontend219a3babe. Same synthetic356-user/880-build fixture, own HTTPS preview,1440×1000 desktop Chromium, sequential fresh-document navigation, same date range. Each cold run starts by restarting only this preview API and waiting for health. No production sign-in, production writes or charges. Stripe reads use existing test mode.

One observation per surface, not a statistical production benchmark. Times are navigation/click to visible selected data; screenshots/holds excluded. The after implementation revalidates all persisted queries on every new document, as requested; the baseline reused server snapshots. Some hard-document routes regress, especially Issues and standalone Revenue. Home first activity is67% faster; its full payment report is **not faster**. Persistent reopening still waits for live authorization before showing private data. Cached switch times include route/chunk rendering, without cursor dwell.

| Surface | Before fresh document (ms) | After fresh document (ms) | After cached switch (ms) |
| --- | ---: | ---: | ---: |
| Home | 3866 | 1259 | 245 |
| Analytics overview | 777 | 1287 | 785 / 294 |
| Analytics growth | 1542 | 525 | 187 |
| Analytics churn | 2339 | 433 | 143 |
| Analytics features | 634 | 603 | 200 |
| Analytics revenue | 2375 | 566 | 158 |
| Analytics issues | 627 | 1939 | 317 |
| Site | 263 | 343 | 145 |
| Revenue | 470 | 2641 | 185 |
| Goals | 355 | 323 | 225 |
| Needs me | 293 | 358 | 81 |
| Issues & fixes | 292 | 337 | 56 |
| Users | 393 | 395 | 134 |
| CRM | 966 | 483 | 158 |
| Site health | 391 | 311 | 110 |
| Settings | 426 | 436 | 177 |

Home full payment completion: before3866ms, after4078ms. Analytics Overview cached values distinguish opening the Analytics route (785ms) and selecting Overview within it (294ms). Standalone Revenue baseline already had a warm report from Analytics Revenue.

Raw navigation/endpoint timings, actual requests, screenshots, preserved before movie and after master are in the proof pack. Failed selector/startup/rebuild diagnostics were excluded, with causes recorded in the company task. The canonical after capture observed383 successful admin responses and no browser page errors.

## Endpoint and query findings

The same sequential GET timing procedure records complete decoded response bodies; all results below are200. JSON sizes are decoded bytes, not compressed transfer sizes. Timing includes TLS/transport and response body.

- `/admin/operating`: 3633 → 2870ms; 25646 → 25646 JSON bytes.
- `/admin/analytics/overview?days=30`: 94 → 119ms; 10737 → 10737 JSON bytes.
- `/admin/analytics/growth?days=30`: 723 → 712ms; 4211 → 4211 JSON bytes.
- `/admin/analytics/churn?days=30`: 2438 → 1905ms; 8023 → 8023 JSON bytes.
- `/admin/analytics/features?days=30`: 152 → 152ms; 309631 → 309631 JSON bytes.
- `/admin/analytics/revenue?days=30`: 1868 → 2017ms; 12619 → 12619 JSON bytes.
- `/admin/analytics/issues?days=30`: 35 → 35ms; 6205 → 6205 JSON bytes.
- `/admin/analytics/site?path=all&device=all&days=30`: 30 → 43ms; 923 → 923 JSON bytes.
- `/admin/goals`: 20 → 23ms; 704 → 704 JSON bytes.
- `/admin/users?take=25&skip=0`: 38 → 43ms; 15956 → 15981 JSON bytes.
- `/admin/invites`: 20 → 18ms; 14 → 14 JSON bytes.
- `/admin/feedback`: 16 → 18ms; 15 → 15 JSON bytes.
- `/admin/infra`: 75 → 59ms; 529 → 528 JSON bytes.
- `/admin/errors`: 19 → 20ms; 385 → 385 JSON bytes.
- `/admin/vps-history`: 16 → 16ms; 885 → 885 JSON bytes.
- `/admin/settings`: 15 → 16ms; 3254 → 3254 JSON bytes.
- `/admin/checkpoints`: 16 → 15ms; 18 → 18 JSON bytes.
- `/admin/app-ai/rollout`: 19 → 16ms; 252 → 252 JSON bytes.
- New `/admin/operating?activity=1`: 61ms, 25686 JSON bytes.
- New `/admin/analytics/features?days=30&compact=1`: 142ms, 141172 JSON bytes.

Home EXPLAIN ANALYZE execution: current traffic0.631ms, previous traffic0.158ms, users9.967ms, on the synthetic fixture. Existing queries batch database aggregates; no measured SQL N+1 or missing-index bottleneck justified a migration. **No index/schema migration** is proposed. Production-scale query plans were unavailable without an owner session; these results do not establish production database performance.

Server fixes: separate real Home activity from GET-only payment-provider waits; losslessly compact Features defaults (309631→141172 JSON bytes,54.4% smaller); group catalog/features/days once instead of repeated scans/date formatting; deduplicate namespace/route live admin lookups only within a request. Full provider-backed Home/Churn/Revenue remain the slowest reads. No payment definitions or provider writes changed.

## Cache and authorization

- Landing data paints before background prefetch begins; all primary destinations and six Analytics reports then load in parallel.
- Browser application cache is scoped by verified user and API origin, never credentials.60s switch/focus freshness, stale copy remains visible; newly authorized documents/hard reload and Refresh force revalidation. Eligible saved entries expire after24h;2M-character disk budget and96 memory entries. Disk serialization is batched during idle time and flushed on pagehide. Expiry limits hydration eligibility; it is not timed physical deletion while the browser is closed.
- Accepted writes invalidate only affected data/dependent reports. Logout, invalid restored auth, account change and401/403 clear disk/memory and invalidate in-flight responses. No offline bypass of current account/admin authorization.
- Live authentication and current database admin role on every API admin namespace/early record/SDK route, and every frontend admin handler. Analytics-role access is deliberately removed. No legacy shared key bypass. Backend report snapshots are keyed by account. HTTP success, denial and error responses use `Cache-Control: no-store, private`.
- Removed shared frontend payload caching and30s role caching. Machine report ingestion uses separate secret-gated `/api/internal/test-passes`; account-only `/api/admin/test-passes` keeps full admin enforcement. See the updated Pilot integration note; deployed callers were not modified here.

## Verification and limits

Frontend335/335 local tests and TypeScript pass; normal build/test CI passes. API local guard168/168, codec/hierarchy18/18 and read-only record6/6 pass; normal API build/full tests, operating/payment, depth-report and read-only-record CI pass. Local whole API typecheck is limited by a borrowed dependency's stale generated Prisma types from main641; fresh CI/preview generation passes. Shared dependencies were not changed.

Complete HTTPS proof: seven journeys, every primary view and six tabs; persisted Home before a real1100ms delayed refresh;23 forced API paths;61s stale-focus refetch; synthetic Goal save reflected in Home with Revenue cache unchanged; unsaved settings survive background refresh; logout session401; live admin→analytics403/recovery;320,390,430,768,1280-width viewport controls. Delayed network and virtual clock are excluded from benchmarks. All172 endpoint/method pairs reject anonymous401, ordinary member403 and analytics-role403 with private/no-store headers; [every result](../proof/admin-page-performance/AUTHORIZATION.md) and JSON are committed. Safe positive early-record/SDK checks do not save config or run charges.

Existing Paper dashboard appearance retained. Desktop/phone screenshots visually reviewed; no overflow or hidden Refresh. UI slop score2/10, product distinctiveness8/10; no broad accessibility or redesign claim.

Linear/GitHub credentials are intentionally absent, so Needs me/Issues & fixes show disconnected integration states; connected production integrations are not proven. Dataset and Stripe account are test fixtures. Remaining payment latency and cold reload regressions are documented above. Final proof-only commits have application runtime source identical to the measured heads; exact final preview identities are checked again after those commits. No merge, dev deployment or production deployment performed.


## Nov30 latest-main revalidation

Rebased onto APIc5cec7fc/frontend8f2ca9af, preserving643/644 and677/678. Needs me remains removed; its old URL308 redirects Home. New actual HTTPS proof227/227 with172 denied endpoint/method rows and five completed responsive Refresh outcomes: [recording and assertions](../proof/admin-performance-rebase/REPORT.md), [current15-view timing observations and endpoints](../proof/admin-performance-rebase/PERFORMANCE.md). Home first data996ms/full3538ms; cached switches92–382ms after initial Analytics643ms. Historical Nov28 baseline/media above are preserved. Single synthetic observations; forced-document regressions and payment-provider latency remain.

Liam approved merge Nov30; production release is pending normal CI, proof and safe API-first deployment. No production result is claimed by this PR evidence.
