跳到主要内容

架构

Tenhou Paifu House uses a single monorepo with separated runtime boundaries:

web -> api-client -> shared-types
api -> d1-repository -> shared-types
pipeline -> tenhou parser + object-store + D1 writer

D1 is the query database. It stores identity, game metadata, per-player facts, round summaries, aggregates, ranking snapshots, and pipeline state. R2 stores raw and intermediate objects. The API reads D1 results only; expensive parsing and aggregation stay in the pipeline.

The schema is intentionally multi-table. This keeps rows narrow, supports idempotent unique keys, and lets high-traffic API paths use small indexes rather than scanning JSON blobs.