feat(categories): add confidence-scored transaction categorization (#… - #980
Merged
Conversation
…martdevs17#963) Replaces the first-match rule list with weighted signals so a payment scores against every matching category and callers get a confidence value to threshold on. Exposes it as a non-persisting suggestion endpoint (POST /categories/payments/:paymentId/suggest) so callers can preview/override before assigning. Heuristic weighted-rule scorer, not a trained model — no labeled categorization data exists yet to train one. Smartdevs17#961 (notification preferences) and Smartdevs17#962 (onboarding checklist wizard) were already fully implemented; Smartdevs17#964 (merchant dashboard with real-time metrics) already has a working push pipeline (30s interval broadcast over the analytics.updates WS channel, consumed by frontend/lib/analytics/realtime.ts on both dashboard pages), so no further scaffolding is added for those. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
@ExcelDsigN-tech is attempting to deploy a commit to the smartdevs17's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@ExcelDsigN-tech Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(categories): confidence-scored transaction categorization (Closes #961, Closes #962, Closes #963, Closes #964)
Overview
Recon before implementing found #961, #962 and #964 already fully built in the codebase, verified but not touched. #963 had a partial rule-based implementation with a genuine gap (no confidence/scoring), which this PR fills by replacing the first-match category rule list with weighted, confidence-scored signals.
Feature Summary
scoreCategories()returns ranked{category, confidence}results;inferCategory()takes the top score, preserving existing behavior for existing callersPOST /categories/payments/:paymentId/suggestendpoint lets a caller preview or override a category before calling the existingauto-assignendpointmain, closed here with no code changes to reflect that the work already existsTechnical Implementation
scoreCategories()returns ranked{category, confidence}results, andinferCategory()now just takes the top score, preserving existing behavior and callers.POST /categories/payments/:paymentId/suggestis non-persisting, letting a caller preview or override a category before calling the existingauto-assignendpoint.ponytail:comment noting the upgrade path.backend/src/services/notifications/preferenceService.ts,frontend/components/NotificationPreferences.tsx,frontend/app/dashboard/notifications/preferences/page.tsx. Implement onboarding checklist wizard #962 (onboarding checklist wizard) is implemented inbackend/src/services/onboarding/onboarding-checklist.tsplus therole-onboarding.tsroute (role-based checklist), and a separate merchant KYC onboarding wizard (frontend/components/onboarding/OnboardingChecklist.tsx). Build merchant dashboard with real-time metrics #964 (merchant dashboard, real-time metrics) is implemented viabackend/src/index.ts, which already broadcasts an analytics snapshot every 30s over theanalytics.updatesWebSocket channel, consumed byfrontend/lib/analytics/realtime.tson both dashboard pages. No code changes were made for these three; they are closed here to reflect that the work is already inmain.Test Coverage
vitest run src/services/__tests__/categories.test.ts: 4/4 passing (ranking, confidence stacking/cap, fallback-to-other,inferCategoryback-compat)eslint: clean on all touched filestsc --noEmit: reports 10 pre-existing errors in the categories module (a brokenPaymentCategoryTypeexport, since noPaymentCategorymodel exists inschema.prisma, plus a repo-widereq.params: string | string[]typing gap). Confirmed viagit stashdiff againstmainthat none of these are introduced by this change; out of scope to fix here.Files Changed
backend/src/services/categories.tsbackend/src/controllers/CategoriesController.tsbackend/src/routes/categories.tsbackend/src/services/__tests__/categories.test.tsChecklists
scoreCategories()returns ranked results,inferCategory()preserves existing behaviorsuggestendpoint added ahead of the existingauto-assignendpointtscerrors confirmed not introduced by this changeNotes for reviewers
main; the verification details for each are listed above so reviewers can confirm independently.ponytail:comment in the code.tsc --noEmiterrors in the categories module (brokenPaymentCategoryTypeexport, missingPaymentCategorymodel, repo-widereq.paramstyping gap) are confirmed present onmainviagit stashand are out of scope for this PR.