docs: add repo review and next production-safe implementation phase#27
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a production-safe plan for the next phase of development, focusing on hardening the backend wallet module and addressing discrepancies between the repository and existing documentation. Review feedback highlights potential risks in exposing new API endpoints while key architectural blockers—such as the authoritative source for wallet balances and the multi-wallet persistence model—remain unresolved. A suggestion was also provided to refine the validation plan by testing the compiled build artifact rather than the source files to better simulate a production environment.
| - `GET /api/wallet/:userId/balance` | ||
| 2. Back endpoints with existing Prisma `User.walletAddress` and a conservative placeholder balance provider (no chain writes). |
There was a problem hiding this comment.
Implementing a balance endpoint with a placeholder while the authoritative source is still listed as a blocker (Line 54) introduces a risk of shipping misleading data. For a production-safe plan, the source of truth (on-chain vs. internal ledger) should be defined before exposing this API to avoid technical debt and potential consistency issues.
| Implement a **small, isolated backend slice** that closes the gap between documented and actual wallet API behavior while avoiding infra/runtime churn: | ||
|
|
||
| 1. Add `wallet` module to `apps/backend/src/modules/wallet/` with: | ||
| - `POST /api/wallet/create` |
There was a problem hiding this comment.
The POST /api/wallet/create endpoint is proposed while the multi-wallet persistence model is still a blocker (Line 53). Since the current Prisma schema enforces a unique walletAddress per User, the purpose of a 'create' endpoint is unclear. Defining the wallet cardinality should precede the API definition to prevent immediate architectural misalignment.
|
|
||
| - `pnpm --filter ./apps/backend test -- wallet` | ||
| - `pnpm --filter ./apps/backend build` | ||
| - `pnpm --filter ./apps/backend exec tsx src/main.ts` (smoke run) |
There was a problem hiding this comment.
For a production-safe validation plan, it is preferable to smoke-test the compiled build artifact rather than using tsx on source files. This ensures that the build process itself is successful and that the resulting bundle behaves as expected in an environment closer to production.
| - `pnpm --filter ./apps/backend exec tsx src/main.ts` (smoke run) | |
| - pnpm --filter ./apps/backend exec node dist/main.js (smoke run) |
Motivation
Description
docs/NEXT_PHASE_PRODUCTION_PLAN.mdwhich records findings, the recommended small backend scope (POST/api/wallet/create, GET/api/wallet/:userId, GET/api/wallet/:userId/balance), DTO/typing guidance, validation commands, blockers, and rollback notes.Testing
Codex Task