4.2 KiB
4.2 KiB
1) Prioritized debt list
- Monolithic
actions/index.js(over-coupled “god module”) - Inconsistent API error handling/response contracts across
pages/api/** - Sensitive/verbose logging in app + API paths
- Endpoint sprawl and duplicated proxy patterns (
pages/api/endpoint/*_api.js) - i18n routing complexity in large rewrite maps
- Sparse automated test coverage for high-risk flows
- Legacy/stale commented patterns in critical files
2) Impact of each item
-
1)
actions/index.jsmonolith- High blast radius for any change; weak modularity and hard ownership boundaries.
- Evidence: ~100+ exports mixing search, auth, account, file, PDF, notify, CRM concerns.
-
2) API contract inconsistency
- Clients must handle errors inconsistently; reliability and observability suffer.
- Evidence: many handlers return raw
res.status(400).json(error)while others shape custom outputs.
-
3) Verbose/sensitive logging
- Privacy/security risk plus noisy telemetry.
- Evidence: 300+
console.logoccurrences, including auth/email/upload-related contexts.
-
4) Endpoint duplication
- Maintenance cost and drift risk (validation/auth/error semantics diverge over time).
- Evidence: repeated patterns across many
_api.jsproxy handlers.
-
5) i18n rewrite complexity
- Higher risk of EN/CY divergence as routes evolve.
- Evidence: large manual rewrite map + separate i18n page namespace config.
-
6) Sparse tests
- Release confidence depends heavily on manual checks; slower, riskier change cadence.
-
7) Stale patterns
- Increased cognitive load and unclear source-of-truth behavior in some modules.
3) Recommended next cleanup targets
- Decompose
actions/index.jsby domain (structure-only first, keep barrel exports). - Add shared API handler utilities for validation/error envelope; migrate top sensitive endpoints first.
- Implement logging redaction wrapper + policy and remove direct logs in auth/email/file paths.
- Create high-risk smoke tests (auth callback, search endpoint, upload negative-path, email failure-path).
- Extract proxy/integration helpers (token/hash/header/retry) to reduce endpoint duplication.
- Add EN/CY parity CI checks for route and locale key consistency.
4) Runtime note (updated)
server.jsandserver/server.jsexist in the repository but are not the active production concern for the current refactor stream.- Current baseline runtime for this debt plan is the standard Next runtime path (
npm start). - Runtime canonicalization is therefore removed from the active prioritized debt list unless deployment evidence changes.
5) Progress snapshot against architecture/debt review (2026-03-25)
Cross-referenced with:
context/architecture.md(status + execution sequence)memory-bank/architect-review.md
Status by debt item:
- Monolithic
actions/index.js-> in progress- Significant modular extraction completed (shared clients and route helpers), but full domain split remains open.
- Inconsistent API contracts -> major progress
- Broad endpoint hardening and contract normalization completed across many route clusters.
- Sensitive/verbose logging -> partial progress
- Relay path improved; broader auth/email/file redaction standardization still pending.
- Endpoint sprawl/duplication -> major progress
- Shared relay/request helpers reduced repeated route logic; long-tail cleanup remains.
- i18n rewrite complexity -> improving
- Targeted EN/CY rewrite parity automation now exists; CI enforcement still pending.
- Sparse high-risk tests -> major progress
- Focused automation now covers auth redirect safety, signed-delete/upload negative paths, and EN/CY parity checks.
- Legacy/stale patterns -> partial progress
- Multiple cleanup slices completed; still an ongoing hygiene lane.
Immediate recommended next lane (aligned to architecture Sequence B):
- Consolidate signed-request patterns behind a focused helper.
- Apply broader logging hardening in auth/file/email/account-sensitive paths.
If you want, I can convert this into a sprint-ready debt register (ID, owner, effort, risk reduction, target milestone).