← /code
OverviewFlowDecisionsHistory
Architecture · Request Flow

From click to DOM

What a request goes through between nginx, Next.js, Hono, and PostgreSQL — timings, cache-hit paths, and the full page-load journey from the user's perspective.

→

Full page-load flow

From URL input to interactive page — after the DNS split, two distinct paths. Option A shows the fork side-by-side; Option B lays events on a timing swimlane.

DNS Lookup0 ms
DNS Split
▲Vercel Edge
Vercel Edge PoP~5 ms
Edge Cache Check~8 ms
Serverless Fn~30 ms
Next SSR stream~80 ms
⬡Self-hosted VM
nginx :443~3 ms
try_files static~5 ms
proxy_pass :3002~8 ms
Next standalone SSR~20 ms
HTML + JS chunks~150 ms
React Hydrate~200 ms
apiUrl() → API~250 ms
DOM Interactive~300 ms

Full first load ~200–300ms · Repeat visits serve JS chunks from CDN/nginx instantly · API cache hits < 10ms

03

From click to DOM

A typical read (say, opening /recon/abc) runs end-to-end in under 50ms. With an nginx proxy_cache hit it drops below 10ms. Each hop's latency is plotted below.

click0 msJS handler~2 msfetch()~5 msnginx~15 msHono~18 msPG query~25 msJSON → DOM~40 ms典型读请求 · 端到端 < 50ms · 缓存命中 < 10ms
Browser
  │  GET cuberoot.me/recon/abc
  ▼
nginx :443    →  proxy_pass :3002  (一条线路:systemd Next standalone)
  │            ↘  Vercel edge      (另一条线路:同份 Next 代码)
  ▼
Next App Router  →  SSR shell stream → 客户端 hydrate
  │
  ▼
client  →  fetch(apiUrl('/v1/recon/abc'))
                          │
                          ▼
                nginx :443 (api.cuberoot.me)
                  │  proxy_cache /v1/wca/* (24h)
                  ▼
                Hono :3001    →  pg pool  →  PostgreSQL :5432
                  │
                  ▼
                JSON  →  React state  →  DOM
05

WCA stats: a separate weekly pipeline

Stats data is fully decoupled from the main site. GitHub Actions pulls the WCA public dump weekly, runs 80+ SQL-driven statistics on the runner, produces JSON + TSVs, scp's them to the VM, \copys them into PG, Hono reads them out, and nginx caches 24h on top.

WCA dump每周公开MySQL本机 :3306stats-build80+ SQL · 1 TSJSON + TSVartifacts/scp → VM~6 MBPG / API / UInginx cache 24h三处必须同步:builder.ts (写 TSV) · stats.yml (scp 清单) · load.sql (\copy 引)
09

A request walks the stack: click a tab to highlight

Section 03 sketches the "ideal read" timeline, but real URLs don't all walk the full path. Click the four tabs below to see which stages each pattern lights up — some never boot Next, some hit cache at nginx, some pierce all the way through.

  1. 01
    Browser
    fetch / nav
  2. 02
    cuberoot.me nginx
    static + try_files
  3. 03
    Next boot
    App Router + RSC
    RETURN
  4. 04
    apiUrl() fetch
    utils/api_base.ts
  5. 05
    api.cuberoot.me nginx
    proxy_cache 24h
  6. 06
    Hono server
    pm2 · :3001
  7. 07
    PostgreSQL
    :5432
~200ms 首次 · 完全不打 API

LandingPage is build-time static (SSG) HTML served straight from CDN / nginx — no Next function runs; the client hydrates and then fetches dynamic data (upcoming comps / records) client-side.

Overview·Decisions·History