現状の全体図(問題箇所の癒着・散乱)
flowchart TD
classDef redProblem fill:#fee2e2,stroke:#ef4444,stroke-width:2px,color:#991b1b;
classDef neutralNode fill:#1f2937,stroke:#374151,color:#f3f4f6;
subgraph UI ["フロントエンド層"]
UI1["Checkout UI (決済失敗を成功偽装)"]:::redProblem
end
subgraph API ["APIファサード層"]
A1["uploads (ハードコード計算)"]:::redProblem
A2["checkout/sessions (未登録キー通過)"]:::redProblem
end
subgraph Domain ["ドメイン層"]
D1["Capacity Engine (形骸化)"]:::redProblem
end
subgraph Storage ["インフラ層"]
DB[(Cloudflare D1)]:::neutralNode
R2[(R2: ゾンビデータ放置)]:::redProblem
end
UI1 -.->|"偽装完了"| A2
A1 -.->|"直書き計算"| DB
A2 -.->|"Fail-Open通過"| DB
修正後の全体図(高凝集・疎結合・堅牢防御)
flowchart TD
classDef greenClean fill:#dcfce7,stroke:#22c55e,stroke-width:2px,color:#14532d;
classDef neutralNode fill:#1f2937,stroke:#374151,color:#f3f4f6;
subgraph UI ["1. UI層 (描画 & 状態受付)"]
V1["Checkout (厳密なエラー境界)"]:::greenClean
end
subgraph Facade ["2. サービス・ファサード層"]
F1["Auth Guard (Fail-Closed)"]:::greenClean
F2["Upload Facade"]:::neutralNode
end
subgraph Domain ["3. コア・ドメイン層 (I/O完全非依存)"]
C1["Capacity Engine (SSOT)"]:::greenClean
end
subgraph Storage ["4. インフラ層 (完全不可分)"]
R1["File Lifecycle Manager (DB+R2)"]:::greenClean
end
V1 --> F1 --> C1 --> R1
F2 --> C1