docs: add class diagrams of the four layers - #12
Conversation
Document the static structure the code actually has: the engine layer, the game modes, the global state and the data model, as Mermaid class diagrams GitHub renders inline. State plainly up front that the project is functional TypeScript with a single real class, StockfishEngine, and model interfaces, hooks and stores through UML stereotypes rather than inventing classes the code does not have. Include the per-table access rules, and why row-level security alone is not enough to protect a column.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a comprehensive architecture document covering engine components, game modes, global state, Supabase data models, access rules, and UML semantics. The README now links to the new architecture reference. ChangesArchitecture Documentation
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
docs/architecture.md (1)
218-222: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winKeep the
useStockfishcontract consistent across diagrams.The engine diagram exposes both
analyzeandconfigureLevel, while the game-mode diagram redeclares the same hook with onlyanalyze. Either reuse the full declaration or mark the second one as an intentionally abbreviated view.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs/architecture.md` around lines 218 - 222, Update the game-mode diagram’s useStockfish declaration to match the full contract shown in the engine diagram, including configureLevel alongside analyze, or explicitly mark it as an intentionally abbreviated view.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/architecture.md`:
- Around line 317-338: The useProgressionSync write path must not directly
persist authoritative progression data through owner-writable tables. Route
writes for progression fields such as xp, stats, unlocked_badges, and any
authoritative scores or achievements payloads through validated RPCs or enforce
equivalent column-level policies, while preserving owner scoping for permitted
client-owned fields.
---
Nitpick comments:
In `@docs/architecture.md`:
- Around line 218-222: Update the game-mode diagram’s useStockfish declaration
to match the full contract shown in the engine diagram, including configureLevel
alongside analyze, or explicitly mark it as an intentionally abbreviated view.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 661486a2-48b6-4988-a203-bd87b62142f3
📒 Files selected for processing (2)
README.mddocs/architecture.md
Make explicit what RLS does and does not guarantee here: client-written values (a score, xp, stats, badges) are asserted by the browser, and RLS only stops a player from writing another account's rows. Note that making them authoritative would need a server-side RPC the spec does not call for, and that the leaderboard shares the same bound.
Adds
docs/architecture.mdwith four Mermaid class diagrams, rendered inline by GitHub.Contents
StockfishEngine(the project's only real class), its composition byuseStockfish, its aggregation of theWorker, and its delegation to the pureucimodule.UseChessGame,UseChessClock,UseBattleGame,CoachAnalysis,PuzzleSessionandHuntGamecontracts, showing that the Piece Hunt depends on neither chess.js nor the engine.useProgressionSyncbridge to the server.Notes
The document says up front that the project is functional TypeScript holding exactly one class, and models interfaces, hooks and stores through UML stereotypes rather than inventing classes the code does not have — so the diagrams stay faithful to the source.
Every member and relationship was read off the actual files (
stockfishEngine.ts,uci.ts,levels.ts,useChessGame.ts,useBattleGame.ts,useCoachAnalysis.ts,useHuntGame.ts, the two stores,sync.tsand the migrations).Verification
All four diagrams were parsed and rendered with Mermaid locally: 0 syntax errors, 4/4 rendered.
npm run format:checkpasses.Summary by CodeRabbit